Consuming webservice having WSDL and XSD files - c#

We've requested a company to write a webservice that we can use to get some information.They have sent us WSDL and XSD files. Could you please tell me how I can use these files to query data?
I can do it easily if I have a link to a webservice. I just provide the link and Visual Studio generates web reference for me. After that I can use that reference just like a normal class. In this case I have no link. Just above mentioned files. Thank you.

You can create a proxy (add service reference in visual studio) from a wsdl file. You can read about svcutil at http://msdn.microsoft.com/en-us/library/aa347733.aspx, but VS2010 allow you to put a wsdl file on adress when adding service reference.

VS2010 can't create a web service reference from some WSDLs. Have
to write custom wrapper for those. OR edit your WSDL in a way so
VS can consume it. For example it may be ok for you to remove web
service method references for the methods that you are not planning to
use if those references create trouble for you.
Unless you're stuck with .NET 2.0, you should not use ASMX web service technology.
You should use "Add Service Reference" and point it to the WSDL on disk. It will create a set of "proxy" classes with methods that you can call just as though it were a "normal" class.
See "How to Consume a Web Service" for a walkthrough with example.
Use WSDL.EXE utility to generate a Web Service proxy from WSDL.
e.g.
wsdl /language:CS /n:"Microsoft.SqlServer.ReportingServices2010" http://<Server
Name>/reportserver/reportservice2010.asmx?wsdl
check this for Creating and Consuming .NET Web Services in 5 Easy Steps Article and then Creating the Web Service Proxy
Ref:
WSDL and consume web service
consume non .NET webservice through WSDL file
How to use a WSDL

Related

c# SOAP web service Complex type

I am new to SOAP complex type web services. I attached down here the wsdl file.
My question is
how to consume the web service? I mean how to call and how to call the callback function.
if possible, use the below wsdl and give me an example with c#
wsdl here
[wsdl here][1]
https://drive.google.com/open?id=1cEM0h3AO6tj1aDv6Z2BGfZUxEiQe9c9O
The easiest way I know to consume a SOAP API is to create a C# project and add a service reference.
Then add the address of your website and Visual Studio will generate a proxy for your WebService.
You will be able to call it in your project (Website/ConsoleApp).
You can have a sample of how to call the client when you call the svc of your WebSite if you use WCF.
ex: http://<host>[/route]/<name of svc>.svc

WSDL2REST - is there a C# version? (convert SOAP to RESTful web service)

converting a WSDL to a REST web service, Is there a C# version of this library?
http://wsdl2rest.sourceforge.net/
I was wondering if you really need a library for this? I mean as long as you have the WSDL you can create a service using the svcutil and decorate the methods with WebInvoke and WebGet also specifying the method (POST/GET/PUT) and the UrlTemplate. The methods would also have return types and input params based on your current wsdl.
I haven't tried it but I've been reading on the issue as my current project requires me to do so when I get that stage of our development effort...
Here are some sources:
How to use a WSDL file to create a WCF service (not make a call)
"Reverse" WCF Service (Building a server from a client definition)
How to use a WSDL File to create a WCF Proxy?
and so forth...

Creating web service by existing WSDL schema

Unfortunately, I am new to web services. I have a WSDL schema, which I have to provide as a service. So how can I do this?
Can someone please tell me instructions step by step?
I'm not sure why you would want to create a web service based on an existing WSDL schema (i'm assuming you mean WSDL and not WDSL).
You could use the WSDL.exe tool that ships with the SDK to reverse engineer the WSDL file to ASMX web services (older )
You can find more details here
However it is advised to use WCF for newer projects, you can then use svcutil.exe to reverse engineer your WSDL file instead.
find a description in a question answered How to use a WSDL file to create a WCF service (not make a call)
Hope this helps

Calling PHP Webservice from C# using supplied WSDL

I've been passed a WSDL from a third party. Their web service is PHP on Apache.
I can call its methods from within XMLSpy and Validwsdl.com. But cannot get my C#/Visual Studio project to build/validate the WSDL. When I add it to my project - it shows all of the methods and seems fine but won't build.
I've tried add web ref, add service ref, I've tried command line WSDL.exe. Nothing works. Should I be having to hack at their WSDL document? Do I need extra libraries/includes?
I don't understand why it's not working.
The WSDL is :-
http://www.gesundsolutions.com/epp/application/heiq.wsdl
Any Ideas?
Have you used the "Add Web Reference" from the menu in VS?
A simple and quick tutorial that shows you what is needed for communicating with a web service from elsewhere is this post on op0.com. Check it to find out what you're possibly missing.
Yes, just the WSDL is enough if you know the location of the web service. No, you should never change the WSDL, as that is the calling convention.

How to use proxy class generated by WSDL in web service?

Disclaimer: My experience/knowledge of web services is very limited.
There is an existing web service WSDL that I have reverse engineered with wsdl.exe to create a C# proxy class.
Using Visual Studio 2008 I created a default web service template.
How do I reference the generated proxy class so that it will work in the web service?
For example -> calling http://localhost/webservice/service.asmx?WSDL will return the details from the proxy class.
First of all, you should not be using ASMX web services. Microsoft now considers them to be "legacy technology", and suggests that all new development of web service clients or services be done using WCF. Don't start off at a disadvantage.
Secondly, the normal way to make use of a WSDL is to use the "Add Web Reference" command in Visual Studio ("Add Service Reference" if you were using WCF). This generates the proxy classes for you and adds them to your project.
I'm not sure from your question that this is what you want, since you first talk about the WSDL, but then talk about a "default web service template". What do you mean to do with the "default web service template"?
Try using the svcutil.exe program (not WSDL.EXE) as follows:
svcutil YourWsdl.WSDL /language:C# /d:subdirectory
This should produce a number of files in the subdirectory. Take a look at the .cs files, one of which will contain an interface which is the service contract. That is the interface that your service must implement. Look at your "default" WCF service application and you'll see that it does the same thing - produces an interface that is implemented by the service.

Categories