简体   繁体   中英

Consuming webservice having WSDL and XSD files

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.

eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM