开发者

Spring WS 2.0.2 : Using StAX with @Endpoint

开发者 https://www.devze.com 2023-03-12 05:33 出处:网络
I\'m trying to use StAX with Spring WS 2.0.2 but I\'m not having any luck getting it working. I found an example online here but it uses AbstractStaxStreamPayloadEndpoint which is now deprecated in Sp

I'm trying to use StAX with Spring WS 2.0.2 but I'm not having any luck getting it working. I found an example online here but it uses AbstractStaxStreamPayloadEndpoint which is now deprecated in Spring WS 2.x. I'm trying to use the @Endpoint annotation approach but I am getting the following error:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring xml:lang="en">No adapter for endpoint [public void com.endpoint.AddressTypeEndpoint.handleReadAddressTypeRequest(javax.xml.stream.XMLStreamRea开发者_C百科der,javax.xml.stream.XMLStreamWriter) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And here is the code for my endpoint:

package com.endpoint;

import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;

import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;

@Endpoint
public class AddressTypeEndpoint {
    private static final String NAMESPACE_URI = "http://client/AddressType";

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "ReadAddressTypeRequest")
    public void handleReadAddressTypeRequest(XMLStreamReader streamreader, XMLStreamWriter streamwriter) throws Exception {
        System.out.println("Got to the endpoint");
    }
}

Does anyone know how I can use StAX with Spring WS, using @Endpoint?


Can you try annotating the method parameter:

 @PayloadRoot(namespace = NAMESPACE_URI, localPart = "ReadAddressTypeRequest")
 public void handleReadAddressTypeRequest(
      @RequestPayload XMLStreamReader streamreader) throws Exception {... }

[Edit] For the response, annotate the method with @ResponsePayload, and return one of the objects listed here http://static.springsource.org/spring-ws/site/reference/html/server.html#d4e1220 (instead of void)


Try using @ResponsePayload as explained in the Spring WS doc at: http://static.springsource.org/spring-ws/sites/2.0/reference/html/server.html

0

精彩评论

暂无评论...
验证码 换一张
取 消