小编use*_*505的帖子

Spring-WS:如何提取 Soap 消息体

我正在尝试从 spring-ws 应用程序中的肥皂请求中提取肥皂主体。我的肥皂请求是

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org  /soap/envelope/" xmlns:sch="http://www.manager.cts.com/schema">
 <soapenv:Header/>
   <soapenv:Body>
     <sch:addManagerRequest>
         <sch:name>shivani</sch:name>
         <sch:salary>1231231</sch:salary>
         <sch:developer>
            <sch:firstName>asd</sch:firstName>
            <sch:lastName>asdasd</sch:lastName>
            <sch:salary>123123</sch:salary>
         </sch:developer>
     </sch:addManagerRequest>
  </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下代码提取肥皂体:

@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
    SoapMessage message = (SoapMessage) messageContext.getRequest();
    SoapBody soapBody = message.getSoapBody();

    Source bodySource = soapBody.getSource();
    DOMSource bodyDomSource = (DOMSource) bodySource;

    Node bodyNode = bodyDomSource.getNode();
    System.out.println(bodyNode.getNodeValue());
    System.out.println(bodyNode.getChildNodes());
 }
Run Code Online (Sandbox Code Playgroud)

输出是:

 null
 [soapenv:Body: null]
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题。我是 spring-ws 的新手

spring spring-ws

1
推荐指数
1
解决办法
7932
查看次数

标签 统计

spring ×1

spring-ws ×1