开发者

PHP SOAP web service call

开发者 https://www.devze.com 2023-01-10 15:38 出处:网络
I\'ll start out by saying that I\'ve never used SOAP before. Anyway, Here\'s the code I\'m trying to create.

I'll start out by saying that I've never used SOAP before.

Anyway, Here's the code I'm trying to create.

<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>

The headers are already in place. I can call the service fine.

What I have is this

//Make the call  
$resul开发者_运维知识库t = $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);


Does this work:

$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'
        )
    ));

The '_' appears to be undocumented but workable. If it doesn't work, try the comments at http://www.php.net/manual/en/soapvar.soapvar.php.

0

精彩评论

暂无评论...
验证码 换一张
取 消