Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP>;SOAP在标题中创建属性;“正确的方法”;_Php_Xml_Soap - Fatal编程技术网

PHP>;SOAP在标题中创建属性;“正确的方法”;

PHP>;SOAP在标题中创建属性;“正确的方法”;,php,xml,soap,Php,Xml,Soap,我在PHP中面临SOAP头的问题 我的代码应该生成如下内容 <soapenv:Header> <ns1:RequestHeader xmlns:ns1="xxxxxxx"> <ns1:auth xmlns:ns1="yyyy"> <ns1:user>xxx</ns1:user> <ns1:pass>false</ns1:pass>

我在PHP中面临SOAP头的问题

我的代码应该生成如下内容

  <soapenv:Header>
    <ns1:RequestHeader xmlns:ns1="xxxxxxx">
        <ns1:auth xmlns:ns1="yyyy">
           <ns1:user>xxx</ns1:user>
           <ns1:pass>false</ns1:pass>
       </ns1:auth>
    </ns1:RequestHeader>
  </soapenv:Header>
您对此有何看法?如何将属性正确添加到
RequestHeader


谢谢

我找到了解决办法

$header_part = '
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext" SOAP-ENV:mustUnderstand="1">
        <wsse:UsernameToken>
            <wsse:Username>'."USERNAME".'</wsse:Username>
            <wsse:Password>'."PASSWORD".'</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
';
$soap_var_header = new SoapVar( $header_part, XSD_ANYXML, null, null, null );
$soap_header = new SoapHeader( 'http://your-target-service.com', 'wsse', $soap_var_header );
$soap_client->__setSoapHeaders($soap_header);
$header\u part=>
““用户名”。”
““密码”。”
';
$soap_var_header=新的SoapVar($header_部分,XSD_ANYXML,null,null);
$soap\u header=新的SoapHeader('http://your-target-service.com“,”wsse“,$soap\u var\u header);
$soap\u客户端->\u设置soap阅读器($soap\u头);

您需要将此消息与原始soap请求一起发送。

我找到了解决方案

$header_part = '
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext" SOAP-ENV:mustUnderstand="1">
        <wsse:UsernameToken>
            <wsse:Username>'."USERNAME".'</wsse:Username>
            <wsse:Password>'."PASSWORD".'</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
';
$soap_var_header = new SoapVar( $header_part, XSD_ANYXML, null, null, null );
$soap_header = new SoapHeader( 'http://your-target-service.com', 'wsse', $soap_var_header );
$soap_client->__setSoapHeaders($soap_header);
$header\u part=>
““用户名”。”
““密码”。”
';
$soap_var_header=新的SoapVar($header_部分,XSD_ANYXML,null,null);
$soap\u header=新的SoapHeader('http://your-target-service.com“,”wsse“,$soap\u var\u header);
$soap\u客户端->\u设置soap阅读器($soap\u头);
您需要将其与原始soap请求一起发送

$header_part = '
    <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext" SOAP-ENV:mustUnderstand="1">
        <wsse:UsernameToken>
            <wsse:Username>'."USERNAME".'</wsse:Username>
            <wsse:Password>'."PASSWORD".'</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
';
$soap_var_header = new SoapVar( $header_part, XSD_ANYXML, null, null, null );
$soap_header = new SoapHeader( 'http://your-target-service.com', 'wsse', $soap_var_header );
$soap_client->__setSoapHeaders($soap_header);