修改SOAP头前缀(Axis 1.4)

时间:2013-01-01 12:19:37

标签: java web-services java-ee soap axis2

我正在尝试配置SOAP请求以使用Web服务

这是预期的SOAP请求

    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://xmlns.oracle.com/ABCS/Industry/Telco/ChannelLayer/ProcessPaymentChannelLayerReqABCSImpl" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test123</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>

我已经成功地提供了这样的SOAP请求。

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:must
Understand="0">
<wsse:UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>test</wsse:Username>
<wsse:password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test123</wsse:password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>

它们都是一样的,唯一的区别是来自 soapenv 的Envelop标签的前缀,需要更改为 env

在我尝试配置SOAPRequest的方法中,我可以访问 org.apache.axis.client.Stub

注意:我尝试访问SOAPEnvelop来设置前缀,它返回为null:(

提前致谢

1 个答案:

答案 0 :(得分:1)

以上两个XML代码段不相同,请检查以下差异:

env:mustUnderstand =“1”在哪里发送soapenv:mustUnderstand =“0”

实际上你的第二个XML会覆盖mustUnserstand标头两次吗?

同样正如@kdgregory所提到的,前缀确实无关紧要只是确保名称空间和标题值是正确的。