PHP SOAP Web服务调用

时间:2010-08-05 19:05:53

标签: php soap soap-client nusoap

我首先会说我以前从未使用过SOAP。

无论如何,这是我正在尝试创建的代码。

<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 个答案:

答案 0 :(得分: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上的评论。