Java 修改SOAP头前缀(轴1.4)

Java 修改SOAP头前缀(轴1.4),java,web-services,jakarta-ee,soap,axis2,Java,Web Services,Jakarta 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

我正在尝试配置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>

测试
测试123
我成功地实现了这样的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>

测试
测试123
它们都是最相同的,唯一的区别是来自soapenv的信封标签的前缀需要更改为env

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

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


提前感谢

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

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

实际上,您的第二个XML覆盖mustUnserstand头两次


正如@kdgregory提到的,前缀并不重要,只要确保名称空间和标题值正确即可。

前缀值不重要。您认为为什么需要更改它?如果您在处理请求时遇到问题,请描述这些问题,不要假设原因。@kdgregory我们正在尝试使用一项我们需要解决的服务我们不是所有者,当我们触发使用服务的请求时,调用入站消息处理程序时出现以下错误。尝试为消息调用入站消息处理程序类“class com.collaxa.cube.security.Authenticator”时出错。报告的异常为:无法应用安全性[用户测试的凭据无效]当我们试图调查此异常的根本原因时,他们建议我们发送一个与我在问题中发布的相同的SOAP请求。我建议使用SOAPUI之类的工具进行任何此类测试。或者您可以通过
HttpUrlConnection
以字符串形式发送消息。但在此之前,您可能只需查看clo请仔细查看这两个请求,看看它们有什么不同。提示:在同一个元素中使用不同的值定义属性两次。