tags:

views:

24

answers:

1

Hi,

I have a WCF client with a custom behavior that intercepts the SOAP request. In BeforeSendRequest in the client I get the SOAP request and pass it to another WS as parameter. The other WS posts the SOAP envelope to the real service that client wants to invoke and returns the SOAP Response back to client. So in BeforeSendRequest the intermediary service returns the real SOAP response as a string back to client.

public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
{
  string soapResponse = myotherProxy.CallService(request.ToString());
  return null;
}

How can i set the returned SOAP response (soapResponse) as the real response in the client?

Hope someone can help :)

Thank you, Adrya

+1  A: 

You could save 'soapResponse' to a member variable of the inspector and set it back in afterReceiveReply.

But why are you faking the call to the service at all? Couldn't you just call the other service And not have to do the inspector trickery?

JamesMLV
Thanks :) but how to set this SOAPEnvelope that comes as string in reply which is a Message? I have to do it this way because that's what project is... (sends messages from different clients at different services, but before sending it in myotherProxy.CallService it does some checks and only allow call if checks are OK )
Adrya
Could you make your CallService method return a SOAP Message instead? Or you could try to make the message out of the soap string. ( see http://msdn.microsoft.com/en-us/library/system.web.services.description.message(v=VS.90).aspx )
JamesMLV