Winter
Winter

Reputation: 1916

Create a SOAP web service with jax-ws using a xml schema

I am trying to create a soap web service for a server using jax-ws following this xml schema:

   <?xml version="1.0" encoding="UTF-8"?>
   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:element name="OfeliaDataEx">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Header"/>
        <xs:element ref="User"/>
        <xs:element ref="Data"/>
      </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="Header">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="State"/>
        <xs:element ref="TypeReq"/>
      </xs:sequence>
     </xs:complexType>
     </xs:element>
     <xs:element name="State" type="xs:string"/>
     <xs:element name="TypeReq" type="xs:string"/>
     <xs:element name="User">
     <xs:complexType>
      <xs:sequence>
        <xs:element ref="JabberID"/>
        <xs:element ref="OpenID"/>
        <xs:element ref="OauthToken"/>
      </xs:sequence>
    </xs:complexType>
     </xs:element>
     <xs:element name="JabberID" type="xs:string"/>
    <xs:element name="OpenID" type="xs:anyURI"/>
    <xs:element name="OauthToken">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AuthToken"/>
        <xs:element ref="TokenSecret"/>
        <xs:element ref="ExpireDate"/>
      </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="AuthToken" type="xs:string"/>
    <xs:element name="TokenSecret" type="xs:string"/>
    <xs:element name="ExpireDate" type="xs:string"/>
    <xs:element name="Data">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="POSI"/>
        <xs:element ref="TESTE"/>
      </xs:choice>
    </xs:complexType>
    </xs:element>
    <xs:element name="POSI">
    <xs:complexType>
      <xs:all>
        <xs:element ref="TimeStamp"/>
        <xs:element ref="RefreshInterval"/>
        <xs:element ref="Lon"/>
        <xs:element ref="Lat"/>
        <xs:element ref="Data"/>
      </xs:all>
    </xs:complexType>
    </xs:element>
    <xs:element name="RefreshInterval" nillable="true" type="xs:integer"/>
    <xs:element name="Lon" nillable="true" type="xs:float"/>
    <xs:element name="Lat" nillable="true" type="xs:float"/>
    <xs:element name="TESTE">
    <xs:complexType>
      <xs:all>
        <xs:element ref="TimeStamp"/>
        <xs:element ref="cenas"/>
      </xs:all>
     </xs:complexType>
     </xs:element>
     <xs:element name="cenas" nillable="true" type="xs:float"/>
     <xs:element name="TimeStamp" type="xs:string"/>
   </xs:schema>

My first try was follow a POJO model how ever i did not have any success. I couldnt reproduce the <xs:choice minOccurs="0" maxOccurs="unbounded">. So i am here to ask for an idea to create a soap web service that follows this schema.

best regards,

Upvotes: 0

Views: 664

Answers (1)

Korgen
Korgen

Reputation: 5399

Why don't you use the xjc tool which comes with your JDK and creates the required jax-b artifacts from a xsd...

something like this will create the classes in the 'generated' subfolder of the current directory:

xjc /the/path/to/my/xsdfile.xsd

Also look here: http://docs.oracle.com/javase/6/docs/technotes/tools/share/xjc.html

Upvotes: 3

Related Questions