tags:

views:

492

answers:

3

I am attempting to consume a SOAP service provided by our Cisco phone system (documentation), to get the current status of a given set of phones. I have an array of phone names, which I'm trying to pass to the service, however, the values of the array are being eaten somewhere

Array of items like so:

$items = array(
    0 => "SEP0004F2E57F8C",
    1 => "SEP001111BF8758",
    2 => "SEP001320BD485C"
);

Attempting to call the method:

$client = new SoapClient(
    "https://x.x.x.x/realtimeservice/services/RisPort?wsdl", 
    array(
        "login" => "admin",
        "password"=> "xxxxx",
        "trace" => true
    )
);
$devices = $client->SelectCmDevice(
    "",
    array(
        "SelectBy" => "Name",
        "Status" => "Any",
        "SelectedItems" => $items
    )
);

When I debug the complete request I get the following:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
mlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://schemas.cisco.com/ast/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
    <SOAP-ENV:Body>
        <ns1:SelectCmDevice>
            <StateInfo xsi:type="xsd:string"></StateInfo>
            <CmSelectionCriteria xsi:type="ns1:CmSelectionCriteria">
                <MaxReturnedDevices xsi:nil="true"/>
                <Class xsi:nil="true"/>
                <Model xsi:nil="true"/>
                <Status xsi:type="xsd:string">Any</Status>
                <NodeName xsi:nil="true"/>
                <SelectBy xsi:type="xsd:string">Name</SelectBy>
                <SelectItems SOAP-ENC:arrayType="ns1:SelectItem[3]" xsi:type="ns1:SelectItems">
                    <item xsi:type="ns1:SelectItem"/>
                    <item xsi:type="ns1:SelectItem"/>
                    <item xsi:type="ns1:SelectItem"/>
                </SelectItems>
            </CmSelectionCriteria>
        </ns1:SelectCmDevice>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The correct number of <Item> elements were counted and inserted into the <SelectItems> object, however, the actual item names themselves are gone. I would guess it needs to be <Item>SEP0004F2E57F8C</Item>, etc., but I can't seem to figure out how to make it do that.

Thank you in advance for any help!!!

A: 

It might be that the API is expecting different values for the array. The fact that the correct number of items are included is promising.

Is there a way in their API to create a list of selected items one item at a time? i.e. start selecting the items, enter each item that you would like, then end selecting the items? I am not sure that it is understanding the Array argument on the Cisco side. Also, have you tried to manually generate the query in the form you are creating (i.e. if you copy this query, insert your IDs where you are trying to get them) does it work?

Jacob

TheJacobTaylor
A: 

On further inspection, Cisco's API wants the items in a really weird format anyway, so I am have switched to just creating the full request XML by hand rather than relying on SoapClient to build it for me. Not as nice and clean, but it gets the job done.

A: 

After searching and trying for serveral hours I've solved it.

$array['SelectBy'] = "Name";

$array['Status'] = "Any";

$array['SelectItems']['SelectItem[0]']['Item'] = "SEP0015F9B16122";

$array['SelectItems']['SelectItem[1]']['Item'] = "SEP0015F9B16123";

$devices = $client->SelectCmDevice( "", $array );

Just to remember: Status of unknown wouldn't show up in the result.

Herman