自托管WCF服务的路由

自托管WCF服务的路由,wcf,asp.net-routing,Wcf,Asp.net Routing,我有一个在端口80上侦听的自托管WCF服务(第三方设备不支持在其他端口上发送)。我还有两个web站点和三个web API基础服务,它们也位于端口80上,并且一直运行良好。所有这些服务/站点都使用不同的FQDN(test-svc1.example.com、test-svc2.example.com、test-site1.example.com等)运行。需要注意的是,所有子域都指向服务器上的相同IP地址。在我尝试安装承载我的WCF服务的服务之前,所有这些都非常有效。一旦我安装了该服务,当我尝试导航到

我有一个在端口80上侦听的自托管WCF服务(第三方设备不支持在其他端口上发送)。我还有两个web站点和三个web API基础服务,它们也位于端口80上,并且一直运行良好。所有这些服务/站点都使用不同的FQDN(test-svc1.example.com、test-svc2.example.com、test-site1.example.com等)运行。需要注意的是,所有子域都指向服务器上的相同IP地址。在我尝试安装承载我的WCF服务的服务之前,所有这些都非常有效。一旦我安装了该服务,当我尝试导航到我的两个站点中的任何一个时,我会得到一个包含以下信息的页面:

您已经创建了一个服务

要测试此服务,您需要创建一个客户机并使用它调用该服务。可以使用命令行中的svcutil.exe工具,使用以下语法执行此操作:

如果我停止基于WCF的服务,那么我的网站就可以正常工作

以下是用于承载WCF服务的代码。 公共类MyService { 私有常量字符串MyServiceName=“MyService”; 私有服务主机_selfHost

    public void Start()
    {
        this._selfHost = new ServiceHost(typeof(MyWebService), new Uri(wcf.exampe.com));

        try
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            int tempValue = 0;
            this._selfHost.AddServiceEndpoint(typeof(IMyServiceContract), binding, MyServiceName);

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            this._selfHost.Description.Behaviors.Add(smb);

            this._selfHost.Open();

        }
        catch ( CommunicationException ce )
        {
            this._selfHost.Abort();
        }
    }

    public void Stop()
    {
        // Close the ServiceHostBase to shutdown the service.
        this._selfHost.Close();

    }
}
此代码由windows服务包装器调用。我需要的是此服务能够在端口80上运行,但只侦听与wcf.example.com关联的数据包

---------事件查看器信息

我在事件查看器中启用了调试和跟踪功能,以查看这是否有助于隔离问题

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
        <Provider Name="Microsoft-Windows-Application Server-Applications" Guid="{c651f5f6-1c0d-492e-8ae1-b4efd7c9d503}" /> 
        <EventID>57396</EventID> 
        <Version>0</Version> 
        <Level>3</Level> 
        <Task>0</Task> 
        <Opcode>0</Opcode> 
        <Keywords>0x2000000000010000</Keywords> 
        <TimeCreated SystemTime="2013-08-16T20:52:13.956945800Z" /> 
        <EventRecordID>99</EventRecordID> 
        <Correlation ActivityID="{1E2ADE87-F4FC-4B42-8711-DD49B2F0DB6B}" /> 
        <Execution ProcessID="1716" ThreadID="4828" ProcessorID="0" KernelTime="0" UserTime="3" /> 
        <Channel>Microsoft-Windows-Application Server-Applications/Analytic</Channel> 
        <Computer>MyComputer</Computer> 
        <Security UserID="S-1-5-18" /> 
    </System>
    <EventData>
        <Data Name="data1">System.ServiceModel 4.0.0.0</Data> 
        <Data Name="data2">System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---> System.Xml.XmlException: The body of the message cannot be read because it is empty. --- End of inner exception stack trace ---</Data> 
        <Data Name="SerializedException">
            <Exception>
                <ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                </ExceptionType>
                <Message>There is a problem with the XML that was received from the network. See inner exception for more details.
                </Message>
                <StackTrace> at System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml, Exception exception, Int32 remainingLength, Int32 remainingAllowedRecursionDepth) at System.Runtime.Diagnostics.EtwDiagnosticTrace.ExceptionToTraceString(Exception exception, Int32 maxTraceStringLength) at System.Runtime.Diagnostics.EtwDiagnosticTrace.GetSerializedPayload(Object source, TraceRecord traceRecord, Exception exception, Boolean getServiceReference) at System.Runtime.TraceCore.ThrowingException(EtwDiagnosticTrace trace, String param0, String param1, Exception exception) at System.Runtime.ExceptionTrace.TraceException[TException](TException exception, String eventSource) at System.Runtime.ExceptionTrace.AsError(Exception exception) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(IAsyncResult result) at System.Runtime.AsyncResult.SyncContinue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor, Action dequeuedCallback, HttpPipeline pipeline, AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync() at System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state) at System.ServiceModel.Channels.SharedHttpTransportManager.EnqueueContext(IAsyncResult listenerContextResult) at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult listenerContextResult) at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Net.LazyAsyncResult.Complete(IntPtr userToken) at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes) at System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
                </StackTrace>
                <ExceptionString>System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---&amp;gt; System.Xml.XmlException: The body of the message cannot be read because it is empty. --- End of inner exception stack trace ---
                </ExceptionString>
                <InnerException>
                    <Exception>
                        <ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                        </ExceptionType>
                        <Message>The body of the message cannot be read because it is empty.
                        </Message>
                        <StackTrace> at System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml, Exception exception, Int32 remainingLength, Int32 remainingAllowedRecursionDepth) at System.Runtime.Diagnostics.EtwDiagnosticTrace.GetInnerException(Exception exception, Int32 remainingLength, Int32 remainingAllowedRecursionDepth) at System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml, Exception exception, Int32 remainingLength, Int32 remainingAllowedRecursionDepth) at System.Runtime.Diagnostics.EtwDiagnosticTrace.ExceptionToTraceString(Exception exception, Int32 maxTraceStringLength) at System.Runtime.Diagnostics.EtwDiagnosticTrace.GetSerializedPayload(Object source, TraceRecord traceRecord, Exception exception, Boolean getServiceReference) at System.Runtime.TraceCore.ThrowingException(EtwDiagnosticTrace trace, String param0, String param1, Exception exception) at System.Runtime.ExceptionTrace.TraceException[TException](TException exception, String eventSource) at System.Runtime.ExceptionTrace.AsError(Exception exception) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(IAsyncResult result) at System.Runtime.AsyncResult.SyncContinue(IAsyncResult result) at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor, Action dequeuedCallback, HttpPipeline pipeline, AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state) at System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync() at System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state) at System.ServiceModel.Channels.SharedHttpTransportManager.EnqueueContext(IAsyncResult listenerContextResult) at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult listenerContextResult) at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Net.LazyAsyncResult.Complete(IntPtr userToken) at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes) at System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
                        </StackTrace>
                        <ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.
                        </ExceptionString>
                    </Exception>
                </InnerException>
            </Exception>
        </Data> 
        <Data Name="AppDomain">MyService.exe</Data> 
    </EventData>
