gpt4 book ai didi

java - 在 JAX-WS 中更改 SOAPRequest 前缀

转载 作者:行者123 更新时间:2023-12-04 00:32:32 24 4
gpt4 key购买 nike

如何在 JAX-WS 中更改 SOAP 请求前缀。我更新了 handlemessage 中的 setprofix 方法

        SOAPMessage msgs = ctx.getMessage();

SOAPMessage sm = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
sm.getSOAPPart().getEnvelope().setPrefix("soap");
sm.getSOAPPart().getEnvelope().removeNamespaceDeclaration("env");
sm.getSOAPHeader().setPrefix("soap");
sm.getSOAPBody().setPrefix("soap");*/

但我仍然收到相同的请求

       <?xml version="1.0"?>
<S:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"

我需要

      <Soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 

请帮忙

最佳答案

    final SOAPMessage soapMsg = context.getMessage();
soapMsg.getSOAPPart().getEnvelope().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/");
soapMsg.getSOAPPart().getEnvelope().removeAttributeNS("http://schemas.xmlsoap.org/soap/envelope/", "env");
soapMsg.getSOAPPart().getEnvelope().removeAttribute("xmlns:env");
soapMsg.getSOAPPart().getEnvelope().setPrefix("soap");
soapMsg.getSOAPBody().setPrefix("soap");
soapMsg.getSOAPPart().getEnvelope().getHeader().detachNode();

关于java - 在 JAX-WS 中更改 SOAPRequest 前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14967691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com