You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Yoshida, Akitoshi" <ak...@sap.com> on 2004/07/29 17:58:15 UTC

XML attributes for code generated by WSDL2Java

Hi,
I tried to generate a SOAP header code that should serialize/deserialize something like: 

<f:Foo b:id="1234" time="2004-07-29T10:00:00Z"
    xmlns:f="urn:foo" xmlns:b="urn:bar">
   <child>...</child>
</f:Foo>

So far I was not able to generate a class that has a global attribute like in the above example ({urn:bar}id).

Could someone tell me how to do this?

I created two schemas: one for urn:foo and one for urn:bar, as in

file:foo.xsd
<xs:schema targetNamespace="urn:foo" xmlns:f="urn:foo" xmlns:b="urn:bar">
  <xs:import namespace="urn:bar" schemaLocation="bar.xsd"/>

  <xs:element name="Foo" type="f:Foo"/>

  <xs:complexType name="Foo">
    <xs:sequence>
      <xs:element name="child" type="xs:string"/>
    </xs:sequence>
    <xs:attribute ref="b:id"/>
    <xs:attribute name="time" type="xs:dateTime"/>
  </xs:complexType>
</xs:schema>

file:bar.xsd
<xs:schema targetNamespace="urn:bar" xmlns:b="urn:bar">
  <xs:attribute name="id" type="xs:string"/>
</xs:schema>


Then, the generated code for Foo got the time attribute right but not the id attribute.

Thanks for your help.

Regards, 
Aki