SOAP UI工具填写用户名密码校验通不过,需要报文头添加

saop  ui默认生成的报文

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.payment.fs.kmss.landray.com/">
    <soapenv:Header/>
   <soapenv:Body>
      <web:updateStatus>
         <!--Optional:-->
       
      <arg0>RDPZ20180404009</arg0></web:updateStatus>
   </soapenv:Body>

</soapenv:Envelope>


点击运行提示


需在报文头增加用户名密码传递

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.payment.fs.kmss.landray.com/">
    <soapenv:Header>
   <tns:RequestSOAPHeader xmlns:tns="http://sys.webservice.client">
<tns:user>SAP</tns:user>
<tns:password>e10adc3949ba59abbe56e057f20f883e</tns:password>
</tns:RequestSOAPHeader>
</soapenv:Header>
   <soapenv:Body>
      <web:updateStatus>
         <!--Optional:-->
       
      <arg0>RDPZ20180404009</arg0></web:updateStatus>
   </soapenv:Body>

</soapenv:Envelope>

接口通了,返回对应的报错信息。


具体为什么直接在


这里填写用户名密码无效,暂时原因未知

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您可以通过以下步骤向SOAP添加用户名密码: 1. 创建一个包含用户名密码SOAPHeader对象。 2. 将SOAPHeader对象添加SOAPEnvelope中。 3. 将SOAPEnvelope对象设置为SOAPMessage对象的内容。 4. 使用SOAPConnection发送SOAPMessage对象。 以下代码片段演示了如何向SOAP添加用户名密码: ```java // 创建SOAP消息 SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); // 创建SOAP SOAPHeader soapHeader = soapMessage.getSOAPHeader(); // 创建身份验证信息 String username = "username"; String password = "password"; String authString = username + ":" + password; String authStringEnc = new String(Base64.encodeBase64(authString.getBytes())); // 添加身份验证信息到SOAP SOAPHeaderElement authHeader = soapHeader.addHeaderElement(new QName("http://example.com", "Authentication", "auth")); authHeader.addChildElement("Username").setValue(username); authHeader.addChildElement("Password").setValue(password); authHeader.addChildElement("AuthType").setValue("Basic"); authHeader.addChildElement("AuthData").setValue(authStringEnc); // 将SOAPEnvelope对象设置为SOAPMessage对象的内容 soapMessage.saveChanges(); // 发送SOAP消息 SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = soapConnection.call(soapMessage, "http://example.com/soap"); ``` 注意,上面的代码片段使用了Apache Commons Codec库中的Base64类来编码用户名密码。您需要将此库添加到您的项目中,或者使用其他编码库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值