...
Code Block |
---|
|
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 |
---|
|
package com.example.customerservice;
public enum CustomerType {
PRIVATE, BUSINESS
}
|
NoSuchCustomerException
...
Code Block |
---|
|
<xs:complexType name="customer">
<xs:sequence>
<xs:element minOccurs="0" name="name" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="address" nillable="true" type="xs:string"/>
<xs:element name="numOrders" type="xs:int"/>
<xs:element name="revenue" type="xs:double"/>
<xs:element minOccurs="0" name="test" type="xs:decimal"/>
<xs:element minOccurs="0" name="birthDate" type="xs:dateTime"/>
<xs:element minOccurs="0" name="type" type="tns:customerType"/>
</xs:sequence>
</xs:complexType>
|
...
Code Block |
---|
|
<xs:simpleType name="customerType">
<xs:restriction base="xs:string">
<xs:enumeration value="PRIVATE"/>
<xs:enumeration value="BUSINESS"/>
</xs:restriction>
</xs:simpleType>
|
...
Code Block |
---|
|
<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.
...