XML From a Web Service Call

2020-07-06 06:55发布

Visual Studio makes calling a web service easy, trying to figure out what is going on under the covers is difficult.

How can I see the actual XML generated from my .Net app when making a call to a web service?

6条回答
Explosion°爆炸
3楼-- · 2020-07-06 07:11

The suggestion to use Fiddler was enough for me to get my IT team on board. They already had a copy of a similar program WireShark installed on the webserver.

Not being very network savvy, I initially thought I could watch for requests made from my PC to the webservice. That didn't work. Monitoring requests as they came into the webserver did give me the stucture of the http header and the soap envelope.

Thanks for all the responses.

查看更多
ゆ 、 Hurt°
4楼-- · 2020-07-06 07:14

MSDN Example code that implements a TraceExtension for SOAP; You can use as-is or modify to log in whatever you want (I used a DB and kept it not only for debugging but to archive all communication for later on).

查看更多
贼婆χ
5楼-- · 2020-07-06 07:17

Outside of Visual Studio, you can use the Fiddler tool to see exactly what is contained in requests and responses.

Inside Visual Studio, one thing you could do is write a DataSet out to a file.

myDataSet.WriteXml(filename);
查看更多
干净又极端
6楼-- · 2020-07-06 07:26

For SOAP web service calls, I've found SoapUI to be extremely helpful. It can connect to a WSDL to get the method definitions, create skeleton envelopes to invoke those methods, and you can see the full-fledged result after invocation.

查看更多
Animai°情兽
7楼-- · 2020-07-06 07:27

Here's another example of how you can do that within Visual Studio. All this does is grab the response from the web service and save it to a file you specify:

Dim url As String = "http://web.service.com/"
Dim request As WebRequest = WebRequest.Create(url)
Dim response As WebResponse = request.GetResponse()
Dim stream As Stream = response.GetResponseStream()

Dim xmlDoc As XmlDocument = New XmlDocument
xmlDoc.Load(stream)
xmlDoc.Save("C:\Temp\foo.xml")
查看更多
登录 后发表回答