首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >封装中包含头与体的Spring服务

封装中包含头与体的Spring服务
EN

Stack Overflow用户
提问于 2013-03-15 19:25:14
回答 1查看 1.4K关注 0票数 1

我们正在创建一个来自WSDL的We服务,soap消息在请求和响应中具有一个头部和主体。如何将其设置为与Spring WS一起工作?我找不到任何例子?

In WSDL

代码语言:javascript
运行
复制
<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>

端点

代码语言:javascript
运行
复制
@PayloadRoot(localPart="CreateCourseSectionRequest", namespace="")
    @ResponsePayload
    public CreateCourseSectionResponse createCourseSection(CreateCourseSectionRequest req) {

        //TODO 
        return null;
    }

示例

代码语言:javascript
运行
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2013-03-19 16:38:04

这是我想出的解决办法。它可以工作,但我希望Soap消息的头部分是强类型的。.NET为您处理这个问题,而在Java中,您似乎需要做更多的工作来为头复制一个强类型的对象。至少我可以使用MessageContext访问信封的请求/响应头。

代码语言:javascript
运行
复制
@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();
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15440565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档