Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

WCF Service call SOAP request

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?
Avatar of kaufmed
kaufmed
Flag of United States of America image

Run Fiddler while you send requests. It will show you the HTTP traffic, including the SOAP.
Avatar of YZlat

ASKER

That's the thing, my client app does not make http requests so it does not show up in fiddler
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.)
Avatar of YZlat

ASKER

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
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.
Avatar of YZlat

ASKER

I am using wsdl endpoint
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?
Avatar of YZlat

ASKER

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

Author just responded.  Now we can try to answer the question.
ASKER CERTIFIED SOLUTION
Avatar of Randy Peterson
Randy Peterson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Yes, the service is hosted on IIS server but the client is on a different server
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

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?
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/