我们正在创建一个来自WSDL的Web服务,其中soap消息在请求和响应中同时具有标题和正文。如何设置它以使用Spring WS?我找不到任何例子????
在WSDL中
<wsdl11:message name="createCourseSectionRequest">
<wsdl11:part name="Parameters" element="tns:createCourseSectionRequest"/>
<wsdl11:part name="HeaderInfoParameters" element="tns:imsx_syncRequestHeaderInfo"/>
</wsdl11:message>
<wsdl11:message name="createCourseSectionResponse">
<wsdl11:part name="Response" element="tns:createCourseSectionResponse"/>
<wsdl11:part name="HeaderInfoResponse" element="tns:imsx_syncResponseHeaderInfo"/>
</wsdl11:message>
端点
@PayloadRoot(localPart="CreateCourseSectionRequest", namespace="")
@ResponsePayload
public CreateCourseSectionResponse createCourseSection(CreateCourseSectionRequest req) {
//TODO
return null;
}
示例
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ims="http://www.imsglobal.org/services/lis/cmsv1p0/wsdl11/sync/imscms_v1p0">
<soapenv:Header>
<ims:imsx_syncRequestHeaderInfo>
<ims:imsx_version>?</ims:imsx_version>
<ims:imsx_messageIdentifier>?</ims:imsx_messageIdentifier>
<!--Optional:-->
<ims:imsx_sendingAgentIdentifier>?</ims:imsx_sendingAgentIdentifier>
</ims:imsx_syncRequestHeaderInfo>
</soapenv:Header>
<soapenv:Body>
.....
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:0)
这是我提出的解决方案。它的工作原理,但我希望Soap消息的标题部分是强类型的。 .NET会为您解决这个问题,而在Java中,您似乎需要做更多的工作来为头部复制强类型对象。至少我可以使用MessageContext访问信封的请求/响应头。
@PayloadRoot(localPart="readCourseSectionRequest", namespace="http://www.imsglobal.org/services/lis/cmsv1p0/wsdl11/sync/imscms_v1p0")
@ResponsePayload
public ReadCourseSectionResponse readCourseSection(@RequestPayload ReadCourseSectionRequest parameters, MessageContext messageContext) {
//SaajSoapMessage response = (SaajSoapMessage) messageContext.getResponse();
//SoapHeader header = response.getSoapHeader();
//header.addHeaderElement(new QName("http://www.w3.org/2005/08/addressing", "MessageID", parameters.getSourcedId()));
return new ReadCourseSectionResponse();
}