My application needs to talk to a web service that hasn\'t got an online WSDL definition. The developers however supplied me with a WSDL file.
With a public WSDL Vis
Using WSDL.exe didn't work for me (gave me an error about a missing type), but I was able to right-click on my project in VS and select "Add Service Reference." I entered the path to the wsdl file in the Address field and hit "Go." That seemed to be able to find all the proper types and added the classes directly to my project.
Try using WSDL.exe and then including the generated file (.cs) into your project.
Fire up the Visual Studio Command prompt (under visual studio/tools in the start menu) then type
>wsdl.exe [path To Your WSDL File]
That'll spit out a file, which you copy/move and include in your project. That file contains a class which is a proxy to your sevice, Fire up an instance of that class, and it'll have a URL property you can set on the fly, and a bunch of methods that you can call. It'll also generate classes for all/any complex objects passed across the service interface.
On the side note: if you have all of the files locally (not only wsdl file but also xsd files) you can invoke wsdl.exe in that manner:
wsdl.exe [path to your wsdl file] [paths to xsd files imported by wsdl]
That way wsdl.exe can resolve all dependecies locally and correctly generates proxy class.
Maybe it will save somebody some time - it solves "missing type" error when service is not avaliable online.
Try the WSDL To Proxy class tool shipped with the .NET Framework SDK. I've never used it before, but it certainly looks like what you need.
There's a Microsoft Doc for creating your WCF
proxy from the command line
.
You can find your local copy of wsdl.exe
in a location similar to this: C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools
(Learn more here)
In the end your Command
should look similar to this:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\wsdl.exe"
/language:CS /n:"My.Namespace" https://www.example.com/service/wsdl
save the file on your disk and then use the following as URL:
file://your_path/your_file.wsdl