How to extract XSD from a WSDL with multiple Schema definitions
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
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.
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.
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!
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.
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
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?