How to convert .xsd file to wsdl

wsdlxsd

I have .xsd file i need to convert it into wsdl,how would i do so?and is this conversion the right approach. I have request and response data in same .xsd file

Best Answer

You can not do that so easily. Usually, the xsd defines the structure (type) of the input and output messages. The wsdl used the xsd to define the operations that will be exposed by the service. An operation has usually a name and a pair of input and output messages.

I don't see how a tool could "reconstruct" the operations out of only the xsd only, except if it uses naming convention. E.g. messages requestDoIt and responseDoIt --> operation DoIt. If the xsd already contains the operations (which would be unusual) that could be ok, but it doesn't seem to be your case.

Manually creating the wsdl shouldn't be too long.

<types>
    <xsd:schema xmlns="..." targetNamespace="...">
        <xsd:import namespace="..." schemaLocation="MySchema.xsd"/>
    </xsd:schema>
</types>
...
 <wsdl:portType name="...">
    <wsdl:operation name="doIt">
        <wsdl:input message="tns:requestDoIt"/>
        <wsdl:output message="tns:responseDoIt"/>
    </wsdl:operation>
</wsdl:portType>

Have a look at WSDL essentials to get the general structure of the wsdl.

Or you can give a try to the tool WSDL Generator (from http://www.theprogrammerfactory.com/) whose purpose is apparently to ease this task. (Note that I never used it).

Another approach would be to generate classes out of the xsd, then use them to define the service class manually (this is the tedious part of matching types together into the corresponding operation) and then use another tool to transform the service class back into a complete wsdl. There are various tools available to convert to/from xsd and wsdl, for both Java or C#: wsgen, wsimport, xsd.exe, wsdl.exe.

Related Topic