Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF - Viewing xml request/response to a secure webservice

Tags:

c#

.net

xml

wcf

I have a WCF service application and in this app I am doing calls to a third party web service over a secure connection.

I have been trying to view the request response streams using fiddler but I have given up on it after trying more than half day applying all I could find over the internet. It has a problem with certificates eventhough I did more fiddlers certificates to trusted zone.

What is my best bet to simply see the xml requests and responses that I am making to this third party web service?

I am using generated proxy classes so I don't currently have access to the raw xml that I am sending and receiving back. I am curious if I am over complicating something which can be done much simpler. This is my development machine and I have access to pretty much everything, no restrictions.

A simple way to do this please?

EDIT:

At this moment I don't even need to use Tracing. I just need to see the serialized output of my request/response. Even if I can do this from the Visual Studio debugger or such It will help.

like image 784
kaivalya Avatar asked Mar 11 '10 17:03

kaivalya


2 Answers

Use WCF Tracing - it works very well and comes with a handy trace viewer utility.

You can set up loads of options - but at its core, you'll have to add something like this to your WCF service and client configs:

<configuration>
   <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "c:\log\Traces.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>
</configuration>

There's a variety of "trace listeners" out of the box - one writes to the output console in Visual Studio, this one here is creating XML files, or you can store stuff in a SQL Server database table - and the whole mechanism is extensible, you can write your own trace listeners, too!

Also see here: Using of WCF Trace and here WCF Tracing FAQ for more info.

like image 153
marc_s Avatar answered Oct 05 '22 15:10

marc_s


Since I was trying to read the soap messages to and from the asmx web service that is referenced to my WCF app, the solution to my problem was to create a class that inherits from System.Web.Services.Protocols.SoapExtension, register this class in the web.config so that all traffic is routed through this class and viewed.

None of this communication would show up on the WCF traces so that was not enough. However it was useful that I learned it so now I am able to see all that is going on between my wcf service app and web app..

This article nailed it for me how-to-capture-soap-envelopes-when-consuming-a-web-service

like image 34
kaivalya Avatar answered Oct 05 '22 15:10

kaivalya