users@glassfish.java.net

Re: RESTful Web Service with Provider - Bug?

From: Mark Hansen <marklists_at_javector.com>
Date: Thu, 06 Jul 2006 17:31:44 -0400

Hi Binod. It works with the current Java EE 5 SDK binary download. But
only the Linux version. The Windows version will not deploy. See issue
#661

Binod wrote:

> The source is the same. In which version of SJSAS90, it started working?
>
> - Binod.
>
>> I just discovered that this bug seems to be fixed in SJSAS90, but not
>> in GlassFish b42. I thought they were the same! Where can I find
>> the source for SJSAS90 ??
>>
>> Thanks,
>>
>> Mark
>>
>> marklists_at_javector.com wrote:
>>
>>> I'm using GlassFish b42 / SJSAS90. Am having trouble deploying a
>>> RESTful Web Service using the Provider<Source>. I keep getting a
>>> ClassCastException thrown by the JAXWSEndpointImpl. Here is a snip
>>> of the stack trace from the server.log.
>>>
>>> java.lang.ClassCastException:
>>> com.sun.xml.ws.handler.XMLHandlerContext$SHDXMLMessageContext
>>> at
>>> com.sun.enterprise.webservice.monitoring.JAXWSEndpointImpl.processRequest(JAXWSEndpointImpl.java:50)
>>>
>>> at
>>> com.sun.xml.ws.protocol.xml.server.XMLMessageDispatcher.receive(XMLMessageDispatcher.java:110)
>>>
>>> at com.sun.xml.ws.server.Tie.handle(Tie.java:88)
>>> at
>>> com.sun.enterprise.webservice.JAXWSServlet.doPost(JAXWSServlet.java:191)
>>>
>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>> at
>>> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterCh
>>>
>>>
>>>
>>> I suspect that deploying a Provider<Source> with an
>>> HTTPBinding.HTTP_BINDING is broken. I can't find the b42 source,
>>> and the b43 source doesn't have a class case at line 50 (but it
>>> does have an instanceof) - so I'm stumped about what exactly is
>>> causing the error. It seems like maybe a problem related to
>>> casting shared XML context to SOAP vs. XML/HTTP.
>>>
>>> Here is the WebServiceProvider. Note that there must be a
>>> wsdlLocation and other attributes that should not be necessary (see
>>> IssueTracker - issue #661). But, anyway it deploys.
>>>
>>> @WebServiceProvider(serviceName="GetNewOrdersProviderPortService",
>>>
>>> portName="GetNewOrdersProviderPortServicePort",
>>>
>>> targetNamespace="http://bogus.com",
>>>
>>> wsdlLocation="WEB-INF/wsdl/bogus.wsdl")
>>>
>>> @BindingType(value=HTTPBinding.HTTP_BINDING)
>>>
>>> public class GetNewOrdersProvider implements Provider<Source> {
>>>
>>>
>>>
>>> public Source invoke(Source xml) {
>>>
>>> System.out.println("entered GetNewOrderProvider");
>>>
>>> OrderManager om = new OrderManager();
>>>
>>> try {
>>>
>>> return om.getNewOrders();
>>>
>>> } catch (Throwable t) {
>>>
>>> t.printStackTrace();
>>>
>>> throw new HTTPException(500);
>>>
>>> }
>>>
>>> }
>>>
>>>
>>> Here is the client that I'm using to test the service:
>>>
>>> public class GetNewOrdersPost {
>>>
>>>
>>>
>>> public static void main(String[] args) throws Exception {
>>>
>>> if (args.length != 1) {
>>>
>>> System.err.println
>>>
>>> ("Usage: java GetNewOrdersPost <Web Service URL>");
>>>
>>> System.exit(1);
>>>
>>> }
>>>
>>> QName svcQName = new QName("http://bogus.com",
>>> "GetNewOrdersProviderPortService");
>>>
>>> QName portQName = new QName("http://bogus.com",
>>> "GetNewOrdersProviderPortService");
>>>
>>> Service svc = Service.create(svcQName);
>>>
>>> svc.addPort(portQName, HTTPBinding.HTTP_BINDING, args[0]);
>>>
>>> Dispatch<Source> dis =
>>>
>>> svc.createDispatch(portQName, Source.class,
>>> Service.Mode.PAYLOAD);
>>>
>>> Source result = dis.invoke(new StreamSource(new
>>> StringReader("<bogus/>")));
>>>
>>> try {
>>>
>>> TransformerFactory.newInstance().newTransformer()
>>>
>>> .transform(result, new StreamResult(System.out));
>>>
>>> } catch (Exception e) {
>>>
>>> throw new IOException(e.getMessage());
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> }
>>>
>>> I have to post some XML (<bogus/>) because HTTP GET isn't
>>> supported. The output from the client is:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?><err>Internal Server Error</err>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>