我有一个spring端点作为项目的一部分,我想访问Soap头。当我将SoapHeader添加到方法参数时,会得到以下异常:
10/05/16 05:00:05:005 PDT localhost-startStop-1调试springframework.integration.util.MessagingMethodInvokerHelper.doWith():方法公共com.bstonetech.ptms.integration.model.ws.external.contract.GetContractResponse com.bstonetech.ptms.integration.service.ws.GetContractEndpoint.getContract(com.bstonetech.ptms.integration.model.ws.external.contract.GetContractRequest,org.springframework.ws.context.MessageContext)抛出的java.lang.Exception没有资格进行消息处理,找到的参数类型不止一种:@org.springframework.ws.server.endpoint.annotation.RequestPayload、com.bstonetech.ptms.integration.model.ws.external.contract.GetContractRequest和org.springframework.ws.context.MessageContext.。10/05/16 05:00:05:005 PDT localhost-startStop-1警告上下文初始化过程中遇到的web.context.support.XmlWebApplicationContext.refresh():异常-取消刷新尝试 com.bstonetech.ptms.integration.service.ws.GetContractEndpoint类型的目标对象没有处理消息的合格方法。
在使用MessageContext messageContext时也会发生相同的错误。
很明显我漏掉了什么。任何帮助都将不胜感激。
合并情况如下:
<oxm:jaxb2-marshaller id="contractMarshaller" context-path="com.bstonetech.ptms.integration.model.ws.external.contract"/>
<ws:inbound-gateway id="getContractWs" request-channel="inboundGetContractChannel" mapped-request-headers="fileId" mapped-reply-headers="fileId"
marshaller="contractMarshaller" unmarshaller="contractMarshaller"/>
<int:service-activator id="contractEndpoint" input-channel="inboundGetContractChannel" ref="getContractEndpoint"/>端点看起来如下:
@Endpoint
public class GetContractEndpoint {
private static final String NAMESPACE_URI = "http://bstonetech.com/contract";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "GetContractRequest")
@ResponsePayload
public GetContractResponse getContract(@RequestPayload GetContractRequest request, SoapHeader soapHeader) throws Exception {
.....
}发布于 2016-05-12 15:13:32
抱歉耽搁了。我们忙于Spring 4.3.0.RC1发行版:-)。
好吧,看起来你错过了一些东西,因此最终导致了一系列的担忧。
Spring方法调用注释(@RequestPayload,@PayloadRoot)和特定于SOAP的参数注入实际上适用于POJO情况,当您在服务上拥有@Endpoint并依赖于@EnableWs或类似的Spring机制时。
另一方面,模块完全建立在Spring项目的基础上,但它的目标是尽快将所有内容转换为消息传递模型。因此,<ws:inbound-gateway>的一个结果是将Message发送到request-channel="inboundGetContractChannel"。在您的示例中,payload将根据JaxB映射被解封到某些域对象。
<service-activator>现在只能处理消息传递基础结构,而且它对SOAP一无所知。这是消息传递的一般目的,因为您可以切换到完全不同的源(例如DB),但仍然使用相同的<service-activator>。
为了满足某些POJO方法调用,有一些有用的注释,如@Payload、@Header等。
为了保持一致性,并且仍然提供一些SOAP信息,AbstractWebServiceInboundGateway与DefaultSoapHeaderMapper协商并将source.getSoapHeader()状态提取为一个单独的MessageHeaders。因此,您仍然可以从请求中访问所需的标头。
https://stackoverflow.com/questions/37145982
复制相似问题