2010-08-05 157 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