Reputation: 1023
I have a soap function, called selectCmDevice, that I'm having trouble formatting into a php statement to run a query. In the WSDL, selectCmDevice looks like this (I've included only the relevant parts);
<element name="selectCmDevice">
<complexType>
<sequence>
<element name="StateInfo" type="xsd:string"/>
<element name="CmSelectionCriteria" type="tns:CmSelectionCriteria"/>
</sequence>
<complexType name="CmSelectionCriteria">
<sequence>
<element name="MaxReturnedDevices" nillable="true" type="xsd:unsignedInt"/>
<element name="DeviceClass" nillable="true" type="xsd:string"/>
<element name="Model" nillable="true" type="xsd:unsignedInt"/>
<element name="Status" nillable="true" type="xsd:string"/>
<element name="NodeName" nillable="true" type="xsd:string"/>
<element name="SelectBy" nillable="true" type="tns:CmSelectBy"/>
<element name="SelectItems" nillable="true" type="tns:ArrayOfSelectItem"/>
<element name="Protocol" nillable="true" type="tns:ProtocolType"/>
<element name="DownloadStatus" nillable="true" type="tns:DeviceDownloadStatus"/>
</sequence>
<simpleType name="CmSelectBy">
<restriction base="xsd:string">
<enumeration value="Name"/>
<enumeration value="IPV4Address"/>
<enumeration value="IPV6Address"/>
<enumeration value="DirNumber"/>
<enumeration value="Description"/>
</restriction>
<complexType name="ArrayOfSelectItem">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="tns:SelectItem"/>
</sequence>
<complexType name="SelectItem">
<sequence>
<element name="Item" nillable="true" type="xsd:string"/>
</sequence>
<simpleType name="ProtocolType">
<restriction base="xsd:string">
<enumeration value="Any"/>
<enumeration value="SCCP"/>
<enumeration value="SIP"/>
<enumeration value="Unknown"/>
</restriction>
<simpleType name="DeviceDownloadStatus">
<restriction base="xsd:string">
<enumeration value="Any"/>
<enumeration value="Upgrading"/>
<enumeration value="Successful"/>
<enumeration value="Failed"/>
<enumeration value="Unknown"/>
</restriction>
</simpleType>
So, I've written a query to that seems to be accepted when I run it in PHP, but it doesn't pull anything I specify - it pulls everything in the system. It doesn't accept anything in insertVariableHere;
$deviceIP = $soapClient->selectCmDevice
(array('StateInfo' => '', 'CmSelectionCriteria' =>
(array('SelectBy'=>'Name','Status'=>'Registered','SelectItems'=>
array('SelectItem[0]'=>
array('Item'=>'insertVariableHere'))))));
I'm not sure if soap values for tns are being written properly in php. Any help is greatly appreciated.
Upvotes: 2
Views: 196
Reputation: 391
In order to see how the actual XML query looks based on WSDL, run the query in the program SoapUI. It is designed to get an overview of what is actually sent and received.
Once you know how the xml looks, initially send the entire XML string as a SOAPVAR to the selectCmDevice in PHP:
$xml='*copy of xml-request from SoapUI*';
$client=new SoapClient($wsdl,array('trace' => 1, 'exception' => 0));
$param=new SoapVar($xml,XSD_ANYXML);
$result=$client->selectCmDevice($param);
Now you sould have a working php-example of your query. From here you can modify your call as desired
Upvotes: 2