WSO2 Enterprise Integrator 3 min

WSDLs in WSO2 ESB – how to publish?

Jan Timmerman
WSO2 Integration Consultant
WSO2Torial witruimte 1

Although we are publishing WSDL’s for our services at Yenlo since the beginning, I recently received a number of questions about this topic indicating that it can still be difficult to find detailed information about publishing WSDLs in WSO2 ESB.

To add an WSDL directly in the ESB using the carbon console please refer to WSO2 documentation (https://docs.wso2.com/display/ESB500/Publishing+a+WSDL)

To publish a WSDL in proxyservice when working with WSO2 Developer Studio first add the WSDL to your registry project (more: see ‘creating a registry project’) using ‘new->registry resource’ afterwards you can either create a wsdl file from scratch or choose to import.

WSDLs in WSO2 ESB - Add WSDL to registry project

Figure 1: Adding the wsdl to your registry project

Then add the wsdl to the xml configuration with the following line:

      <publishWSDL key="gov:sketch/example.wsdl">

A proxy would then look like:

<proxy name="testproxy" startOnLoad="true" trace="disable"
      transports="http https" xmlns="http://ws.apache.org/ns/synapse">

                <send />
           <outSequence />
           <faultSequence />
      <publishWSDL key="gov:sketch/example.wsdl">

Note the location, mediators are located within <target>, the wsdl declaration is located between </target> and </proxy>

Almost all wsdl’s  contain xsd references which need to be explicitly added to the publishWSDL definition. This allows for flexibility in structuring of the xsd’s without the need to change the content of the xsd. The structure of a resource is as follows: <resource key="[LOCATION IN THE REGISTRY]" location="[RESOURCE LOCATION AS DEFINED IN THE .XSD FILE]" />

Say we have xsds/v2/example.xsd reference in the wsdl file but we decided to add the file as example_v2_0.xsd to the xsds registry folder the resource reference will be:
      <resource key="gov:sketch/xsds/example_v2_0.xsd" location="xsds/v2/example.xsd" />

Note that we do not just specify the resources of the wsdl file but also all resources that the xsds reference. Say example.xsd  references a values.xsd. A WSDL specification then might look as follows:

      <publishWSDL key="gov:sketch/example.wsdl">
            <resource key="gov:sketch/xsds/example_v2_0.xsd" location="xsds/v2/example.xsd" />

<resource key="gov:sketch/xsds/child_v2_0.xsd" location="../canonicaldata/v2/values.xsd" />

That’s all!

Bonus: Creating a registry project

WSDLs in WSO2 ESB - Creating a registry project

WSDLs in WSO2 ESB - Create a registry project - select a wizard

Tip: due to the complexities of the underlying maven pom.xml files WSO2 Developer studio sometimes drops the ball when renaming files. Whenever you make an error during adding of the resource just remove is and import/add it anew.

Tip: The easiest way to change the registry path is by accessing the artifact.xml file in your registry project and changing the <path> of your xsd artifact.

If you have any questions about this blogpost contact us via the comments section of this blog. View also our WSO2 Tutorials, webinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development SupportWSO2 Operational Support and WSO2 Training Programs.

ESB Selection Guide

esb frontback
Get it now
What's on our menu