Visual Studio SOAP Service References Client: see XML message - c#

I've built SOAP based client using wsdl file and it works really good. One issue that I am having now is - I need to see original SOAP format messages (requests and responses) that are being sent and received.
It there any way how I can obtain XML requests/responses?
SomeClient Client = new SomeClient();
var response = Client.SomeMethod();

If this is for debugging purposes you could configure tracing: http://msdn.microsoft.com/en-us/library/ty48b824.aspx. Or use Fiddler to capture HTTP traffic.

Related

how to get the xml representation of the SOAP request message?

I have the WSDL of a SOAP web service and I am consuming it via my MVC application.
From adding the WSDL as a web service to my Visual Studio solution it automatically creates a proxy class for me and it handles all the serialization/destabilization for me which is really awesome for a while. I have been using this proxy class to call/send my SOAP request to the web service (with pure c# code and no XML involves) and I got my response message back and everything is working great.
However, there is a need now for me to find what is the exact xml representation of the SOAP message that I am sending to the web service. How can I get/find/make this?
you can do it like this
var serxml = new System.Xml.Serialization.XmlSerializer(request.GetType());
var ms = new MemoryStream();
serxml.Serialize(ms, request);
string xml = Encoding.UTF8.GetString(ms.ToArray());
where xml is your raw SOAP

WCF Service not working due to white-space in soap envelope (Soap Request XML)

I am facing an issue while calling SOAP API and getting different responses due to single space between envelope and body i.e:
<s:Envelope><DataRequest> if I request it like this I receive empty SOAP body from server, but if I send it like this:
<s:Envelope> <DataRequest> I receive proper response from server side.
Can anyone suggest what to do in this situation? Should I ask server side dev team to do some changes? If so, what changes should be done?

Get Request and Response XML in SOAP web service

I'm making a call to a web service. The call works as expected in most cases. However, sometimes it fails and for troubleshooting, there is always a request from the developer to send them the request xml and if possible the response xml. How do I get this? I tried using fiddler but I don't know if it is because it is https, I only see some tunnel entries but not the xml sent or received. Sample of the web service code is below:
var serviceUrl = "http://190.0.0.1/ServiceLIVE/Service.asmx";
var svc = new LiveEntryService.LiveSoapClient(new BasicHttpBinding("LiveSoap"),new EndpointAddress(serviceUrl));
var ret = svc.MakeLiveEntry(0, "001001002", "002002003", 3, "New Site Data", "004", DateTime.UtcNow);
For serious testing of web services download a copy of SOAP UI today. It is relatively simple to get started with it.
You will be able to see and manipulate your requests and responses. It is really worth using this tool for testing.
Disclaimer: I dont work for SOAP UI.

ServiceStack JsonServiceClient, force traffic on the wire for localhost?

This ServiceStack client code works:
var client = new JsonServiceClient("http://localhost:32949/test");
var request = new MyRequest { ClassificationId = new ClassificationId (21300) };
var response = client.Post(request);
However, when observing the traffic in Fiddler, I see nothing. I would like to observe the traffic to get a better idea on how to build the required JSON request for other clients I have to write.
To make the above code work, I had to reference the assembly that has the service, and I am suspecting that ServiceStack is making some clever calls to avoid sending a HTTP request. Is this the case ?
Why am I not seeing any traffic in Fiddler, and how do I force it ?
HTTP traffic to localhost endpoints via the browser is shown correctly.
Edit your hosts file, located at
C:\Windows\System32\drivers\etc\hosts
and add the following entry
127.0.0.1 mymachine.com
then point your client to mymachine.com instead of localhost
I will answer my own question here - commenter #wal pointed out the problem to me:
This has nothing to do with ServiceStack, and requests actually go over the http protocol. The problem was looping back to localhost did not send the traffic through fiddler. It is actually explained on the Fiddler2 FAQ page.
The other trick is to replace your "localhost" uri with your machine name, and that should work out of the box with Fiddler.
http://machinename:port/test

how to consume php web service in c# Desktop application

how to consume php web service in c# Desktop application. I am doing this by adding web reference and through code
WebReference.TestWSDL pdl = new testingApp.WebReference.TestWSDL();
string copy = pdl.verify("testing");
but it throws the error
Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
Make sure you are sending the the appropriate soap version request that the service is expecting ie sending a soap 1.2 request to a service expecting a 1.1 request would give a similar error. Maybe run fiddler and post the messages that are sent and recieved for people to have a look at?

Categories

Resources