7

How to extract XSD from a WSDL with multiple Schema definitions

 1 year ago
source link: https://blogs.sap.com/2023/01/28/how-to-extract-xsd-from-a-wsdl-with-multiple-schema-definitions/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
January 28, 2023 3 minute read

How to extract XSD from a WSDL with multiple Schema definitions

0 1 102

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.

Capture-16.png

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.

Capture-17.png

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

Capture1.png

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK