users@jaxb.java.net

xjc: strange "holder" type on generated code

From: Alejandro Escalante Medina <alex.escalante_at_gmail.com>
Date: Mon, 13 Apr 2009 18:09:16 -0700

Guys, you have been very helpful before, and I really appreciate it. I am
close to my goal of having a WS-I Notification consumer but I still have an
issue which doesn't let me advance...

According to the my understanding of the schema I am working on, and to the
users manual from OASIS, a notification message looks like the following:

<wsnt:Notify>
  <wsnt:NotificationMessage>
    <wsnt:SubscriptionReference>
      wsa:EndpointReferenceType
    </wsnt:SubscriptionReference> ?
    <wsnt:Topic Dialect="xsd:anyURI">
      {any} ?
    </wsnt:Topic>?
    <wsnt:ProducerReference>
      wsa:EndpointReferenceType
    </wsnt:ProducerReference> ?
    <wsnt:Message>
      {any}
    </wsnt:Message>
  </wsnt:NotificationMessage> +
  {any} *
</wsnt:Notify>

So, right away from a <Notify> element, comes a sequence of
<NotificationMessage>. However, the generated types coming from xjc expect
an xml instance with a bit of a difference. This is the sample request
generated by SoapUI:

  <ws:Notify>
         <!--Optional:-->
         <arg0>
            <!--1 or more repetitions:-->
            <b:NotificationMessage>

Please take a look at the <arg0> element there. The question is... why??? If
I remove the <arg0> element then I wiill get (of course) a null pointer
reference when trying to get the enclosed <NotificationMessage> list.

Here are the relevant fragments for the schema:

<!-- ================== Message Helper Types ===================== -->
  <xsd:complexType name="NotificationMessageHolderType" >
    <xsd:sequence>
      <xsd:element ref="wsnt:SubscriptionReference"
                   minOccurs="0" maxOccurs="1" />
      <xsd:element ref="wsnt:Topic"
                   minOccurs="0" maxOccurs="1" />
      <xsd:element ref="wsnt:ProducerReference"
                   minOccurs="0" maxOccurs="1" />
      <xsd:element name="Message">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:any namespace="##any" processContents="lax"
                     minOccurs="1" maxOccurs="1"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="NotificationMessage"
               type="wsnt:NotificationMessageHolderType"/>

<!-- ========== Message Types for NotificationConsumer =========== -->
  <xsd:element name="Notify" >
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="wsnt:NotificationMessage"
                     minOccurs="1" maxOccurs="unbounded" />
        <xsd:any namespace="##other" processContents="lax"
                 minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

Thanks again for your help...

Alejandro Escalante Medina
Visita mi página personal en http://weblocked.blogsome.com/