请帮助您创建包含WS-A参数的请求 从: 至: 等
<int:chain input-channel="msoapInChannel" output-channel="justLog">
<ws:header-enricher >
<ws:soap-action value="http://yeah.com/Txns/port/sPortType/getesRequest"/>
</ws:header-enricher>
<ws:outbound-gateway uri="http://g.tst.b.l/wsb/router"/>
</int:chain>
我想添加wsa:从wsa:To到请求
错误:1100表示消息寻址属性的标头不是 当下。 (原因:所需的标题元素wsa:From不存在)
如何在基于xml的配置中执行此操作?
编辑: 我们创建请求并使用JMS队列。请求如下所示
String requestXml =
"<getnNames xmlns=\"http://b.do.com/DTositeTxns/port\">" +
"<RequestControl xmlns=\"http://www.im.com/mm/schema\">" +
"<requestID>123896</requestID>" +
"<DLControl>" +
"<requesterName>LW</requesterName>" +
"<requesterLocale>RTnl</requesterLocale>" +
"</DLControl>" +
"</RequestControl>" +
"<InquiryParam xmlns=\"http://www.im.com/mm/schema\">" +
"<tcrmParam name=\"identiftionNumber\">" + bn + "</tcrmParam>" +
"<tcrmParam name=\"PartficationType\">1000001</tcrmParam>" +
"<tcrmParam name=\"Filter\">ACTIVE</tcrmParam>" +
"</InquiryParam>" +
"</getnNames>" ;
TextMessage outMessage = session.createTextMessage(requestXml);
并发送到队列。 如果我使用soapenv:Body,则不接受请求为有效。所以我的要求只是身体内的标签。不知道如何添加标题位。
请指出一个用wsa创建请求的示例:To和wsa:From,Relates To,Fault to etc
答案 0 :(得分:0)
wsa:From
和wsa:To
是Element
标题,它们不是像上面提到的soap-action
那样的简单字符串。那里<ws:header-enricher>
对你没有帮助。
但是,您仍然可以为普通<int:header-enricher>
声明一个bean,并为标头提供javax.xml.transform.Source
作为值。
从 5.0版开始,Spring Integration的DefaultSoapHeaderMapper
可以在<soapenv:Header>
:https://docs.spring.io/spring-integration/docs/5.0.5.RELEASE/reference/html/ws.html#ws-message-headers中添加元素。
请参阅示例文档:
Map<String, Object> headers = new HashMap<>();
String authXml =
"<auth xmlns='http://test.auth.org'>"
+ "<username>user</username>"
+ "<password>pass</password>"
+ "</auth>";
headers.put("auth", new StringSource(authXml));
...
DefaultSoapHeaderMapper mapper = new DefaultSoapHeaderMapper();
mapper.setRequestHeaderNames("auth");
<强>更新强>
<ws:outbound-gateway>
的属性如下:
<xsd:attribute name="request-callback" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Reference to a Spring Web Services WebServiceMessageCallback. This enables changing
the Web Service request message after the payload has been written to it but prior
to invocation of the actual Web Service.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.ws.client.core.WebServiceMessageCallback"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
所以,你需要的是为ActionCallback
配置一个bean并从这个属性中引用它。
有关ActionCallback
的更多信息,请参见Spring WS Reference Manual。