Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 使用MarshallingWebServiceOutboundGateway时选择正确的SoapAction_Spring Integration_Soap Client - Fatal编程技术网

Spring integration 使用MarshallingWebServiceOutboundGateway时选择正确的SoapAction

Spring integration 使用MarshallingWebServiceOutboundGateway时选择正确的SoapAction,spring-integration,soap-client,Spring Integration,Soap Client,我正在努力学习Spring集成。作为一个测试项目来探索所有的特性。我的项目是这样的 AMQP Queue -> Header Router -> Transformer -> OutBound SOAP WS Call -> Log Results -> End 1.)通过侦听RabbitMq队列启动流。发送的RabbitMq消息将具有字符串值(例如:32)和类似{“operation”“celsiustofahernheit”}的头 2.)然后根据RabbitM

我正在努力学习Spring集成。作为一个测试项目来探索所有的特性。我的项目是这样的

AMQP Queue -> Header Router -> Transformer -> OutBound SOAP WS Call -> Log Results -> End
1.)通过侦听RabbitMq队列启动流。发送的RabbitMq消息将具有字符串值(例如:32)和类似{“operation”“celsiustofahernheit”}的头

2.)然后根据RabbitMq头值(“操作”)将RabbitMq消息转换为相应的Java对象

3.)然后我使用MarshallingWebServiceOutboundGateway调用SOAP WebService@()。当我这样做的时候,我得到了一个错误

ErrorMessage[payload=org.springframework.messaging.MessageHandlingException:消息处理程序[wsOutboundGateway]中发生错误;嵌套异常为org.springframework.ws.soap.client.SoapFaultClientException:服务器未识别HTTP标头SOAPAction:。,标头的值={replyChannel=org.springframework.messaging.core.GenericMessageTemplate$TemporaryReplyChannel@601affec,errorChannel=org.springframework.messaging.core.GenericMessageTemplate$TemporaryReplyChannel@601affec,id=7f6624cc-e7a4-37f6-0a1f-578dc78c4afa,时间戳=1482356790717}]

正如您所看到的,SOAPAction是空白的,服务器不喜欢它

如果我像这样硬编码SOAPAction

public MessageHandler wsOutboundGateway()
{
    MarshallingWebServiceOutboundGateway temperatureConversionWebServiceGateway = new MarshallingWebServiceOutboundGateway(WEBSERVICE_URL, jaxb2Marshaller(), jaxb2Marshaller());
    temperatureConversionWebServiceGateway.setRequestCallback(new SoapActionCallback("http://www.w3schools.com/xml/CelsiusToFahrenheit"));
    temperatureConversionWebServiceGateway.setOutputChannelName("webServiceResponseChannel");
    return temperatureConversionWebServiceGateway;
}
它起作用了

但是,端点公开了2个服务(2个可能的操作)。请参见下文

华氏摄氏度soapAction=”http://www.w3schools.com/xml/FahrenheitToCelsius" CelsiusToFahrenheit soapAction=”http://www.w3schools.com/xml/CelsiusToFahrenheit"

我希望能够在运行时基于RabbitMQ头值(“操作”)设置SoapAction。我该如何做

另一方面,我已经做了一些不同的实验来解决这个问题,但似乎没有一个能产生我想要的结果。我尝试的解决方案之一是将SoapAction设置为转换过程的一部分(根据RabbitMQ头值将RabbitMQ消息的输入转换为相应的Java类型)并将该请求发送到出站网关(请参阅下面的代码)

@Bean
公共集成流GenerateCelsiUstofHearnHeitRequestFlow(){
Map headers=newhashmap();
headers.put(“SOAPAction”http://www.w3schools.com/xml/CelsiusToFahrenheit");
返回IntegrationFlows.from(Celsiustofahrenheithannel)
.变换(Celsiustofahrenheit变压器)
.enrichHeaders(标题)
.channel(webServiceRequestChannel)
.get();
}
在我这样做并点击“webServiceRequestChannel”之后,我会看到我之前添加的SoapAction头(见下文)

GenericMessage[payload=CelsiustOfHarenheit[celsius=32],Header={SOAPAction=,amqp_receivedDeliveryMode=NON_PERSISTENT

但是,当MarshallingWebServiceOutboundGateway接收到请求并对SOAP Web服务进行出站调用时,“SOAPAction:”仍然为空。我不知道为什么SOAP操作被屏蔽。我缺少了什么


很抱歉,如果我在编写/格式化问题时没有遵循惯例。这是我第一次在这里讨论堆栈溢出问题。对于解决此问题的任何输入或建议,我们都将非常感谢。

是的,这里的错误是头名必须完全是
WebServiceHeaders.SOAP\u ACTION
,其名称是
ws\u soapA>操作
。只有现在,
DefaultSoapHeaderMapper
才能将其映射到请求
WebserviceMessage

public DefaultSoapHeaderMapper() {
    super(WebServiceHeaders.PREFIX, STANDARD_HEADER_NAMES, Collections.<String>emptyList());
}
public DefaultSoapHeaderMapper(){
super(WebServiceHeaders.PREFIX,标准_HEADER_名称,Collections.emptyList());
}

非常感谢您的快速回复。效果很好!!。感谢@Samuel Liew整理我的问题。我将确保在以后的问题中采用这种格式。
public DefaultSoapHeaderMapper() {
    super(WebServiceHeaders.PREFIX, STANDARD_HEADER_NAMES, Collections.<String>emptyList());
}