title: RESTful WS - Jersey - client side unmarshalling issue
body: <p>I am trying to call a REST WS which I built myself.
  Below is my code on the client side.
  On the server side this call completes fine,
  I can see the arguments which I want to see
  in the debugger. The method is POST, 
  has an XML argument, returns JSON.
  I am using Java and Jersey.</p>
  
  <p>I am using this version of Jersey:
  jersey-client-1.0.3.jar
  jersey-core-1.0.3.jar
  jersey-json-1.0.3.jar
  jersey-server-1.0.3.jar</p>
  
  <p>I cannot upgrade that easily, it's not up to me.</p>
  
  <pre><code>package com.company.module.test;
  
  import java.net.URI;
  
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.UriBuilder;
  
  import com.sun.jersey.api.client.Client;
  import com.sun.jersey.api.client.WebResource;
  import com.sun.jersey.api.client.config.ClientConfig;
  import com.sun.jersey.api.client.config.DefaultClientConfig;
  import com.company.common.DateUtil;
  import com.company.module.input.AssetOperation;
  import com.company.module.input.AssetOperationData;
  
  public class MainProg002 {
  
      public static void main(String[] args) throws Exception {
          ClientConfig config = new DefaultClientConfig();
          Client client = Client.create(config);
          WebResource service = client.resource(getBaseURI());
  
          AssetOperationData data = new AssetOperationData();
          AssetOperation op1 = new AssetOperation();
          op1.setAssetID("1234");
          op1.setDate(DateUtil.getDate(2013, 12, 22));
          op1.setOperation("pause");
          AssetOperation op2 = new AssetOperation();
          op2.setAssetID("5050");
          op2.setDate(DateUtil.getDate(2013, 12, 5));
          op2.setOperation("resume");
          data.getAssetOperations().add(op1);
          data.getAssetOperations().add(op2);
  
          service.path("Asset").entity(data, MediaType.APPLICATION_XML).post(AssetOperationData.class, data);
      }
  
      private static URI getBaseURI() {
          return UriBuilder.fromUri("http://localhost:8080/module/service").build();
      }
  }
  </code></pre>
  
  <p>Seems to me the problem is then that the client cannot unmarshal some objects
  properly on the client side. Below is the exception which I get. I think
  it has something to do with element namespaces in XSD?! I have no idea
  how to tell the client to use a particular XSD. Also, I am not sure if 
  that's needed at all, because the RESTful service returns JSON in this case. 
  Also I am puzzled by the fact that the exception mentiones "input" which
  is an element from the arguments, not from the return values?!</p>
  
  <pre><code>Exception in thread "main" javax.ws.rs.WebApplicationException: javax.xml.bind.UnmarshalException
   - with linked exception:
  [javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"input"). Expected elements are &lt;{http://company.com/module/input}input&gt;]
      at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:99)
      at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:259)
      at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:220)
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:561)
      at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
      at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:499)
      at com.company.module.test.MainProg002.main(MainProg002.java:36)
  Caused by: javax.xml.bind.UnmarshalException
   - with linked exception:
  [javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"input"). Expected elements are &lt;{http://company.com/module/input}input&gt;]
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:372)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:342)
      at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.readFrom(JSONRootElementProvider.java:110)
      at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:97)
      ... 6 more
  Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"input"). Expected elements are &lt;{http://company.com/module/input}input&gt;
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253)
      at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1063)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:498)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480)
      at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
      at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:246)
      at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:180)
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:370)
      ... 9 more
  Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"input"). Expected elements are &lt;{http://company.com/module/input}input&gt;
      ... 20 more
  Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
  </code></pre>
  
  <p>I would be very thankful to any help.</p>
  
  <p>On the client side: </p>
  
  <pre><code>1 * Out-bound request
  1 &gt; POST http://localhost:8080/module/service/Asset
  1 &gt; Content-Type: application/xml
  1 &gt; 
  &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;input xmlns="http://company.com/module/input"&gt;&lt;item&gt;&lt;assetID&gt;1234&lt;/assetID&gt;&lt;date&gt;2014-01-22-05:00&lt;/date&gt;&lt;operation&gt;pause&lt;/operation&gt;&lt;/item&gt;&lt;item&gt;&lt;assetID&gt;5050&lt;/assetID&gt;&lt;date&gt;2014-01-05-05:00&lt;/date&gt;&lt;operation&gt;resume&lt;/operation&gt;&lt;/item&gt;&lt;/input&gt;
  1 &lt; 200
  1 &lt; Transfer-Encoding: chunked
  1 &lt; Content-Type: application/json
  1 &lt; Server: Apache-Coyote/1.1
  1 &lt; Date: Sat, 09 Nov 2013 20:23:22 GMT
  1 &lt; 
  {"error":"","id":"10"}
  1 * In-bound response
  </code></pre>
  
  <p>This is how my method looks like.</p>
  
  <pre><code>@POST
  @Consumes(MediaType.APPLICATION_XML)
  @Produces(MediaType.APPLICATION_JSON)
  public AssetResult manageAssets(AssetOperationData data) {
      LogProvider.logInfo(this, "BEGIN");
      LogProvider.logInfo(this, "Found POST data = " + data);
      AssetResult result = new AssetResult();
      result.setId(10);
      LogProvider.logInfo(this, "END");
      return result;
  }
  </code></pre>