简体   繁体   English

Soap WS-Security 错误:安全标头不正确

[英]Soap WS-Security error: Incorrect security header

I'm try to connect to a web service with WS-Security, but I receive an error message "Incorrect security header", here is the SoapHeader:我尝试使用 WS-Security 连接到 Web 服务,但收到错误消息“安全标头不正确”,这是 SoapHeader:

<soapenv:Header>
  <wsse:Security mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:UsernameToken Id="ABC-123">
      <wsse:Username>*****</wsse:Username>
      <wsse:Password>*****</wsse:Password>
    </wsse:UsernameToken>
  </wsse:Security>
</soapenv:Header>

And here is the Php code to connect:这是连接的 PHP 代码:

<?php

$client = new SoapClient("https://www.weservice.com/service?wsdl");

//Body of the Soap Header. 
$headerbody = array("UsernameToken" => array("Username" => "******",
                                             "Password" => "******"));

//Create Soap Header.        
$header = new SoapHeader("wsse", "Security", $headerbody);

//set the Headers of Soap Client. 
$client->__setSoapHeaders($header);

try{
$result = $client->__soapCall("sendBill", array("fileName" => "filename",
                                                "contentFile" => "byteArray"));

}catch(SoapFault $e){
    echo $e;
}

Thanks in advance.提前致谢。

I finally solved this incident taking a different way.我终于以不同的方式解决了这个事件。 With Php, the zip file in byte array couldn't be sent because some rare reason (maybe the Php's poor support on attachments over soap protocol).使用 Php,字节数组中的 zip 文件无法发送,因为一些罕见的原因(可能是 Php 对基于soap 协议的附件的支持很差)。

So I changed the language to C#, now I could test a dummy file to the soap service, I had some (solved) problems, but I receive a succesfull response from the service.因此,我将语言更改为 C#,现在我可以将一个虚拟文件测试到soap 服务,我遇到了一些(已解决)问题,但是我收到了来自该服务的成功响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM