Back Forum Reply New

JAXB quot;No adapter for endpointquot; while using JAXBElement

I have a web service that I am trying to implement using Spring and Jaxb.  I already have a handful of working services using both of these - but this particular service is giving me a hard time due to the format of the response.  In my XSD, the response is defined like this (notice that it is a single element):Code:
lt;!-- Response definition --gt;
lt;element name=quot;ServiceResponsequot; type=quot;Q1:Outcomequot;/gt;

lt;!-- Outcome definition --gt;
lt;complexType name=quot;Outcomequot;gt;
lt;sequencegt;
lt;element name=quot;ErrorCodequot;gt;
lt;simpleTypegt;
lt;restriction base=quot;stringquot;gt;
lt;maxLength value=quot;8quot;/gt;
lt;/restrictiongt;
lt;/simpleTypegt;
lt;/elementgt;
lt;element name=quot;ErrorTextquot;gt;
lt;simpleTypegt;
lt;restriction base=quot;stringquot;gt;
lt;maxLength value=quot;1000quot;/gt;
lt;/restrictiongt;
lt;/simpleTypegt;
lt;/elementgt;
lt;element name=quot;DocumentIdquot;gt;
lt;simpleTypegt;
lt;restriction base=quot;stringquot;gt;
lt;maxLength value=quot;30quot;/gt;
lt;/restrictiongt;
lt;/simpleTypegt;
lt;/elementgt;
lt;/sequencegt;
lt;/complexTypegt;
I have a service method that looks like this:Code:   @PayloadRoot( localPart = SERVICE_REQUEST, namespace = NAMESPACE )   public Outcome processFileRequest( ServiceRequest requestObject )
I end up with an exception that looks like this:

java.lang.IllegalStateException:
No adapter for endpoint [public dortman.xsd.objects.Outcome dortman.annotated.MyTestEndpoint.processFileReques  t(dortman.xsd.objects.ServiceRequest)]: Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?

After finding some related posts on the Spring forum and Stackoverflow, it seems that return objects need to either have the XmlRootElement annotation or be wrapped in a JAXBElement.  To try the first, I changed the response in the XSD to:Code:
lt;!-- Response definition --gt;
lt;element name=quot;ServiceResponsequot;gt;
lt;complexTypegt;
lt;sequencegt;
lt;element name=quot;FileSizequot; type=quot;longquot;/gt;
lt;/sequencegt;
lt;/complexTypegt;
lt;/elementgt;

That works, as JAXB then generates a ServiceResponse class which has the XmlRootElement annotation.  Unfortuantely, I don't necessarily have the latitude the alter the XSD - which means I need to pursue the other option.  So I tried that.  My new service method looks like this:Code:   @PayloadRoot( localPart = SERVICE_REQUEST, namespace = NAMESPACE )   public JAXBElementlt;Outcomegt; processFileRequest( ServiceRequest requestObject )
And I then wrap my return object using the method that was created on ObjectFactory:Code:   /**    * Create an instance of {@link JAXBElement }{@code lt;}{@link Outcome }{@code gt;}}    *     */   @XmlElementDecl(namespace = quot;MyTestServicequot;, name = quot;ServiceResponsequot;)   public JAXBElementlt;Outcomegt; createServiceResponse(Outcome value) {       return new JAXBElementlt;Outcomegt;(_ServiceResponse_QNAME, Outcome.class, null, value);   }
I file up the server expecting this to resolve the problem.  But instead I get:

java.lang.IllegalStateException:
No adapter for endpoint [public javax.xml.bind.JAXBElementlt;dortman.xsd.objects.Out  comegt; dortman.annotated.MyTestEndpoint.processFileReques  t(dortman.xsd.objects.ServiceRequest)]:
Does your endpoint implement a supported interface like MessageHandler or PayloadEndpoint?       at org..ws.server.MessageDispatcher.ge  tEndpointAdapter(MessageDispatcher.java:283)       at org..ws.server.MessageDispatcher.di  spatch(MessageDispatcher.java:226)       at org..ws.server.MessageDispatcher.re  ceive(MessageDispatcher.java:169)       at org..ws.transport.support.WebServic  eMessageReceiverObjectSupport.handleConnection
(WebServiceMessageReceiverObjectSupport.java:89)       at org..ws.transport.from.WebServiceMe  ssageReceiverHandlerAdapter.handle
(WebServiceMessageReceiverHandlerAdapter.java:57)       at org..ws.transport.from.MessageDispa  tcherServlet.doService(MessageDispatcherServlet.ja  va:231)       at weblogic.servlet.internal.WebAppServletContext.exe  cute(WebAppServletContext.java:2174)       at weblogic.servlet.internal.ServletRequestImpl.run(S  ervletRequestImpl.java:1446)       at weblogic.work.ExecuteThread.execute(ExecuteThread.  java:201)       at weblogic.work.ExecuteThread.run(ExecuteThread.java  :173)

Apparently it was not impressed by my use of JAXBElement.  Has anybody else encountered this problem?
¥
Back Forum Reply New