Versions Compared

Key

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

...

Wrapped vs. Unwrapped Mode

In REST style services we can only send and receive one XML element. Wrapping is the process of wrapping the XML requests/responses with the operation names to allow multiple parameters to your operation. For instance, say we had an operation "Customer findCustomer(String name, String company)". It would not be valid to create an XML POST request like this:

Code Block
xml
xml

<name>Dan</name>
<company>Acme Inc</company>

That has two root XML elements, which isn't allowed. Instead we would have to "wrap" the POST with the operation name:

Code Block
xml
xml

<findCustomers>
<name>Dan</name>
<company>Acme Inc</company>
</findCustomers>

You may be wondering why don't we always turn on wrapping? Well wrapping creates uglier XML. Take this operation for instance: Collection<Customer> getCustomers(). The resulting XML would be:

Code Block
xml
xml

<getCustomersResponse>
<Customers>
<Customer>..</Customer>
<Customer>..</Customer>
</Customers>
</getCustomersResponse>

The getCustomersResponse element is not needed and makes the response uglier. CXF allows you to chose which style you desire. In Wrapped mode you can write your service interface however you desire.

In unwrapped mode you must only receive a single input and respond with a single output. If you wish to take multiple parameters, you must combine them in an object. With the findCustomer example above, you would want to create a FindCustomer type which name and company properties.TODO