c# SoapHttpClientProtocol get raw xml of request - c#

I need to invoke soap call. I add web link and enter wsdl and Visual studio generates a class derived from System.Web.Services.Protocols.SoapHttpClientProtocol.
But when i call method (f.i. CreateOrder) it throws FormatException. But call from SoapUI passes succesfully. What I need is to get raw xml request to analyse what's wrong. Can I get it?

Related

C# - Visual Studio, how to debug SoapHttpClientProtocol

I am trying to call an external web-service via some proxy code generated by Visual Studio (based on the WSDL from the service). The result object I get back is null, even though I can see that the service does actually return a SOAP message (I can see that in Fiddler).
It appears that the SOAP message is not able to be deserialized by the code generated by Visual Studio. I have read that this can be due to a mismatch between what the service's WSDL tells us what to expect, and what the service actually returns.
Is it possible to get the deserialization code to report what the problem is, throw an exception, or something, instead of just silently returning null?
Thanks.
I'm not sure about the debugging, but one approach you can try is to create a simple web service which returns the structure you're expecting. Then you can compare the output from this service with the actual service to see if you see any problems.

C# Getting Soap response from an auto generated reference.cs generated using wsdl

The SOAP service I am consuming will send back a 202 Accepted. All I want to do is capture this 202 so I can confirm that the server received the message.
I have found this:
here
So the answer states to implement a soapextension and links to msdn. I looked at the sample code, and I am having a hard time understanding what I should do. The client that was generated submits the data in the following way:
psrs.SubmitPersonSearchRequest(psrt);
and has a void return. How do I get the response from the server?
I was able to see the correct response in soapui and in fiddler.

Calling php webservice in visual studio 2010 is giving me error releated to content type

I have created one webservice call in php, it is a RESET webservice.
Now I want to call this webservice in excel 2007. So I am using Visual stdio 2010.
When I give the url in add service refrence dialog box and press go. it's give me this error.
-------error------------------------------------
There was an error downloading 'http://careernet.localhost/rep-details/report_details/retrieves'.
The request failed with HTTP status 404: Not found: Could not find the controller..
Metadata contains a reference that cannot be resolved: 'http://careernet.localhost/rep-details/report_details/retrieves'.
The remote server returned an unexpected response: (406) Not Acceptable: Unsupported request content type application/soap+xml.
The remote server returned an error: (406) Not Acceptable.
If the service is defined in the current solution, try building the solution and adding the service reference again.
I would like to tell that url is correct. my webservice call is returning data in xml format.
I tried to convert this into json but it is not working at all.
Service References don't work against REST webservices, they work against SOAP services or other services that provide a WSDL that describes the protocol in a way that Visual Studio understands.
You'll need to write your own proxy for it using the Web API/HttpClient, or you can make use of existing libraries to communicate:
RestSharp: https://stackoverflow.com/a/4970558/736079

How to hit Web Service Based on WSDL

Here is the WSDL
http://cc93161263da499cb8f0e0e0b2bcc5a9.cloudapp.net/Service1.svc?wsdl
How can I get to the GetHello service
I tried
http://cc93161263da499cb8f0e0e0b2bcc5a9.cloudapp.net/Service1.svc/GetHello
But I receive a bad request error....
Any thoughts...
Easiest would be to use VS to generate a client proxy based on the WSDL (Add a Service Reference to your project).
Regarding the error: it could be because you're not passing in an input parameter... looks like there is a blank sequence. Or that your browser is sending in accepts parameters that don't match what the server expects (soap).
See this for command line generation without VS:
http://cc93161263da499cb8f0e0e0b2bcc5a9.cloudapp.net/Service1.svc?help

.net Client consuming Axis2 Web Service

I have an .net 2.0 C# client app that has a web service reference to an Axis2 Java Webservice.
The idea is to send some xml data to the webservice, so it can be parsed and inserted into database.
The WS method accepts a single parameter of type 'xsd:anytype'.
Java web service:
public class JWS{
public Response AddData(Object inputXML) {
return Response;
}
}
C# Client:
JWS client = new JWS();
object inputXML = "<xml>some xml data</xml>";
response = client.AddData(inputXML);
There are 2 issues i am seeing when monitored using fiddler.
1) The request has an additional element '<inputXML>' added before the actual xml data.
<inputXML><xml>some xml data</xml></inputXML>
2) The xml is encoded, so '<' is appearing as "<"
I am not sure if this is how SOAP request's are generated but i would like to remove the <inputXML> tag and also, have the xml appear as is without having to replace the special characters.
Is this possible? Is it got something to do with 'Wrapping'/'UnWrapping' Types?
Also, i have used SoapUI to test the java web service and it works well. However, in the request tab, i had to manually remove the <inputXML> tag and submit for it to work correctly. Please help.
TIA
This is expected behaviour under SOAP and the inputXml variable will be decoded back to the original string when passed to your web service method.
However this may indicate a problem with your design, have you considered constructing an object to send to your web service rather than xml data? (As this object will transparently be converted to xml for the web service call anyway).
I found out that the issue is not with encoding but it was interpreted incorrectly on java side when the message was viewed in axis2. So, it is getting decoded properly. Also, the inputxml is now being handled correctly.

Categories