Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB Customizations - Multiple schemas inside WSDL and schemaLocation

Tags:

wsdl

jaxb

I have a WSDL which contains 3 schemas inside it's "types" element. The schemas are not defined in external XSDs but inside the types element.

I want to customize an element inside schema number 2 and change it's name to avoid a conflict.

So in the schemaLocation how can I do that? Despite making the question I have the way to do this:

 schemaLocation="../wsdl-files/mywsdl.wsdl#types?schema2">
     ...
     <jxb:bindings node="some xpath

but I am not the one who found it but a colleague of mine who is not working with me anymore. Is there a resource where I can find the explanation for it even if I understand it? A link or a book? Somewhere where I can find also other examples.

My problem is the schemaLocation value(../wsdl-files/mywsdl.wsdl#types?schema2) not the xpath. I want to know all the possibilities to reference a schema inside a WSDL. I need a documentation for this or something.

Thank you very much

like image 684
Timmo Avatar asked Feb 28 '10 14:02

Timmo


2 Answers

The JAXB Ri v2.1 added support for [Schema Component Designators][1], which in theory allow you to reference schema components symbolically, rather than by their file location and xpath location. In principle, this is much nicer to use, but I've never used it myself.

I'm not sure how widely supported this is, however. There's very little mention of it anywhere else other than that blog entry. It does mention it was part of the proposed spec for JAXB 2.1, so if that was passed, it should be implemented by every JAXB 2.1 implementation, including Java6. It's possible, though, that it was never actually added to the spec.

like image 166
skaffman Avatar answered Oct 27 '22 02:10

skaffman


Had similar problem (five schemas in types with common names) and somehow didn't get SCD to work correctly. My solution was following:

custombinding.xml:

<jxb:bindings version="2.1" 
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <jxb:bindings schemaLocation="file:wsdlfile.wsdl" node="*/xs:schema[1]">
        <jxb:schemaBindings>
            <jxb:package  name="my.custom.package"/>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

xjc call in ant build file:

<target name="xjc_generate">
    <exec executable="xjc" >
      <arg value="-wsdl" />
      <arg value="${wsdl.base}/service/wsdlfile.wsdl" />
      <arg value="-d" />
      <arg value="${dir.src}" />
      <arg value="-b" />
      <arg value="${wsdl.base}/service/custombinding.xjb" />
    </exec>
</target>
like image 2
andro83 Avatar answered Oct 27 '22 01:10

andro83