Java Reference
In-Depth Information
This Jersey client tests the POST, GET, and DELETE methods using XML representa-
tions.
All of these HTTP status codes indicate success: 201 for POST, 200 for GET, and
204 for DELETE. For details \about the meanings of HTTP status codes, see
ht-
The
CustomerClientJSON
class is similar to
CustomerClientXML
but it uses
JSON representations to test the web service. In the
CustomerClientJSON
class
“
application/xml
” is replaced by “
application/json
”, and
Medi-
aType.APPLICATION_XML
is replaced by
MediaType.APPLICATION_JSON
.
Modifying the Example to Generate Entity Classes from an Existing Schema
This section describes how you can modify the
customer
example if you provide an
XML schema definition file for your entities instead of providing Java classes. In this case
JAXB generates the equivalent Java entity classes from the schema definition.
For the
customer
example you provide the following
.xsd
file:
<?xml version="1.0"?>
<xs:schema targetNamespace="http://xml.customer"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDe-
fault="qualified"
xmlns:ora="http://xml.customer">
<xs:element name="customer" type="ora:Customer"/>
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="number" type="xs:int"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Customer">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="address" type="ora:Address"/>