2010-08-05 300 views
0

我會先說我以前從未使用過SOAP。PHP SOAP web服務調用

無論如何,這是我正在創建的代碼。

<soapenv:Body> 
<Circuits xmlns="http://www.qpricer.com/Services/Pricing"> 
<Circuit bandwidth="DS-3" port-billing-type="Flat" product="Dedicated Voice" term="1-Year"> 
<ns1:Loop npanxx="212255" xmlns:ns1="http://www.qpricer.com/Schema/Pricing"> 
<ns1:Address city="MANHATTAN" postal-code="10011" state="NY" street="111 8 AV FLR 1"/> 
</ns1:Loop> 
</Circuit> 
</Circuits> 
</soapenv:Body> 

標題已經存在。我可以打電話給服務很好。

我所擁有的就是這個

//Make the call 
$result = $client->Price('Circuits', 
     array(
     'Circuit'   => array(
     'product'   => 'Dedicated Voice', 
     'port-billing-type' => 'flat', 
     'term'    => '1-Year', 
     'bandwidth'   => 'DS-3' 
     ), 

     'Loop'    => array(
     'npanxx'   => '212255' 
     ), 

     'Address'   => array(
     'street'   => '111 8 AV FLR 1', 
     'city'    => 'MANHATTAN', 
     'state'    => 'NY', 
     'postal-code'  => '10011') 
     )); 

// Display the result 
print_r($client->__getLastRequest()); 
print_r($result); 

回答

1

這是否工作:

$result = $client->Price('Circuits', 
    array(
    'Circuit'   => array(
     '_'     => array(
      'Loop'    => array(
       '_' => '', 
       'npanxx'   => '212255' 
      ), 
      'Address'   => array(
       '_' => '', 
       'street'   => '111 8 AV FLR 1', 
       'city'    => 'MANHATTAN', 
       'state'    => 'NY', 
       'postal-code'  => '10011' 
      ) 
     ), 
     'product'   => 'Dedicated Voice', 
     'port-billing-type' => 'flat', 
     'term'    => '1-Year', 
     'bandwidth'   => 'DS-3' 
     ) 
    )); 

'_'似乎是無證,但可行的。如果不起作用,請嘗試在http://www.php.net/manual/en/soapvar.soapvar.php的評論。

+0

不幸的是,還是一樣的錯誤。我們可以在QPricer.API.QPricer.Price(電路電路)檢查您的XML命名空間,或許是?QPricer.API.QPricer.Price(電路電路)在C:\ wamp \ www \ soap.php:79堆棧跟蹤:#0 [內部函數]:SoapClient - > __ call('Price',Array)#1 C:\ wamp \ www \ soap.php(79): SoapClient-> Price('Circuits',Array)#2 {main}拋出C:\ wamp \ www \ soap.php在79行「 – Xavias 2010-08-05 19:48:34

+0

啊,那麼它可能只適用於簡單類型。你有沒有嘗試我最後鏈接的soapvar例子(查看評論)?結果是什麼請求人? – Wrikken 2010-08-05 19:58:38

+0

我嘗試了第二個例子。它返回了這個。 「SOAP錯誤:QPricer.API.Common.Model.ApiException:在定價請求中沒有檢測到電路。檢查您的XML名稱空間,可能是? at QPricer.API.QPricer.Price(Circuits circuits)
我的代幣在這裏:)「 – Xavias 2010-08-05 20:06:24