PHP>;SOAP在标题中创建属性;“正确的方法”;
我在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>
<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);