I have a .WSDL
file that contains the interfaces to communicate with a service.
I need to create a host that provides the functionality described in the WSDL.
This means that I have to create an Interface with a [ServiceContract]
, and possibly one or more classes with a [DataContract]
.
I thought that SvcUtil.Exe
would do this for me. The help says:
svcutil.exe can generate code for service contracts, ... from metadata documents. These metadata documents can be on disk or ...
So I run SvcUtil while in the folder with the .WSDL:
SvcUtil.exe Example.Wsdl
This gives me the following error:
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Schema with target namespace 'http://logius.nl/digipoort/koppelvlakservices/1.2/' could not be found.
XPath to Error Source:
//wsdl:definitions[@targetNamespace = 'http://logius.nl/digipoort/wus/2.0/afleverservice/1.2/'] /wsdl:portType[@name='AfleverService_V1_2']
I interpret this as that file example.wsdl
needs a schema that cannot be found.
In file Example.WSDL:
<wsdl:types>
<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import
namespace = "http://logius.nl/digipoort/koppelvlakservices/1.2/"
schemaLocation="../digipoort-koppelvlak-1.2.xsd"
/>
</xsd:schema>
</wsdl:types>
I guess this means that the file with the requested schema should be in the super-folder with filename digipoort-koppelvlak-1.2.xsd
I have a base folder that contains schema information and a subfolder that contains the .WSDL:
basefolder
digipoort-koppelvlak-1.2.xsd
basefolder\subfolder
Example.WSDL
The first line of digipoort-koppelvlak-1.2.xsd
:
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:tns ="http://logius.nl/digipoort/koppelvlakservices/1.2/"
targetNamespace = "http://logius.nl/digipoort/koppelvlakservices/1.2/"
elementFormDefault="qualified">
This seems to me the requested schema. So why can't SvcUtil find the Schema with the mentioned namespace?
The strange thing is, that the .WSDL
file seems correct, because I can create client classes for this in visual studio (menu: project / add service reference). But I don't know how to create the classes to host the service
A solution is to mention the .XSD
file in the command line:
SvcUtil.exe c:\...basefolder\digipoort-koppelvlak-1.2.xsd Example.Wsdl
Although this does not explain why the XSD is not included automatically, it generates a file with the requested [servicecontract]