How to hit Web Service Based on WSDL - c#

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

Related

How do I make a POST web request in C# (SOAP)

I have to write a code that makes a post request with the data in the body. I am not familiar with this sort of thing.
URI: https://___________________________________________________.asmx/Process
This is what I must send in the body:
Username: ___________________
Passsword: ___________________
APISignature: _________________
MessageID: (a new GUID)
Data: Some XML.
In VS 2017, right click references and choose Add Service Reference:
I will use sample calculator service at http://www.dneonline.com/calculator.asmx
Put the service URL in the box, click Go, choose a namespace, click OK:
See the Connected Services node of Solution Explorer gained these things:
Now write in code that uses the XXXClient (XXX is the name of your service) like:
Highlighted are the operations of the service, arguments are the parameters to the operations, like Add(1,2)
VS makes a client that does all the HTTP and encoding of values etc; all you do is call the client methods, the XML is sent over the wire to the server, the response is decoded and the method returns

C# service reference doesn't recognize the query parameter from url

I've added in the service reference an url like this: "https://example.com/cars?wsdl"
Everything works fine, I can access the methods from that soap and compile the project without errors.
When I call a method the endpoint address is https://example.com/cars (I've notice this with the debugger) on this page is only a fault error and every method I call it returns the fault error.
Why the service reference doesn't see the parameter "?wsdl" ?
Thanks!
Your fault message is probably coming from the service itself. The ?wsdl at the end just has information about your service. Put a try catch in the method that you're calling on the service layer.
The problem was solved by using xml request.
http://www.terminally-incoherent.com/blog/2008/05/05/send-a-https-post-request-with-c/
The error seems to be from the service itself.

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

Server returned an invalid soap fault when calling operation from class library

I am using Visual Studio 2012. I have a ASP.NET MVC 4 web app that references a class library. This class library has a service reference. The service reference I added by inserting the URL to the .wsdl file.
I have set up everything correctly. When I do a call to one of the operations then I get an error:
Server returned an invalid SOAP Fault. Please see InnerException for more details.
Then when I view the inner exception:
The data at the root level is invalid. Line 16, position 17.
I am doing everything right, I just don't know why I get this error when I do a call to one of the operations. Where do I see what is returned? I have no control over this service, I am just consuming it.
Run fiddler while making the request. http://fiddler2.com/
This will allow you to see what is actually being sent and what is actually being returned

Problem regarding consuming php web service in c# Desktop application

I am developing a c# desktop application and using a webservies which is developed in a php application when i try to consume that application. I just add web REference of that web service and try to access throught the following code
WebReference.TestWSDL pdl = new testingApp.WebReference.TestWSDL();
string copy = pdl.verify("testing");
it throws the error when i try to call the method verify. the error is
Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
and the web service link was like
http://171.139.101.12/code/index.php/webservice/wsdl
The error you are encountering is informing you that when you invoke the webservice, you are being given the WSDL (Web Service Definition Language) for the service - this is the metadata that describes the service functions, but cannot actually be used to invoke the service. Usually, you access the WSDL by appending either "?wsdl" or "wsdl" to the service URI.
There are two elements to the webservice you are attempting to consume.
The actual service exists at:
http://171.139.101.12/code/index.php/webservice
The metadata describing it, which Visual Studio via wsdl.exe used to generate a proxy, resides here:
http://171.139.101.12/code/index.php/webservice/wsdl
You need to edit the properties of the Web Reference and update the address appropriately. Alternatively, you can alter the properties of the pdl variable, and change the endpoint in code.

Categories