Маршрутизация собственной службы WCF

У меня есть собственная служба WCF, которая прослушивает порт 80 (стороннее устройство не поддерживает отправку на другие порты). У меня также есть два веб-сайта и три базовых сервиса Web API, которые также работают на порту 80 и работают хорошо. Все эти службы / сайты работают с использованием разных полных доменных имен (test-svc1.example.com, test-svc2.example.com, test-site1.example.com и т. Д.). Важно отметить, что все субдомены указывают на один и тот же IP-адрес на сервере. Все это работало замечательно, пока я не попробую и не установлю свой сервис, на котором размещается мой сервис WCF. После установки этой службы при попытке перейти на один из двух сайтов я получаю страницу со следующей информацией:

.....

Вы создали сервис.

Чтобы протестировать этот сервис, вам нужно будет создать клиент и использовать его для вызова сервиса. Это можно сделать с помощью инструмента svcutil.exe из командной строки со следующим синтаксисом:

.....

Если я остановлю свой сервис на основе WCF, мой сайт будет работать нормально.

Ниже приведен код, который используется для размещения службы WCF. открытый класс MyService {приватная константная строка MyServiceName = "MyService"; частный сервис Host _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>

----------------- Ошибка завершения

Транспорт отправил сообщение на http://x.x.x.8/data/MyService.

Обработка исключения. Сведения об исключении: System.ServiceModel.ProtocolException: существует проблема с XML, который был получен из сети. Смотрите внутреннее исключение для более подробной информации. ---> System.Xml.XmlException: тело сообщения не может быть прочитано, потому что оно пустое. --- Конец трассировки стека внутренней исключительной ситуации --- в System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue (результат IAsyncResult) в System.ServiceModel.Channels.HttpPipeline.Eesign.EnsynsRexync..SyncContinue(IAsyncResult результат) на System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor (replyChannelAcceptor акцептора, действие dequeuedCallback, HttpPipeline трубопровода, AsyncCallback обратного вызова, объект) в состояние System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(replyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, обратный вызов AsyncCallback, состояние объекта) в System.ServiceModel.Channels.HttpChannelListener1.HttpContextReceivedAsyncResult1.ProcessHttpContextAsync ()

HttpGetContext начать.

--------- Информация для зрителей

Как упоминалось ранее, все это прекрасно работает на моем тестовом компьютере при работе в Visual Studio, но не работает при запуске на моем производственном компьютере в качестве службы.

С Уважением,

Ричард О

0 ответов

Другие вопросы по тегам