I am trying to call a credit card WSDL soap service in my ASP.net web forms. I tried to add the reference of the service in my application. I got the error "Page cannot be displayed. I asked the vendor and he told me that I am using older version of .net and I should use below line of code to fix the issue
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Where should I put the above line in my code and by putting the above, will I be able to call the service. Below is the screenshot of the error message when I am trying to call the service.
There are 2 ways to add a web reference on a project in visual studio.
Using an Url. In this case you can try typing the url on any browser and adding ?wsld at the end of the url, it should to show you the contract just there (like and xml). If it works then you can use THAT url (including the ?wsdl part) as the reference.
From a local file. In this case you can download the wsdl file from the browser (changing the extension to .wsdl when you download it) using the same way as I explained before but when the browser shows you the xml then you download it with the right click. Then in the web reference URL you can reference to the local path of the file.
Related
I want to add a service reference in Visual studio 2012, I have a wsdl file and I don't have url to type in url box.
I add wsdl file path in my local computer to url box, is it ok?
when I add this wsdl file to soapUI its work and return true data in response, but when I add this wsdl file path to visualstudio it not work(return null when I call the method), its force.
in the wsdl file the service url is "http://xxx.xx.xxx.xxx/soap" (and soapUI use this url) but Visual studio don't accept this url because it doesn't have xxx.asmx postfix?
I add the wsdl file path to url box in visual studio and vs generate some files, then I create instance of that service and call web method, like this:
service1.xxxServicesClient proxy=new service1.xxxServicesClient ;
service1.RequestType request= new service1.RequestType;
request.param1="123";
service1.ResponseType response= new service1.ResponseType ;
response= proxy.methodx(request);
I build successfully that, but I get null in response when call the methodx()!
I add this wsdl file to soapUI and pass same parameter and soapUI return data(work fine)!
I do not know technology of destination web service, maybe it's a java web service.
it's ok , you can use wsdl file in local computer.
you get response in soapUI it' means good, so the destination web service work fine.
on resonse panel and request panel right click and chose validate(soapUI v5), for validate xml format. i guess that xml format invalid, try it.
visual studio return null when it can't prepare response data to xml schema (that specify in wsdl).
so, your code is ok, if format is invalid, call destination web service developer and ask to them check web service configurations and wsdl (xml) format.
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
I would like to build an app in C# that connects to an Apache AXIS web service and performs the following operations via SOAP.
Login in to the server.
POST string data to server
Receive and display server response
Here's the tough part. I do not have access to the server, nor do I know where the .JWS file is located on the server. I was able to get to the WSDL file in my web browser, so I know a "Login" operation exists as well as an operation to take in data.
I have tried accessing the web service via URL, but I keep getting this message:
Hi there, this is an AXIS service!
Perhaps there will be a form for
invoking the service here...
In summary, is there anyway I can connect to this web service when all I have is the URL of the WSDL file? Are web services accessible via URL?
Thank you
Use WCF, and generate client proxies to the web service using the svcutil.exe tool.
running svcutil.exe http://url.to/webservice?WSDL the_wsdl.wsdl /language:C# should generate proxy classes you can use in your C# project, and you'd call the service e.g. like
BasicHttpBinding myBinding = new BasicHttpBinding(); //might not even need these
// 2 lines if you ran svcutil.exe directly on the web service URL
EndpointAddress myEndpoint = new EndpointAddress("http://url.to/webservice");
TestClient client = new TestClient(myBinding,myEndpoint); //the generated classes
// svcutil.exe created
client.SomeOperation(42); // call an SomeOperation of the web service
Thanks for everyone's help. Looking back on this question, I can see how severely confused I was. Here is the solution I followed.
Assuming you know the URL of the WSDL file of the service you wish to connect to then just do the following.
Boot up Visual Studio
On the top toolbar navigate to Data -> Add New Data Source then choose Service in the new dialog
In the address bar, enter the URL of the wsdl file (EXAMPLE: http://server.com/services/displayName?wsdl)
Near the bottom of the dialog, change the namespace to something relevant to the project (EXAMPLE: sampleService)
Now Visual Studio should compile the client proxies for you that you can use to access the web services on your server. To access one of the services, all you need to do is create a new object from the class.
//Example
sampleService.ClassName test = new sampleService.ClassName();
test.displayName("Jack");
See http://msdn.microsoft.com/en-us/library/bb552364.aspx for a starting point
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.
Okay, simple situation: I'm writing a simple console application which connects to a SOAP web service. I've imported a SOAP Service reference and as a result, my application has a default endpoint build into it's app.config file.
The web service, however, can run on multiple servers and the URL to the proper web service is passed through the commandline parameters of my application. I can read the URL, but how do I connect the web service to this custom URL?
(It should be very simple, in my opinion. It's something I'm overlooking.)
Is this using an auto-generated class deriving from SoapHttpClientProtocol? If so, just set the Url property when you create an instance of the class.
Well, .NET can provide some very useless error messages sometimes. In IIS, the service was configured to AutoDetect cookieless mode. As a result, I had to append "?AspxAutoDetectCookieSupport=1" to the URL. Although that would fix the problem, it was just easier to go to the IIS console, open the properties of the service, go to the ASP.NET tab page, click the "Edit configuration" button, to to "State Management" in the newly popped up screen and change "Cookieless mode" into something other than "AutoDetect"...
Excuse me. Dumb error. Am going to hit myself on the head a few times for this. ;-)
As Jon said, you set the Url, as in:
Namespace.ClassName nwe = new Namespace.ClassName();
nwe.Url = "http://localhost/MyURL/site.asmx";