</Event>

57396
0
3.
0
0
0x20000000000010000
99
Microsoft Windows应用程序服务器应用程序/分析
我的计算机
System.ServiceModel 4.0.0.0
System.ServiceModel.ProtocolException:从网络接收的XML有问题。有关详细信息,请参阅内部异常。-->System.XML.XmlException:无法读取消息体,因为它是空的。--内部异常堆栈跟踪结束--
System.ServiceModel.ProtocolException,System.ServiceModel,版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089
从网络接收的XML有问题。有关详细信息,请参阅内部异常。
在System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml,异常异常,Int32 remainingLength,Int32 remainingAllowedRecursionDepth)的System.Runtime.Diagnostics.EtwDiagnosticTrace.ExceptionToTraceString(异常异常异常,Int32 maxTraceStringLength)在System.Runtime.TraceCore.ThrowingException(EtwDiagnosticTrace跟踪,字符串param0,字符串param1,异常异常异常)在System.Runtime.TraceCore.ThrowingException(EtwDiagnosticTrace跟踪,字符串param0,字符串param1,异常异常异常)在System.Runtime.Exception.TraceeException[TException]的System.Runtime在System.ServiceModel.Channel.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(IAsyncResult结果)中的System.Runtime.ExceptionOnTrace.AsError(异常异常异常)在System.ServiceModel.Channel.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(IAsyncResult结果)在System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor,Action dequeuedCallback,HttpPipeline管道,AsyncCallback回调,对象状态)上的System.Runtime.AsyncResult.SyncContinue(IAsyncResult结果)在System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest上(ReplyChannel Acceptor ReplyChannel Acceptor,Action dequeuedCallback,AsyncCallback callback,Object state)位于System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync(),位于System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextExterReceivedSystem.ServiceModel.Channels.SharedHttpTransportManager.EnqueueContext(IAsyncResult listenerContextResult)System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult listenerContextResult)中的(HttpRequestContext上下文、Action acceptorCallback、AsyncCallback回调、对象状态)在System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult结果)的System.Net.LazySyncResult.Complete(IntPtr userToken)的System.Net.LazySyncResult.ProtectedInvokeCallback(对象结果,IntPtr userToken)的System.Net.LazySyncResult在System.Net.ListenarSyncResult.WaitCallback(UInt32 errorCode,UInt32 numBytes,UInt32 numBytes,UInt32 numBytes,UInt32 errorCode,UInt32 numBytes,NativeOverlapped*NativeOverlapped)的System.Net.ListenarSyncResult.IOCompletionCallback中,在System.Threading中完成了(ListenarySyncResult,UInt32 numBytes,NativeOverlapped*NativeOver(UInt32错误代码,UInt32字节,本机重叠*pOVERLAP)
System.ServiceModel.ProtocolException:从网络接收的XML有问题。有关详细信息,请参阅内部异常。-->;System.XML.XmlException:无法读取消息体,因为它是空的。--内部异常堆栈跟踪结束---
System.Xml.XmlException,System.Xml,版本=4.0.0.0,区域性=neutral,PublicKeyToken=b77a5c561934e089
无法读取邮件正文,因为它是空的。
在System.Runtime.Diagnostics.EtwDiagnosticTrace.WriteExceptionToTraceString(XmlTextWriter xml,异常异常,Int32剩余长度,Int32剩余长度允许重复出现