dev@jax-ws.java.net

Re: Dispatch with JAXBContext Problem

From: <mark_at_javector.com>
Date: Wed, 04 Jan 2006 13:03:04 -0700

Kathy,

Thanks for the response. Since this seems like a bug/spec issue, I'm keeping
the thread here. If you think it should be on "user" - go ahead and reply on
that list.

I've read the JAX-WS PFD and I don't see where this issues is
discussed. Could
you provide a page or section reference?

In any event, I don't think it makes sense to not allow the JAXB
binding in this
case. I think its common for RESTful web services to have a null XML request
payload. Often, the invocation parameters are passed as query strings. The
response is XML. This is how the Amazon REST interface works - any many
others.

So, you don't want the JAX-WS implementation to force you to work with Source
whenever you are going an HTTP GET. You would want to have a JAXB binding on
the response. Otherwise, you are dealing with a StreamSource response
and then
you have to unmarshal it into your JAXB object - not very elegant.

-- Mark


Quoting Kathy Walsh <Kathleen.Walsh_at_Sun.COM>:

> mark,
>
> I looked at the JAX-WS Public Final Draft which you can find at www.jcp.org
> and the spec seems to indicate that only the Source object is allowed
> to have a null
> value when used with an HTTP GET. Given this, a Source would be expected.
>
> Since this isn't stated in the JAXB object case(invocation parameter
> can be null)
> the implementation did not implement this. In this case, the error
> could have
> been found before the GET reguest was invoked.
> Please enter a bug for this at java.net-
>
> Thanks so much for using JAX-WS 2.0.
> Kathy
>
>
>
> mark_at_javector.com wrote:
>
>> I'm using the JAX-WS version in Glassfish (built yesterday from
>> source). Even
>> though I create the Dispatch with a JAXBContext, it is returning a
>> StreamSource. Is this the intended behavior when doing an HTTP "GET"?
>>
>> Here is code:
>>
>> JAXBContext jc =
>> JAXBContext.newInstance("com.example.oms:com.example.css");
>> // Get the new orders
>> Service svc = Service.create(svcQName);
>> svc.addPort(orderQName, HTTPBinding.HTTP_BINDING, newOrdersUrl);
>> Dispatch<Object> getOrdersDispatch =
>> svc.createDispatch(orderQName, jc, Service.Mode.PAYLOAD);
>> Map<String, Object> requestContext =
>> getOrdersDispatch.getRequestContext();
>> requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "GET");
>> JAXBElement<OrdersType> newOrdersElt =
>> (JAXBElement<OrdersType>) getOrdersDispatch.invoke(null);
>>
>> Here is run time error:
>>
>> [java] Exception in thread "main" java.lang.ClassCastException:
>> javax.xml.transform.stream.StreamSource
>> [java] at
>> samples.OrderToCustHistJAXB.main(OrderToCustHistJAXB.java:45)
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
>> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>
>