任何人都知道什么类实际调用春季Web服务中的反编组?我想知道是否有效/有必要在soap iterceptor中调用un/marshalling。或者是否有更适合用于处理端点周围未编组对象的拦截器?如果是,我仍然想知道它是如何在内部工作的。Spring WS:什么类调用unmarshalling?
谢谢。
编辑
其实我现在用的是org.springframework.ws.server.EndpointInterceptor
更准确。
任何人都知道什么类实际调用春季Web服务中的反编组?我想知道是否有效/有必要在soap iterceptor中调用un/marshalling。或者是否有更适合用于处理端点周围未编组对象的拦截器?如果是,我仍然想知道它是如何在内部工作的。Spring WS:什么类调用unmarshalling?
谢谢。
编辑
其实我现在用的是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.springframew ork.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
注意,在春季,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>
希望这有助于。
MethodArgumentResolver的实现负责将请求负载映射为适当的格式(xml Document,Dom4j,Jaxb等),而这恰好在调用端点之前发生。拦截器只能得到原始的xml Source(javax.xml.transorm.Source)。
如果你想在一个拦截器中解开原始的xml,那么你必须得到一个unmarshaller的引用并且自己做这件事,似乎没有任何一个EndpointInterceptor的孩子可以为你提供一个unmarshalled内容(考虑到它可以解开这么多不同的格式)。
谢谢你这个答案,我想知道是否可以在MessageContext或类似的地方找到一个unmarshalled对象。建议的解决方案正是我正在做的,但功能变得越来越复杂,现在我正在解组,并且对请求/响应进行编组也是在拦截器中进行的,因此它会执行两次。我们已经生成了端点,因此我们需要尽可能简化它。 – tomasb 2012-07-16 08:12:45
谢谢,这实现了我的担忧:),希望能够在解组后调用但在端点方法调用之前调用一些拦截器,但似乎不能这样工作。 – tomasb 2012-07-16 08:25:08