在 Nusoap PHP 中添加命名空间前缀

发布于 2024-12-26 06:44:44 字数 1261 浏览 0 评论 0原文

我正在使用 nusoap v 1.123,我正在尝试在生成的 nusoap 请求中添加前缀 urn

这是我所期望的

<soapenv:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:urn="urn:mnop:acceptor:contract"> 
       <soapenv:Header> 
          <urn:authenticationHeader> 
             <urn:name>abctest</urn:name> 
             <urn:userid>dddd</urn:userid> 
             <urn:pass>errerere</urn:pass> 
          </urn:authenticationHeader> 
       </soapenv:Header> 

,这就是代码生成的

   <SOAP-ENV:Header>
          <authenticationHeader> 
             <name>abctest</urn:name> 
             <userid>dddd</urn:userid> 
             <pass>errerere</urn:pass> 
          </authenticationHeader> 
     </SOAP-ENV:Header>


$header = new SoapHeader($wsdl, 'authenticationHeader',$headerParam);  
$soapAction='urn:mnop:acceptor:contract';
$client = new  nusoap_client($wsdl);
$client->setHeaders($headerParam);
$data=$client->call('myoperation',$bodyParam,$namespace,$soapAction,null,null,'document', 'literal');

urn 前缀缺失的 内容SOAP-ENV: 需要替换为soapenv: ,请告诉我解决这个问题。

谢谢

I'm using nusoap v 1.123, I'm trying to add the prefixes urn in my generated request of nusoap

This is what I am expecting

<soapenv:Envelope  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:urn="urn:mnop:acceptor:contract"> 
       <soapenv:Header> 
          <urn:authenticationHeader> 
             <urn:name>abctest</urn:name> 
             <urn:userid>dddd</urn:userid> 
             <urn:pass>errerere</urn:pass> 
          </urn:authenticationHeader> 
       </soapenv:Header> 

and this is what the code is generating

   <SOAP-ENV:Header>
          <authenticationHeader> 
             <name>abctest</urn:name> 
             <userid>dddd</urn:userid> 
             <pass>errerere</urn:pass> 
          </authenticationHeader> 
     </SOAP-ENV:Header>


$header = new SoapHeader($wsdl, 'authenticationHeader',$headerParam);  
$soapAction='urn:mnop:acceptor:contract';
$client = new  nusoap_client($wsdl);
$client->setHeaders($headerParam);
$data=$client->call('myoperation',$bodyParam,$namespace,$soapAction,null,null,'document', 'literal');

the urn prefix is missing and SOAP-ENV: need to be replaced with soapenv: , kindly tell me to resolve this issue.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扶醉桌前 2025-01-02 06:44:44

这就是我解决这个问题的方法

$bodyParam = array('urn:operationName'=>array(
    'urn:amount'=>'23232',
    'urn:automati'=>'monUrl',
    'urn:context'=>'',
    'urn:currencyCode'=>'978',
    'urn:customerId'=>'',
    'urn:customerIpAddress'=>'',
    'urn:customerLanguage'=>'fr',
));

this is how I solved this problem

$bodyParam = array('urn:operationName'=>array(
    'urn:amount'=>'23232',
    'urn:automati'=>'monUrl',
    'urn:context'=>'',
    'urn:currencyCode'=>'978',
    'urn:customerId'=>'',
    'urn:customerIpAddress'=>'',
    'urn:customerLanguage'=>'fr',
));
冰魂雪魄 2025-01-02 06:44:44

解决这个问题,必须配置nusoap参数

添加全局命名空间

$client->namespaces['tem'] = "http://tempuri.org/";

并为元素添加本地命名空间

$responseService = $client->call(
            'CAV_GET_DATA',
            $param,
            $namespace = 'tem'
        );

解决

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tem="http://tempuri.org/" xmlns:ns6704="tem"><SOAP-ENV:Body><tem:CAV_GET_DATA><tem:UsuarioID>example</tem:UsuarioID><tem:Password>example</tem:Password><tem:idEmpleado>000000</tem:idEmpleado></tem:CAV_GET_DATA></SOAP-ENV:Body></SOAP-ENV:Envelope>

Solved this problem, nusoap parameters must be configured

add global name space

$client->namespaces['tem'] = "http://tempuri.org/";

and add local namespace for elements

$responseService = $client->call(
            'CAV_GET_DATA',
            $param,
            $namespace = 'tem'
        );

Resolve

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tem="http://tempuri.org/" xmlns:ns6704="tem"><SOAP-ENV:Body><tem:CAV_GET_DATA><tem:UsuarioID>example</tem:UsuarioID><tem:Password>example</tem:Password><tem:idEmpleado>000000</tem:idEmpleado></tem:CAV_GET_DATA></SOAP-ENV:Body></SOAP-ENV:Envelope>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文