Dirk Declercq

Hi,

I am building a router based on the SDK sample. I have changed it in a way that a client connect to my router via a ClientViaBehavior, router is listening on this address with the ListenUri prop. The logical address specified by the client is looked up in a table from where I can find the final physical addres.

This works fine until now when I am trying to use a datagram MEP over a wsHttpBinding (no-security, no reliable session).

My contract is as follow :

[ServiceContract( Namespace = "http://egemin.com/Epia.ServiceModel.Test.Routing/2007.05.15/", SessionMode = SessionMode.NotAllowed )]

internal interface ISimplexSessionNotAllowed

{

[OperationContract( IsOneWay = true )]

void Echo( string value );

}

When I connect my client directly to the backend-svc which implements this contract it works. In this case I am chaning the ClientViaBehavior of my client to point directly to the backend-svc.

When I am going through my router I receive an exception when I am forwarding the incoming message :

System.ServiceModel.EndpointNotFoundException was unhandled by user code
Message="Could not connect to
http://localhost:53200/RoutingTest/Simplex_Service_SessionNotAllowed/service. TCP error code 10061: No connection could be made because the target machine actively refused it. "
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Egemin.Epia.ServiceModel.Routing.ISimplex.ProcessMessage(Message message)
at Egemin.Epia.ServiceModel.Routing.Router.Egemin.Epia.ServiceModel.Routing.ISimplex.ProcessMessage(Message message) in D:\ServiceModel\ServiceModel\Routing\Router.cs:line 144
at SyncInvokeProcessMessage(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

When I look at the trace when connecting directly from client to back-end svc I see the following :

<MessageLogTraceRecord>

<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">

<Method>POST</Method>

<QueryString></QueryString>

<WebHeaders>

<Connection>Keep-Alive</Connection>

<Content-Length>526</Content-Length>

<Content-Type>application/soap+xml; charset=utf-8</Content-Type>

<Expect>100-continue</Expect>

<Host>localhost:53200</Host> <====================================================================================================

</WebHeaders>

</HttpRequest>

<s:Envelope xmlnsTongue Tied="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">

<s:Header>

<a:Action s:mustUnderstand="1">http://egemin.com/Epia.ServiceModel.Test.Routing/2007.05.15/ISimplexSessionNotAllowed/Echo</a:Action>

<a:To s:mustUnderstand="1">urn:routingtest_simplex_sessionnotallowed</a:To>

</s:Header>

<s:Body>

<Echo xmlns="http://egemin.com/Epia.ServiceModel.Test.Routing/2007.05.15/">

<value>From client urn_routingtest_requestreply_sessionnotallowed (1)</value>

</Echo>

</s:Body>

</s:Envelope>

</MessageLogTraceRecord>

When I look at the trace when going through my router I see the following :

<MessageLogTraceRecord>

<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">

<Method>POST</Method>

<QueryString></QueryString>

<WebHeaders>

<Connection>Keep-Alive</Connection>

<Content-Length>526</Content-Length>

<Content-Type>application/soap+xml; charset=utf-8</Content-Type>

<Expect>100-continue</Expect>

<Host>localhost:54001</Host> <====================================================================================================

</WebHeaders>

</HttpRequest>

<s:Envelope xmlnsTongue Tied="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">

<s:Header>

<a:Action s:mustUnderstand="1">http://egemin.com/Epia.ServiceModel.Test.Routing/2007.05.15/ISimplexSessionNotAllowed/Echo</a:Action>

<a:To s:mustUnderstand="1">urn:routingtest_simplex_sessionnotallowed</a:To>

</s:Header>

<s:Body>

<Echo xmlns="http://egemin.com/Epia.ServiceModel.Test.Routing/2007.05.15/">

<value>From client urn_routingtest_requestreply_sessionnotallowed (1)</value>

</Echo>

</s:Body>

</s:Envelope>

</MessageLogTraceRecord>

What's different is the HttpRequest/WebHeaders/Host information.

Is this logical because I am sure that in the router the ChannelFactory is created with the right EndPointAddress which is {http://localhost:53200/RoutingTest/Simplex_Service_SessionNotAllowed/service}

What's strange is that I already have used a Http-binding, but then for the 'RequestReply'-MEP. In that case I have no problems

Can someone explain what is going on



Re: Windows Communication Foundation (Indigo) Router (from SDK example) problem with datagram MEP

Kenny Wolf - MSFT

Is the second trace the message from client->router or from router->service If you use the exact same setup but without IsOneWay=true then it works Can you include the code you use in the router to create the channel factory




Re: Windows Communication Foundation (Indigo) Router (from SDK example) problem with datagram MEP

Dirk Declercq

Never mind, I found the problem. Sorry for your wasted time.

The problems lies in the fact that when the router was creating his channel factory, for the connction to the backend-svc, I am looking up the type of encoding (TextMessageEncodingBindingElement or BinaryMessageEncodingBindingElement) used by the incoming message. There was a problem because I detected the wrong encoding so that the outgoing channel factory was created with a binary-encoding to the backend-svc which has a text-encoding.