谁知道在Spring Web服务中实际上是哪个类调用解组?我想知道在肥皂Iterceptor中调用un / marshalling是否有效/必要。还是有其他更合适的拦截器可用于处理端点周围的未编组对象?如果可以,我仍然想知道它在内部如何工作。
谢谢。
编辑
实际上,我使用org.springframework.ws.server.EndpointInterceptor
是为了更准确。
最佳答案
AbstractMarshallingPayloadEndpoint是将请求有效内容解组为对象并将响应对象解组为XML的端点,请检出its invoke() method source code:
public final void invoke(MessageContext messageContext) throws Exception {
WebServiceMessage request = messageContext.getRequest();
Object requestObject = unmarshalRequest(request);
if (onUnmarshalRequest(messageContext, requestObject)) {
Object responseObject = invokeInternal(requestObject);
if (responseObject != null) {
WebServiceMessage response = messageContext.getResponse();
marshalResponse(responseObject, response);
onMarshalResponse(messageContext, requestObject, responseObject);
}
}
}
AbstractMarshallingPayloadEndpoint需要对XML封送处理程序的引用:
Castor XML:org.springframework.oxm.castor.CastorMarshaller
JAXB v1:org.springframework.oxm.jaxb.Jaxb1Marshaller
JAXB v2:org.springframework.oxm.jaxb.Jaxb2Marshaller
JiBX:org.springframework.oxm.jibx.JibxMarshaller
XMLBeans:org.springframework.oxm.xmlbeans.XmlBeansMarshaller
XStream:org.springframework.oxm.xstream.XStreamMarshaller
请注意,在Spring-OXM中,所有封送处理程序类都实现Marshaller和Unmarshaller接口,以提供OXM封送处理的一站式解决方案,例如Jaxb2Marshaller,因此在applicationContext中,您的AbstractMarshallingPayloadEndpoint实现如下所示:
<bean id="myMarshallingPayloadEndpoint"
class="com.example.webservice.MyMarshallingPayloadEndpoint">
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
... ...
</bean>
希望这可以帮助。