svcutil.exe - How to get WSDL
I'm working with a SOAP interface. The interface provider is having trouble getting me the full WSDL (long story). They have asked me to use svcutil.exe to generate everything I need. From what I can tell, svcutil.exe
- requires windows - I don't have a windows box available
- generates C# or VisualBasic
It'd be great if it could just spit out a WSDL. Or if there's something I can do from Linux, that would be great too.
Do I have any options from here, or do I just have to wait for the provider to get me the WSDL.
I guess the question is开发者_JAVA百科, given a URL and instructions to use svcutil.exe, how can I write code to use a SOAP service only using Linux?
If using linux you could save it via curl
curl url > service.wsdl
so to get a weatherForcast WSDL
curl http://www.webservicex.net/WeatherForecast.asmx?WSDL > weatherForcast.wsdl
@grantk has already demonstrated the easiest method: if you know where the WSDL is hosted, you can simply fetch the document using your tool of choice.
But as you asked specifically about using SVCUtil: you could find a windows box, use SVCUtil to fetch the WSDL, and then return to your linux (and Java?) stack and generate client proxies from that WSDL to call the service using your web service framework of choice.
If the target service supports WS-MetadataExchange or XML Web Service Discovery, SVCUtil will locate and download the WSDL for you: see this HowTo on Microsoft's MSDN web site.
Using the weather forecast service example that @grantk used, you can ask SVCUtil to query the service and download metadata as follows:
svcutil /t:metadata http://www.webservicex.net/WeatherForecast.asmx
(I'm sure there are similar tools to do this using WS-MetadataExchange in the linux world, but my experience is with SVCUtil.)
精彩评论