我有一个自托管WCF服务通过HTTPS接受消息.
正在从Java应用程序发送消息,该应用程序接收响应:
HTTP/1.1 413 Request Entity Too Large
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 19 Sep 2012 09:05:34 GMT
Connection: close
Run Code Online (Sandbox Code Playgroud)
我没有尝试上传文件,只是发送一个78kb的XML/SOAP消息.我试过提高我的最大消息和缓冲区大小,但无济于事.
<binding name="SecuredNoProxy" openTimeout="00:00:10" sendTimeout="00:00:10">
<textMessageEncoding messageVersion="Soap11WSAddressing10" />
<security includeTimestamp="true" enableUnsecuredResponse="true">
<localClientSettings timestampValidityDuration="00:15:00" />
</security>
<httpsTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" allowCookies="false" bypassProxyOnLocal="true" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="false" requireClientCertificate="true" />
</binding>
Run Code Online (Sandbox Code Playgroud)
如果我能提供任何其他信息,请告诉我.
WCF跟踪日志
在连接'https:// localhost'上接收字节
活动边界(开始)
连接信息
抛出异常(错误)
例外是:
System.ServiceModel.ProtocolException,System.ServiceModel,Version = 4.0.0.0,Culture = neutral
我有一个在端口8080上运行的自托管API.在端口80上是我的网络服务器(IIS 7.5),我的网站无法触及.我添加了一个应用程序"MyApiTestsite".现在对/ api /或/ signalr/I的所有请求都要转发到端口8080:
http://mycompany/MyApiTestsite -> untouched
http://mycompany/MyApiTestsite/signalr/* -> http://mycompany:8080/signalr/*
http://mycompany/MyApiTestsite/api/* -> http://mycompany:8080/api/*
Run Code Online (Sandbox Code Playgroud)
我已经安装了ARR(这甚至是必要的吗?)和URL Rewrite.
这是我到目前为止的规则(对于SignalR):
<rule name="Rewrite SignalR to port 8080" patternSyntax="Wildcard" stopProcessing="true">
<match url="signalr/*" />
<serverVariables>
<set name="SERVER_PORT" value="8080" />
</serverVariables>
<action type="Rewrite" url="{R:0}" appendQueryString="true" logRewrittenUrl="false" />
</rule>
Run Code Online (Sandbox Code Playgroud)
我检查了日志文件,规则得到匹配.但是,它根本不起作用:
MyApiTestsite日志:
RULE_EVALUATION_END RuleName="Rewrite SignalR to port 8080", RequestURL="MyApiTestsite/signalr/hubs", QueryString="", StopProcessing="true", Succeeded="true"
URL_REWRITE_END RequestURL="/MyApiTestsite/signalr/hubs"
GENERAL_CHILD_REQUEST_START SiteId="4", RequestURL="http://mycompany:80/MyApiTestsite/signalr/hubs", RequestVerb="GET", RecursiveLevel="1"
Run Code Online (Sandbox Code Playgroud)
更新: 我现在根据这篇文章尝试过.但是,它仍然无效.URL似乎很好,但MvcHandler接管并返回404:
URL_REWRITE_END RequestURL ="http:// mycompany:8080/signalsr/hubs"
USER_SET AuthType ="",UserName ="",SupportsIsInRole ="true" …
我想强调测试我的Web Api自托管应用程序.此应用程序托管在Azure辅助角色上.
我知道如何从我的工作者角色到我的存储(用于分析)的性能计数器,但因为我的web api是使用Microsoft.Owin.Host.HttpListener自托管,我不知道是否有一些现有的perf计数器我可以塞.
我试过几个计数器perfmon:
当我选择Process时,我没有像req/sec等有趣的计数器......
有没有办法激活自托管Owin应用程序的一些计数器?
只使用我没有制作的配置?使用其他自我主持人?使用其他组件并修改我的代码?(添加属性......,我见过类似的东西https://github.com/aliostad/PerfIt)
非常感谢.
我正在尝试自我托管一个简单的WebAPI:
public class AccountViewApplication {
protected IDisposable WebApplication;
public void Start() {
WebApplication = WebApp.Start<WebPipeline>("http://myhost.mymachine.me:12345");
new AccountViewApplication().Start();
}
public void Stop() {
WebApplication.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
我第一次运行它,它开始听得很好,但下次我尝试 - 我得到这个:
无法侦听前缀' http://myhost.mymachine.me:12345/ ',因为它与机器上的现有注册冲突
我可以做些什么来让它每次都听,而不是抱怨现有的预订?
我试图在WinForms应用程序中自我托管一个OWIN管道.该管道正在托管静态文件和Web Api v2内容.该实现在本地工作得很好,但我不确定我缺少什么才能从我的网络上的远程机器访问托管文件和API.
为了简单起见,我下载CodePlex从样品自主机的应用程序在这里,并试图使下面的修改的基地址后远程访问的测试方法(I尝试都运行在netsh regisration和我在管理员模式下运行)和I仍然无法访问它们.我需要在配置中更改哪些内容才能查看同一网络中其他计算机的内容?
static void Main()
{
string baseAddress = "http://*:10281/";
// Start OWIN host
using (WebApp.Start<Startup>(url: baseAddress))
{
// Create HttpCient and make a request to api/values
HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync("http://localhost:10281/api/values").Result;
Console.WriteLine(response);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
Console.ReadLine(); // Keeps the host from disposing immediately
}
}
Run Code Online (Sandbox Code Playgroud)
这是启动配置,非常基本的东西:
public class Startup
{
// This code configures Web API contained in the class Startup, which is additionally specified as the type parameter in WebApplication.Start
public …Run Code Online (Sandbox Code Playgroud) 我正在考虑自我托管我的WCF服务,而不是使用IIS.对我来说一个很大的问题是我是否需要像IIS那样实例化多个服务主机,或者一个就足够了.
除了安全原因,除了隔离外,多个服务主机是否会提供任何好处?
一个servicehost可以同时在一个端点上提供多个连接吗?
我最初几次尝试创建自托管服务.尝试创建一些接受查询字符串并返回一些文本但有一些问题的东西:
所有文档都讨论了如果在配置文件中找不到端点,则会自动为每个基址创建端点.这对我来说似乎不是这样,我得到"服务没有应用程序端点......"的例外情况.手动指定基本端点如下所示似乎解决了这个问题:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace TestService
{
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
string SayHello(string name);
}
public class HelloWorldService : IHelloWorldService
{
public string SayHello(string name)
{
return string.Format("Hello, {0}", name);
}
}
class Program
{
static void Main(string[] args)
{
string baseaddr = "http://localhost:8080/HelloWorldService/";
Uri baseAddress = new Uri(baseaddr);
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = …Run Code Online (Sandbox Code Playgroud)我正在编写一个需要托管多个WCF服务的应用程序.WCF的优势之一是能够通过在app.config文件中指定设置来配置服务而无需重新编译.
在自托管时,似乎没有一种开箱即用的方式来自动托管app.config文件中的服务.我发现这个问题提到了一个可能的解决方案,即在运行时动态枚举app.config中列出的服务,并为每个服务创建一个ServiceHost.
但是,我的服务,合同和托管应用程序都在不同的程序集中.这导致Type.GetType(string name)无法找到我的服务类型(返回null),因为它是在不同的程序集中定义的.
如何可靠地托管app.config文件中列出的所有服务(即,new ServiceHost(typeof(MyService))在我的自托管应用程序中没有硬编码?
注意:我的app.config是使用Visual Studio 2010中的"WCF配置编辑器"生成的.
另请注意:我的主要目标是由app.config文件驱动,因此只有一个配置点.我不想在一个单独的位置配置它.
编辑:我能够读取app.config文件(请参阅此处),但需要能够解析不同程序集中的类型.
编辑:下面的答案之一促使我尝试在app.config中指定AssemblyQualifiedName而不仅仅是基本类型名称.这能够解决Type.GetType()问题,但无论我如何获得类型,ServiceHost.Open()现在都失败了InvalidOperationException:
// Fails
string typeName = typeof(MyService).AssemblyQualifiedName;
Type myType = Type.GetType(typeName);
ServiceHost host = new ServiceHost(myType);
host.Open(); // throws InvalidOperationException
// Also fails
Type myType2 = typeof(MyService);
ServiceHost host2 = new ServiceHost(myType2);
host2.Open(); // throws InvalidOperationException
Run Code Online (Sandbox Code Playgroud)
例外细节:
Service 'SO.Example.MyService' has zero application (non-infrastructure) endpoints. This might be because no configuration file …
我试图制作一个自托管的web api服务.我按照教程,它在我的本地计算机上工作正常.
localhost/api/values对预期的JSON响应很好.
现在,我有一个绑定到DNS"myserver.mycompany.com"的服务器.当我在此服务器上启动WebApi 2服务并尝试调用myserver.mycompany.com/api/values时,我找不到404页面错误.
如果我在这个服务器上本地浏览并调用localhost/api/values url它可以正常工作.
这是Startup类的代码:
using Owin;
using System.Web.Http;
namespace SelfHostedWebApi2
{
public class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
public void Configuration(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我启动服务器的方式:
using Microsoft.Owin.Hosting;
using System;
using System.Net.Http;
namespace …Run Code Online (Sandbox Code Playgroud) 我必须在Bitbucket和GitLab之间决定存储库托管(是的,它们必须是私有的).我过去曾经使用过Bitbucket,但现在我发现了GitLab,我发现让自托管存储库管理器非常有吸引力.但是,我必须证明使用其中一个(特别是在使用GitLab的情况下,因为假设其安装和配置的开销).
我们必须考虑以下因素:
那么,我应该选择自托管的回购管理器(GitLab),而不是非自托管的(Bitbucket)?