Reputation: 2217
I'm writing UI to test an asmx web service. Server and client are .NET. Client proxy has been generated using wsdl.exe.
I would like to intercept and store a string representation of outgoing and incoming SOAP messages generated as a result of calling methods on the web proxy, so I can add a feature to the UI which will show the message just sent/received.
I dimly recall there are two pairs of extension points where code can can be added to intecept the message but I cannot remember how this was done. I think the examples I have in mind involved compressing some part of the message on the client and the reverse on the server, even though in my scenario, I want to store rather than alter the message.
Any hints and help gratefully received.
(I've partially implemented a SoapExtension. I don't understand how the ChainStream method works, and I'm not sure how to notify a listener that a soap message has been trapped (since I'm not in control of instantiating the soap extension).'
Upvotes: 2
Views: 7168
Reputation: 6966
Another way to capture the XML is sent through the Wireshark application. It intercepts the communication network card.
In my case, I called a service that had as part of his address to string PIOSOS. I used the Find Packet window and searched.
Then located the XML.
See the picture.
(I know ... it's not a programmatic way, but it has its value. Lol)
Upvotes: 1
Reputation: 161783
You'd really be better off using WCF as your client technology. You could then simply use WCF message-level tracing to log the incoming and outgoing messages. This is done simply through configuration.
There's no reason you have to use an ASMX client just because you are using an ASMX service.
Upvotes: 0
Reputation: 3781
You're on the right track with SoapExtension. Did you see the documentation and example here? http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension.aspx
The idea with ChainStream is you get passed the network stream that the request would be written to, and you have the option of returning a different stream. So if you want to save a copy of the request, return a MemoryStream, which the web services client will write the request into, and then in the ProcessMessage call you can copy the data out of there and pass it to your UI.
Upvotes: 1
Reputation: 1249
I would suggest 2 tricks :
If you need more info about these tricks, just let me know.
Upvotes: 0