1

我们正在创建一个来自 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>
4

1 回答 1

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();
    }
于 2013-03-19T16:38:04.667 回答