Creating XML facade from WSDL

It is possible to include the definitions of schema elements into WSDL. To overcome the extraction of XML schema content from the WSDL document, we would rather take the WSDL document and create XML facade for it. This recipe explains how to create XML facade out of the WSDL document.

Getting ready

To complete the recipe, we need the WSDL document with the XML schema definition. Luckily, we already have one automatically generated WSDL document, which we received during the Banking_BPEL project creation.

We will amend the already created project, so it is recommended to complete the Generating XML facade using ANT recipe before continuing with this recipe.

How to do it...

Here are the steps involved in creating XML façade from WSDL:

  1. Open the ANT configuration file (build.xml) in JDeveloper.
  2. We first define the property which identifies the location of the WSDL document:
    <property name="wsdl_file" location="../Banking_BPEL/Derivative_Cashflow.wsdl"/>
  3. Continue with the definition of a new target inside the ANT configuration file in order to generate Java classes from the WSDL document:
    <target name="xjc_wsdl">
      <delete dir="src/org"/>
      <mkdir dir="src/org"/> 
      <echo message="Compiling the schema..." />
      <exec executable="xjc">
        <arg value="-wsdl"/>
        <arg value="${schema_file}"/>
        <arg value="-d"/>
        <arg value="${dest_dir}"/>
        <arg value="-p"/>
        <arg value="${package}"/>     
      </exec>
    </target>
  4. From the configuration point of view, this step completes the recipe.
  5. To run the newly defined ANT task, we select the build.xml file in the Projects pane. Then, we select the xjc_wsdl task in the Structure pane of JDeveloper, right-click on it, and select Run Target "xjc_wsdl":
    How to do it...

How it works...

The generation of Java representation classes from WSDL content works similar to the generation of Java classes from XSD content. Only the source of the XML input content is different from the xjc utility.

In case we execute the ANT task with the wrong XML or WSDL content, we receive a kind notification from the xjc utility. For example, if we run the utility xjc with the parameter –xmlschema over the WSDL document, we get a warning that we should use different parameters for generating XML façade from WSDL.

Note

Note that generation of Java classes from the WSDL document via JAXB is only available through ANT task definition or the xjc utility. If we try the same procedure with JDeveloper, an error is reported.

See also

Now that the Java presentation of XML content is created, it is time to create a JAR (Java Archive) package for the BPEL process and provide documentation for our XML facade. The mentioned two tasks are covered in the following two corresponding recipes: Packaging XML facade into JAR and Generating Java documents for XML facade.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset