3

I have a C# console program that makes a request to a SOAP service.

This interface to the SOAP message was generated with Microsoft.VSDesigner, Version 4.0.30319.42000. with these steps:

  1. Right click References
  2. Choose Add Service Reference
  3. Choose Advanced
  4. Add Web Reference
  5. Type in URL or service I am using
  6. Name the service
  7. Click Add Reference.

At that point I have code that is generated that invokes the service.

Here is the fragment that invokes the service:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.xxxxx.com/VerifyInsurance", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("CoverageResponseDocument", Namespace="http://www.xxxxx.com/CoverageVerification/")]

public CoverageResponseDocument VerifyInsurance([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.xxxxx.com/CoverageVerification/")] CoverageRequest CoverageRequest) 
{
    object[] results = this.Invoke("VerifyInsurance", new object[] {
                    CoverageRequest});
    return ((CoverageResponseDocument)(results[0]));
}

What can I change such that I can see the exact string of the SOAP message that is sent and received?

Either by changing code or by changing configuration.

I am a long time developer but new to visual studio so I would appreciate an answer that uses terminology I see on the screen.

Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
  • Hi Please let me know whether do you have access to web service code? You could also use Fiddler - https://www.telerik.com/fiddler to check request and responses! – MBB Sep 17 '18 at 08:10
  • Also is there any specific reason to use "web reference" instead of "service reference"? – MBB Sep 17 '18 at 08:37
  • I have access to the web service code. It was bootstrapped with the wsdl.exe program. I will look into using service reference. Please elaborate on how that might help. – Be Kind To New Users Sep 17 '18 at 13:14

1 Answers1

1

Hi Couple of points to note(Though I am accepting the fact I was not able to change the code to get the request and response logged, below are couple of other options which I have checked which you could try) -

  1. Get the raw request response by using Diagnostics(Tracing)

I have followed the same steps and added the Service Reference and applied the diagnostics and able to log the raw request response in the log file - you can read about tracing here-

  1. If you have access to your web service code then you can write Soap Extensions.

So SOAPExtention is

The base class for SOAP extensions for XML Web services created using ASP.NET.

The extension class provides the granular level details of handling the raw request and response. One way you can log these to trace log file for you examination. One example can be found here -

  1. The other approach is to use fiddler outside Visual Studio for monitoring the traffic both http and https

There is another thread in SO which talks about the same. Please have a look.

Getting RAW Soap Data from a Web Reference Client running in ASP.net

Below discussion is more of using the SOAP proxy. Adding web reference is old way of referencing the client proxy. If there is no reason to use web reference only then use the service reference instead of web references. You can find more details on the same in below threads.

https://stackoverflow.com/questions/2158106/web-reference-vs-service-reference?answertab=active#tab-top

MBB
  • 1,635
  • 3
  • 9
  • 19