Solved

WCF Service call SOAP request

Posted on 2016-07-22
15
77 Views
Last Modified: 2016-08-31
I built a WCF Service that uses custom username and password authentication and I am testing it from the client app with the following code:

    using (ServiceReferenceClient.TestServiceClient tc = new ServiceReferenceClient.TestServiceClient())
    {
    	tc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        tc.ClientCredentials.UserName.UserName = "User1";
        tc.ClientCredentials.UserName.Password = "Pwd1";
        tc.ServiceMethod(param1, param2, param3);
    }

Open in new window


It works fine but I need to see the actual SOAP request sent to the WCF service and response. How can I do that from my client?
0
Comment
Question by:YZlat
  • 6
  • 6
  • 2
15 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 41725484
Run Fiddler while you send requests. It will show you the HTTP traffic, including the SOAP.
0
 
LVL 35

Author Comment

by:YZlat
ID: 41727778
That's the thing, my client app does not make http requests so it does not show up in fiddler
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 41727916
What do you mean your client does not make the requests? If this is an SSL-secured service, then you'll have to enable Fiddler's SSL interception, which will require installing a self-signed cert that Fiddler uses to decrypt traffic. (Basically, Fiddler performs a man-in-the middle "attack" allowing you to see the SSL-encrypted data.)
0
 
LVL 35

Author Comment

by:YZlat
ID: 41741081
The client app is a console application in Visual studio. I open Fiddler and then run the client app and nothing shows up in fiddler
0
 
LVL 8

Expert Comment

by:Randy Peterson
ID: 41748914
Have you tried using Wireshark?  What is the endpoint of your WCF service you are consuming?  I am just curious what protocol you are using for the connection.
0
 
LVL 35

Author Comment

by:YZlat
ID: 41749081
I am using wsdl endpoint
0
 
LVL 8

Expert Comment

by:Randy Peterson
ID: 41749132
OK.  But the wsdl endpoint means you added it as a service reference in the project correct?  Look in your app.config and you will find the actual endpoint (URL).  Can you post the xml here?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Author Comment

by:YZlat
ID: 41768832
Here is what I have in Web.config file of the client:

<client>
      <endpoint address="http://localhost:xxxxx/MyService.svc" binding="wsHttpBinding"
        bindingConfiguration="wsHttpEndpoint" contract="ServiceReference1.IMyService"
        name="wsHttpEndpoint">
        <identity>
          <certificate encodedValue="xxxxxx" />
        </identity>
      </endpoint>
    </client>

Open in new window

0
 
LVL 8

Expert Comment

by:Randy Peterson
ID: 41769015
Author just responded.  Now we can try to answer the question.
0
 
LVL 8

Accepted Solution

by:
Randy Peterson earned 500 total points
ID: 41769033
So looking at your endpoint it appears that your are hosting this on IIS correct?  Also, your client is on the same server correct?   Getting loopback packets are not so simple.  So you can install the client on a different machine and then you can easily capture the packets based on ip to ip, or you can follow the instructions here to get local loopback traffic captured:  https://wiki.wireshark.org/CaptureSetup/Loopback
0
 
LVL 35

Author Comment

by:YZlat
ID: 41774667
Yes, the service is hosted on IIS server but the client is on a different server
0
 
LVL 8

Assisted Solution

by:Randy Peterson
Randy Peterson earned 500 total points
ID: 41774974
So, that makes it easier then.  Open up wireshark and do a simple filter on the other compter's ip address.  You should even be able to filter on the particular port so you only see that traffic.  Although, just an FYI, if you have security set up, your messages could be encrypted (at least the inner packet.
0
 
LVL 35

Author Comment

by:YZlat
ID: 41776401
I am not familiar with wireshark and I cannot install something that is not in approved software list due to security reasons. Is there anything else I could use?
0
 
LVL 8

Expert Comment

by:Randy Peterson
ID: 41776565
Unfortunately, that is the only one I have been using.  It is the one software I've found that really captures the packets, which is really what you are after.  As suggesting other software, I'm not familiar with others and it would most likely be in the same situation with your ability to install.  I would suggest if seeing the actual packets is a must, then try to get approval for wireshark.  You do not get to see the actual soap message in your client or service as it is all handled in the network stack.

Here is the wireshark tutorial to capture the SOAP messages:  https://victorjabur.com/2010/09/10/capturing-soap-message-through-http-traffic-web-services/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Not showing page correctly 3 31
Not showing JavaScript in the list 5 40
Entity Framework 7 33
How useful is the free version of Selenium? 3 16
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now