简体   繁体   中英

How can I capture the SOAP response after executing a webservice in C#? I need to manipulate it in code

It is a foreign AXIS webservice and I am using "add service reference" in VS 2010 using C#. After executing a webmethod I can see the desired string I want to access in Fiddler. However, the place in the object returned to me where that string should go reads "null".

There are a few ways to go about this.

First, you don't have to use what "Add Service Reference" returns to you. If you look at Reference.cs , you will see that the proxy/contract are code constructs you can create yourself.

If you go this route, then I would make sure you craft the classes that are used as return values yourself, applying the DataContract and DataMember attributes appropriately to serialize the result properly.

You can also check the what the IExtensibleDataObject implementation on the class that is generated by "Add Service Reference" returns. It's very possible the data you are looking for lies in there.

Finally, if neither of these works for you and you want to deal with the raw message that is returned to your client, you can define your own contracts, as specified above, set the return value to the Message class and manipulate it yourself after the call completes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM