How to generate service reference with only physical wsdl file
I have been creating and consuming web services for years and always have been able to use Visual Studio to create a service reference from the client. I have a third party service I need to work with and they refuse to open their security so I can see the wsdl and make the service reference. It's a public facing service so I don't see the need for that level of security but it is what it is.
I know this is a n00b question and I'm ashamed to be asking it, but how do I do create the equivalent Service Reference information in my client when all I have available to me is a physical copy of the wsdl the client emailed me? The web.config changes, the object layer over the SOAP data, etc. Just like with an automated Service Reference I just want to open a connection to the service and start using it with the defined objects.
The third party service is not WCF as far as I can tell but is SOAP. I'm using VS 2010 btw. Thanks in advance, Ken
This may be the easiest method
- Right click on the project and select "Add Service Reference..."
- In the Address: box, enter the physical path (C:\test\project....) of the downloaded/Modified wsdl.
- Hit Go
There are two ways to go about this. You can either use the IDE to generate a WSDL, or you can do it via the command line.
1. To create it via the IDE:
In the solution explorer pane, right click on the project that you would like to add the Service to:
Then, you can enter the path to your service WSDL and hit go:
2. To create it via the command line:
Open a VS 2010 Command Prompt (Programs -> Visual Studio 2010 -> Visual Studio Tools)
Then execute:
WSDL /verbose C:\path\to\wsdl
WSDL.exe will then output a .cs file for your consumption.
If you have other dependencies that you received with the file, such as xsd's, add those to the argument list:
WSDL /verbose C:\path\to\wsdl C:\path\to\some\xsd C:\path\to\some\xsd
If you need VB output, use /language:VB
in addition to the /verbose
.
Predecessors show how to import from local file but there's small chances that your WSDL will have one or more XSD referenced and you will receive error:
You will have to download all referenced XSD files, and put those into the same directory as referenced WSDL. Then you will have to manually edit WSDL, and change schemaLocation to local downloaded files.
Before
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://gate.somesite.local:8084/Shop/SomeService.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://gate.somesite.local:8084/Shop/SomeService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://gate.somesite.local:8084/Shop/SomeService.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
</xsd:schema>
</wsdl:types>
After
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="tempuri.org.xsd" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="schemas.microsoft.com.2003.10.Serialization.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="schemas.microsoft.com.2003.10.Serialization.Arrays.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
</xsd:schema>
</wsdl:types>
Beware there's posibility that those downloaded XSD files will have reference to web adresses as well.
Like this:
Before
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/DaxServiceLibrary.Messages" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/DaxServiceLibrary.Messages" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="http://gate.somesite.local:8084/Shop/DaxService.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
After
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/DaxServiceLibrary.Messages" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/DaxServiceLibrary.Messages" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="schemas.microsoft.com.2003.10.Serialization.Arrays.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />