Skip to Content
Technical Articles
Author's profile photo vinay mittal

How to extract XSD from a WSDL with multiple Schema definitions

Introduction

As an Integration consultant I come across scenarios where I have a complex WSDL at hand with deeply nested structures and multiple schema definitions like the one below for Business Partner Replication.

Working with WSDL’s is all good and cool until you come across a requirement where you have to extract the XSD out of the WSDL and work on that. There might be several reasons why you may need to extract the XSD out of the WSDL a few of them which I faced are below.

    • XSD needs to be shared with a third party as their system only accepts and works upon XSD’s.
    • WSDL contains too much information and as SAP CI is interfacing between the third party and SAP this information is either not needed at their end or needs to be abstracted.
    • You need to do a XML validation in SAP CI which only works on a XSD schema and does not accept a WSDL!
    • You need to edit the schema in a way to perform multimapping on it for example
      <Messages>
      <Message1>
      <WSDL’s Schema>
      </Message1>
      <Message2>
      <Schema2>
      </Message2>

 

In all of these cases working on a WSDL directly and updating it is a nightmare and so is trying to extract the schema’s manually. Sometimes the WSDL files are easily over 10000 lines which makes it impossible to do it manually without comiting any mistakes.

 

Also what if you want a schema without any namespace prefixes? Stripping all the declarations and namespaces  and also ensuring that you handle complexType definitions where the name is same for different complexType definitions s a task in itself.

For example look at the two complexType “Text” definitions below they both are taken from the same WSDL but different Schema’s

 <xsd:complexType name="Text">
    <xsd:sequence>
     <xsd:element name="BuyerTextElementID" minOccurs="0" type="TextElement"/>
     <xsd:element name="SupplierTextElementID" minOccurs="0" type="TextElement"/>
     <xsd:element name="TextElementLanguage" minOccurs="0" type="LanguageCode"/>
     <xsd:element name="TextElementText" minOccurs="0" type="TextElementText"/>
     <xsd:element name="TextElementTextFormat" minOccurs="0" type="TextElementTextFormat"/>
    </xsd:sequence>
    <xsd:attribute name="Type" type="TextType"/>
 </xsd:complexType>

And

<xsd:complexType name="Text">
    <xsd:annotation>
     <xsd:documentation xml:lang="EN">
      <ccts:RepresentationTerm>Text</ccts:RepresentationTerm>
     </xsd:documentation>
    </xsd:annotation>
    <xsd:simpleContent>
     <xsd:extension base="xsd:string">
      <xsd:attribute name="languageCode" type="LanguageCode"/>
     </xsd:extension>
    </xsd:simpleContent>
</xsd:complexType>

 

If you just copy paste all the schema nodes into a single file you will have conflicting namespace declarations, mirror duplicate types, and duplicate types with different definitions and whole lot of WSDL definitions to take care of. Working on a small WSDL is easy but when it comes to large WSDL’s  like the one’s from SAP its not an easy task.

 

Solution

I developed a solution for this very problem and have deployed it for free use on UtilityArena.

Let me demonstrate how easy it is to extract a XSD out of a complex WSDL or repair a broken WSDL(a WSDL without any schema prefixes like the ones from salesforce , these are not accepted as is by SAP CI).

 

Go to the link above and upload your WSDL or paste the WSDL content in the text area.

Click on Extract XSD and then you will have your extracted XSD ready for download.

 

And with just a few clicks you will have your XSD extracted from a WSDL in seconds.

 

 

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Piotr Radzki
      Piotr Radzki

      This is great Vinay! I have to admit I do it usually manually. Now I got nice utility from you to do it automatically. It will be also very handy when we integrate to ABAP Proxy using XI adapter and don't want to do mapping against WSDL (due to mentioned by you namespaces) but work with XSDs that are much more convenient and also handy when you want to convert from/to JSON and do validation. You made my day!

      Author's profile photo vinay mittal
      vinay mittal
      Blog Post Author

      Happy to know Piotr that this help and thank you for your kind words.

      Please share your feedback about the tool if you find any bugs in it.

       

      Regards

      Vinay

      Author's profile photo Michael Jennings
      Michael Jennings

      You can use SoapUI: http://www.soapui.org/ This is a generally handy program. Make a new project, connect to the WSDL link, then right click on the project and say "Show interface viewer". Under "Schemas" on the left you can see the XSD. SoapUI can do many things though! UPSers

       

      Author's profile photo vinay mittal
      vinay mittal
      Blog Post Author

      Hello Michael,

       

      I think you have never tried to export XSD from SOAP UI yourself. I tried to follow your steps and found that Interface viewer just shows the Schema inside the WSDL ..It does not allow to extract and merge the schema definitions from the WSDL.

       

      It has been long known that SOAP UI is useless when it comes to extracting multiple schemas into one from a WSDL. Can you add step by step procedure to extract a XSD from a WSDL with "multiple" Schema definitions for the greater good of the community?

      Author's profile photo kannan S
      kannan S

      Hi vinay mittal

      It's a really amazing blog that would help people working in WSDL to XSD scenarios. I appreciate the work!

      I just tried to explore the "utilityarena" for my wsdl to xsd requirement; unfortunately, extracted XSD was not accepted in the CPI mapping. Attached is the error snapshot. Can you kindly look into the issue and let me know how to rectify using your tool?

      Error: XSD: Type reference '#TextType' is unresolved

      Thanks!

      Kannan Selvakumar

       

       

       

       

      Author's profile photo vinay mittal
      vinay mittal
      Blog Post Author

      Hello Kannan

       

      Thanks for feedback. Feedback like this helps me rectify any bugs. Let me help you here please share the wsdl with me on linkenin. I will debug the code to see whats wrong.

       

      Its important to examine this case as this will help others also.

      Regards

      Vinay

      Author's profile photo kannan S
      kannan S

      Hi Vinay,

      Thanks much for the response. Please check "LinkedIn".

      Regards

      Kannan Selvakumar