spring 集成编组后找不到 SOAP headers
Can't find SOAP headers after spring integration marshalling
我正在尝试为 SOAP 服务创建入站网关,它接受如下 SOAP 请求:
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<RequestHeader xmlns="http://test.com/">
<SecurityToken>mytoken</SecurityToken>
<RequestID>1234</RequestID>
</RequestHeader>
</S:Header>
<S:Body>
<BaseRequest xmlns="http://test.com/">
<RequestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="BalanceRequest">
<CustomerID>1234</CustomerID>
</RequestData>
</BaseRequest>
</S:Body>
</S:Envelope>
我想将 JAXB 用于 marshalling/unmarshalling request/response。我已成功配置 Spring/Spring-integration 如下:
<oxm:jaxb2-marshaller id="soapMarshaller" context-path="com.test" />
<int:channel id="soap-channel"/>
<int-ws:inbound-gateway id="ws-inbound-gateway"
request-channel="soap-channel"
marshaller="soapMarshaller"/>
<int:service-activator input-channel="soap-channel">
<bean class="com.test.SoapServiceActivator"/>
</int:service-activator>
并且我尝试在服务激活器中提取 SOAP header 和 body。
@ServiceActivator
public BaseResponse issueResponseFor(BaseRequest body,
@Headers Map<String, Object> headerMap) {
return null;
}
BaseRequest 是一个带注释的 JAXB class。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"requestData"
})
@XmlRootElement(name = "BaseRequest")
public class BaseRequest {
@XmlElement(name = "RequestData")
protected BaseRequestBody requestData;
}
我的问题是,在变量 body 中,我得到了 SOAP 请求的 body,但无论如何我没有找到提取 SOAP 的 header要求。 headerMap 变量仅包含标准的 Spring-Integration headers(replyChannel、errorChannel、id、timestamp)。 headers,我指的是 SecurityToken+RequestID,以及带有所请求操作名称的 HTTP header。
知道怎么做吗?
尝试使用mapped-request-headers="*"
.
默认情况下 DefaultSoapHeaderMapper
地图仅标准 headers。在这种情况下,它只是 WebServiceHeaders.SOAP_ACTION
更新
引用奥马尔的话:-)
Thanks ! The following code is working great :
@Autowired
@Qualifier("soapMarshaller")
Jaxb2Marshaller marshaller;
@ServiceActivator
public BaseResponse issueResponseFor(BaseRequest request, @Header("RequestHeader") SoapHeaderElement soapHeader) {
BaseRequestHeader requestHeader = (BaseRequestHeader) JAXBIntrospector.getValue(marshaller.unmarshal(soapHeader.getSource()));`
我正在尝试为 SOAP 服务创建入站网关,它接受如下 SOAP 请求:
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<RequestHeader xmlns="http://test.com/">
<SecurityToken>mytoken</SecurityToken>
<RequestID>1234</RequestID>
</RequestHeader>
</S:Header>
<S:Body>
<BaseRequest xmlns="http://test.com/">
<RequestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="BalanceRequest">
<CustomerID>1234</CustomerID>
</RequestData>
</BaseRequest>
</S:Body>
</S:Envelope>
我想将 JAXB 用于 marshalling/unmarshalling request/response。我已成功配置 Spring/Spring-integration 如下:
<oxm:jaxb2-marshaller id="soapMarshaller" context-path="com.test" />
<int:channel id="soap-channel"/>
<int-ws:inbound-gateway id="ws-inbound-gateway"
request-channel="soap-channel"
marshaller="soapMarshaller"/>
<int:service-activator input-channel="soap-channel">
<bean class="com.test.SoapServiceActivator"/>
</int:service-activator>
并且我尝试在服务激活器中提取 SOAP header 和 body。
@ServiceActivator
public BaseResponse issueResponseFor(BaseRequest body,
@Headers Map<String, Object> headerMap) {
return null;
}
BaseRequest 是一个带注释的 JAXB class。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"requestData"
})
@XmlRootElement(name = "BaseRequest")
public class BaseRequest {
@XmlElement(name = "RequestData")
protected BaseRequestBody requestData;
}
我的问题是,在变量 body 中,我得到了 SOAP 请求的 body,但无论如何我没有找到提取 SOAP 的 header要求。 headerMap 变量仅包含标准的 Spring-Integration headers(replyChannel、errorChannel、id、timestamp)。 headers,我指的是 SecurityToken+RequestID,以及带有所请求操作名称的 HTTP header。
知道怎么做吗?
尝试使用mapped-request-headers="*"
.
默认情况下 DefaultSoapHeaderMapper
地图仅标准 headers。在这种情况下,它只是 WebServiceHeaders.SOAP_ACTION
更新
引用奥马尔的话:-)
Thanks ! The following code is working great :
@Autowired
@Qualifier("soapMarshaller")
Jaxb2Marshaller marshaller;
@ServiceActivator
public BaseResponse issueResponseFor(BaseRequest request, @Header("RequestHeader") SoapHeaderElement soapHeader) {
BaseRequestHeader requestHeader = (BaseRequestHeader) JAXBIntrospector.getValue(marshaller.unmarshal(soapHeader.getSource()));`