我们正在创建一个来自WSDL的We服务,soap消息在请求和响应中具有一个头部和主体。如何将其设置为与Spring WS一起工作?我找不到任何例子?
In 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>
发布于 2013-03-19 16:38:04
这是我想出的解决办法。它可以工作,但我希望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();
}
https://stackoverflow.com/questions/15440565
复制相似问题