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

问题描述 投票:3回答:2

我正在使用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:,请告诉我解决此问题。

谢谢

php xml soap nusoap
2个回答
2
投票

这是我解决此问题的方式

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

0
投票

已解决此问题,必须配置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>
© www.soinside.com 2019 - 2024. All rights reserved.