Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
package com.example.customerservice;

@XmlAccessorType( XmlAccessType.FIELD )
public class Customer {
     String name;
     String\[\] address;
     int numOrders;
     double revenue;
     BigDecimal test;
     Date birthDate;
     CustomerType type;
}

The sample class Customer gives a nice overview which primitive datatypes can be used. Additionally you can create arrays of primitive or class datatypes in this way. The complete example also contains an enumeration definition to show this is possible. I think this code is quite near the DSL I would imagine to describe my services.

...

Code Block
java
java
package com.example.customerservice;

public enum CustomerType {
     PRIVATE, BUSINESS
}

NoSuchCustomerException

...

Code Block
xml
xml
<xs:complexType name="customer">
&nbsp;    <xs:sequence>
&nbsp;&nbsp;&nbsp;        <xs:element minOccurs="0" name="name" type="xs:string"/>
&nbsp;&nbsp;&nbsp;        <xs:element maxOccurs="unbounded" minOccurs="0" name="address" nillable="true" type="xs:string"/>
&nbsp;&nbsp;&nbsp;        <xs:element name="numOrders" type="xs:int"/>
&nbsp;&nbsp;&nbsp;        <xs:element name="revenue" type="xs:double"/>
&nbsp;&nbsp;&nbsp;        <xs:element minOccurs="0" name="test" type="xs:decimal"/>
&nbsp;&nbsp;&nbsp;        <xs:element minOccurs="0" name="birthDate" type="xs:dateTime"/>
&nbsp;&nbsp;&nbsp;        <xs:element minOccurs="0" name="type" type="tns:customerType"/>
&nbsp;    </xs:sequence>
</xs:complexType>

...

Code Block
xml
xml
<xs:simpleType name="customerType">
&nbsp;    <xs:restriction base="xs:string">
&nbsp;&nbsp;&nbsp;        <xs:enumeration value="PRIVATE"/>
&nbsp;&nbsp;&nbsp;        <xs:enumeration value="BUSINESS"/>
&nbsp;    </xs:restriction>
</xs:simpleType>

...

Code Block
xml
xml
<xs:element name="NoSuchCustomer" type="tns:NoSuchCustomer"/>
    <xs:complexType name="NoSuchCustomer">
        <xs:sequence>
            <xs:element name="customerName" nillable="true" type="xs:string"/>
        </xs:sequence>
 </xs:complexType>
 <wsdl:message name="NoSuchCustomerException">
    <wsdl:part name="NoSuchCustomerException" element="tns:NoSuchCustomer">
    </wsdl:part>
  </wsdl:message>

The wsdl defines a SOAP/HTTP binding by default but can also be used to build services based on JMS as I will show in my next post.

...