2

I am new to Webservices and I have a question. I have a web service and a method like this,

     CompanyOpereations srv = new CompanyOperations();
           srv.getCustomerInfo(input);

I want to get and response.write the soap request and response of getCustomerInfo method.

can someone help me?? I have seen this but insted of logging into the file i need to print it on the screen, Getting RAW Soap Data from a Web Reference Client running in ASP.net

I have even seen this but was not sure how to call this, WriteOutput method from my client can some one please help me?? http://msdn.microsoft.com/en-us/library/ms972353.aspx

Thanks in advance.

If my question is not clear please let me know!!

This is not for debugging.. its for printing it as the output of the method so that some one else can use the XML somewhere else.

Thanks!

Community
  • 1
  • 1
helpme
  • 570
  • 1
  • 7
  • 26
  • is it for debug proposed only? You can simply use [Fiddler](http://fiddler2.com/fiddler2/) – balexandre Apr 26 '12 at 18:28
  • NO this is not for debugging.. its for printing it as the output of the method so that some one else can use the XML! – helpme Apr 26 '12 at 18:29

3 Answers3

2

I would probably use a SOAP interception extension and they just write everything to a log:

ASP.NET allows a SOAP-related infrastructure to be built by means of an extensibility mechanism. The ASP.NET SOAP extension architecture revolves around an extension that can inspect or modify a message at specific stages in message processing on either the client or the server.

the MSDN docs have a good full example...


ADDED: I couldn't implement the answer above so I went rogue.

add this to your web.config file:

<configuration>

  <system.diagnostics>
    <trace autoflush="true" useGlobalLock="false"/>
    <sources>
      <source name="System.Net">
        <listeners>
          <add name="traceFile"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="traceFile"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="App_Data/trace.log"
           traceOutputOptions="None">
      </add>
    </sharedListeners>
    <switches>
      <add name="System.Net" value="Verbose"/>
    </switches>
  </system.diagnostics>

</configuration>

This will output a log file in App_Data/trace.log that will be like this one.

Just parse that file or use it as is...

I didn't find any other way as there are no methods on the ServiceClient to show such information.

I have also set up a small Weather Service Project so you can have a look at it and see the log file being created

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
balexandre
  • 73,608
  • 45
  • 233
  • 342
  • can please tell me how to call this methods?? i mean how should i start after calling my method??i mean after this CompanyOpereations srv = new CompanyOperations(); srv.getCustomerInfo(input); – helpme Apr 26 '12 at 18:57
  • add a simple project and how to set up the service log – balexandre Apr 26 '12 at 20:36
  • thanks for you help @balexandre this saved me hours and hours :) – zanona Jan 08 '14 at 19:14
0

Although this utility is from the stone age, it did the job quite well when I was using it: SOAP Toolkit 3.0. I guess they added more sophisticated methods since then, but you should give it a try first.

Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
  • Thanks for the reply.. Do u have an example which i can see?? – helpme Apr 26 '12 at 18:54
  • Once you start it, it is supposed to act as a proxy between your application and the web service. Basically, you have to direct your application to another port, let's say 8080, and then let the proxy forward them to port 80, but this depends on the specific implementation that you are using. I also know that Microsoft changed the SOAP wrappers a lot since .NET 2.0... I'm sorry I can't be of more help. – Mihai Todor Apr 26 '12 at 23:21
0

The best way i could solve this issue is serialize my object as i was returning a object :)

helpme
  • 570
  • 1
  • 7
  • 26