2013-12-11 84 views
1

我想使用的NuSOAP PHP創建SOAP請求,PHP SOAP請求屬性正確創建

require_once('lib/nusoap.php'); 
    $client = new nusoap_client('wsdl_link', true); 

我想產生的請求的結構是:

<rootlevel att1="abc" att2="def" > 
    <Start> 

</Start> 
</rootlevel > 

參數如下:

$params=array('att1'=>'abc', 
    'att2'=>'def', 
    'start'=>array(/*array defined here*/)); 

$result = $client->call('function_name', array('rootlevel' => $params)); 

但隨着請求生成如下:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<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:ns4439="http://tempuri.org"> 
    <SOAP-ENV:Body> 
    <rootlevel xmlns="http://site/01"> 
     <start> 

    </start> 
    </rootlevel> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

請電話我,爲什麼我的屬性越來越被取代的xmlns ..

編輯: 我是通過我的WSDL打算: 在WSDL,標籤根層次Rootlevel被定義爲ref =「TNS:根層次Rootlevel 「並且屬性在名稱= rootlevel下定義,這是wsdl中的其他位置。

對於某些屬性來說,請求是正確的(這裏標記被定義爲名稱,屬性在這個標記下)。但有些正在被xmlns取代..請讓我知道我會出錯哪裏。

回答

0

我使用的NuSOAP的「發送」功能,解決了我的問題。這裏ü不必須創建一個數組和所有。該請求可以在XML格式本身發出如下:

$params="<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:ns4439="http://tempuri.org"> 
    <SOAP-ENV:Body> 
    <rootlevel xmlns="http://site/01"> 
     <start> 

    </start> 
    </rootlevel> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>"; 

$result = $client->send($params, 'wsdl_url/function',0,$timeout); 

希望這可以幫助你.. :)