Java Integration
Transform Anything with Java
Creating an XSD from WSDL
1. Launch the Windows text editor by clicking the "Start" menu in the lower left corner of the desktop followed by "Run..." Enter "notepad" in the text field, and then click "OK."
2. Choose "File" followed by "Open" from the "Notepad" menu bar. Navigate to the location of your WSDL file, highlight the file with your mouse and click "OK" to open.
3. Search the document by clicking "Edit" followed by "Find" to identify the first occurrence of the XML tag "<wsdl:types>." This marks the beginning of the XSD portion of the WSDL file.
4. Search again to locate the closing XML tag "</wsdl:types>." This marks the end of the XSD portion of the WSDL file. By clicking on <wsdl:types> while holding the "Shift" key, you may use the arrow keys to select all of the text between the beginning and ending XML tag.
5. Copy the selected portion of the document beginning with "<wsdl:types>" and the closing tag "</wsdl:types>" inclusive of the "wsdl:types" XML nodes by clicking "Edit" followed by "Copy" from the "Notepad" menu.
6. Click "File" followed by "New" to create a new file.
7. Paste the XSD portion of the document from Step 4 into the new file by clicking "Edit" followed by "Paste" from the "Notepad" menu.
8. Save the new file by clicking "File" followed by "Save as..." from the menu. The new file is now a candidate for sharing with fellow Web service authors who are required to validate against the XSD schema extracted from the WSDL.
Below example will take the wsdl file from http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL to convert to XSD for one operation
I took a generic XSD FIle as below.
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/TestSOA/SOATest/BPELProcess1"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="input" type="string"/>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
I took the below pieces from the WSDL
<s:element name="GetCityWeatherByZIP">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ZIP" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="WeatherReturn">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Success" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="ResponseText" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="WeatherStationCity" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="WeatherID" type="s:short" />
<s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Temperature" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="RelativeHumidity" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Wind" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Pressure" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Visibility" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="WindChill" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Remarks" type="s:string" />
</s:sequence>
</s:complexType>
I wil now fit the conntent from the WSDL to the XSD
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/TestSOA/SOATest/BPELProcess1"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getWeatherZIP">
<complexType>
<sequence>
<element minOccurs="0" maxOccurs="1" name="ZIP" type="string" />
</sequence>
</complexType>
</element>
<element name="getWeatherZIPResponse">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="Success" type="boolean" />
<element minOccurs="0" maxOccurs="1" name="ResponseText" type="string" />
<element minOccurs="0" maxOccurs="1" name="State" type="string" />
<element minOccurs="0" maxOccurs="1" name="City" type="string" />
<element minOccurs="0" maxOccurs="1" name="WeatherStationCity" type="string" />
<element minOccurs="1" maxOccurs="1" name="WeatherID" type="short" />
<element minOccurs="0" maxOccurs="1" name="Description" type="string" />
<element minOccurs="0" maxOccurs="1" name="Temperature" type="string" />
<element minOccurs="0" maxOccurs="1" name="RelativeHumidity" type="string" />
<element minOccurs="0" maxOccurs="1" name="Wind" type="string" />
<element minOccurs="0" maxOccurs="1" name="Pressure" type="string" />
<element minOccurs="0" maxOccurs="1" name="Visibility" type="string" />
<element minOccurs="0" maxOccurs="1" name="WindChill" type="string" />
<element minOccurs="0" maxOccurs="1" name="Remarks" type="string" />
</sequence>
</complexType>
</element>
</schema>
Our XSD File is ready. All I did is moved the complex types to the XSD and removed s:xx whatever.