views:

46

answers:

1

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"&gt; 
<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"&gt; 
<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  
$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);

Any help will be greatly appreciated.

Thanks, Adam Boersma

+1  A: 

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.

Wrikken
Unfortunately, No. Still the same error." Fatal error: Uncaught SoapFault exception: [soap:Client] QPricer.API.Common.Model.ApiException: No circuits detected in pricing request. Check your XML namespaces, perhaps? at QPricer.API.QPricer.Price(Circuits circuits) in C:\wamp\www\soap.php:79 Stack trace: #0 [internal function]: SoapClient->__call('Price', Array) #1 C:\wamp\www\soap.php(79): SoapClient->Price('Circuits', Array) #2 {main} thrown in C:\wamp\www\soap.php on line 79"
Xavias
Ah, then it probably only works for simpletypes. Did you try the soapvar examples I linked in the end (look at the comments)? What was the resulting requestbody?
Wrikken
I did try the second example. It returned this. "SOAP FAULT: QPricer.API.Common.Model.ApiException: No circuits detected in pricing request. Check your XML namespaces, perhaps? at QPricer.API.QPricer.Price(Circuits circuits)<br /> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qpricer.com/Services/Pricing" xmlns:ns2="Identity"><SOAP-ENV:Header><ns2:token>My token goes in here :)</ns2:token></SOAP-ENV:Header><SOAP-ENV:Body><ns1:Circuits/></SOAP-ENV:Body></SOAP-ENV:Envelope>"
Xavias
It looks like it isn't quite sending the rest of the xml doc with it. hmm.
Xavias
Well after working on this a little farther I can almost get it to work. My headers are appearing wrong apparently. Heres what they need to be."<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pric="http://www.qpricer.com/Services/Pricing" xmlns:pric1="http://www.qpricer.com/Schema/Pricing"><soapenv:Header><pric:Identity token="token here"/> </soapenv:Header>"
Xavias
Here's what they are "<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qpricer.com/Services/Pricing" xmlns:ns2="Identity"><SOAP-ENV:Header><ns2:token>0945ae54-c0a4-4db8-a99f-1b2158156eee</ns2:token></SOAP-ENV:Header>" How do I go from SOAP-ENV to soapenv, xmlns:ns1 to xmlns:pric, xmlns:ns2 to xmlns:pric1?Here's my header code for the token "$headers[] = new SoapHeader('Identity','token','token goes here');" For some reason it's not reading the Identity in the right spot. any Ideas?
Xavias
Instead of passing 'Identity' in `SoapHeader`, pass 'http://www.qpricer.com/Services/Pricing', the name of the prefix shouldn't matter (be it `pric1` or `ns1`, as long as the uri is correct,'Identity' is the second argument, possibly add a `DOMElement` node with the proper attribute as the third argument, or a SoapVar with the proper settings.
Wrikken