43429members
217967posts

Using php to load data from DCE

Highlighted

Using php to load data from DCE

This question was originally posted on DCIM Support by Chu Li Wei on 2020-01-31


Hi Team ,

Our customer wanna using php to load the data (humidity sensor) from DCE ,

He tried to use the script as below and got the "bool(false)" error message ,

Does anyone have such this experience and know where the script is wrong?

Your support would be appreciated.

Best Regards 

<?php include ('xml.php'); //Data, connection, auth //$dataFromTheForm = 'value'; // request data from the form $soapUrl = "https://10.xx.xx.xx/integration/services/ISXCentralSensorService_v2_0?wsdl"; // asmx URL of WSDL $soapUser = "username"; // username $soapPassword = "password"; // password // xml post structure //$xml_post_string = $xmldata; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: http://schemas.xmlsoap.org/soap/envelope/", "Content-length: ".strlen($xmldata), ); //SOAPAction: your op URL $url = $soapUrl; // PHP cURL for https connection with auth $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata); // the SOAP request curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // converting $response = curl_exec($ch); curl_close($ch); print_r($response); // converting $response1 = str_replace("<soapenv:Body>","",$response); $response2 = str_replace("</soapenv:Body>","",$response1); // convertingc to XML $parser = simplexml_load_string($response2); /*foreach ($parser->xpath('//ns2:Soap_Model_SOAP_Location_Country') as $item) { print_r($item); } */ // user $parser to get your data out of XML response and to display it. var_dump($response); ?> <!doctype-html> <html lang="zh_tw"> <head> <meta content="width=device-width" charset="utf-8" /> <title>DCE</title> <script language="javascript" type="text/javascript" src="js/angular.js"></script> <script type="text/javascript"></script> </head> <body> </body> </html>           ===================================================================================   <?php $xmldata = ' <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body xmlns:ns1="http://www.apc.com/stdws/xsd/ISXCentralDevices-v2"> <ns1:getAllDevicesResponse> <ns1:ArrayOfISXCDevice> <ns2:ISXCDevice xmlns:ns2="http://www.apc.com/stdws/xsd/ISXCentral/2009/10"> <ns2:ISXCNamedElement> <ns2:ISXCElement> <ns2:ISXCElementType>DEVICE</ns2:ISXCElementType> <ns2:id>B987654_nbSNMPEnc060D85C4</ns2:id> </ns2:ISXCElement> <ns2:name>10.x.x.x</ns2:name> </ns2:ISXCNamedElement> <ns2:ISXCCommState>ONLINE</ns2:ISXCCommState> <ns2:ISXCDeviceType>ENVIRONMENT</ns2:ISXCDeviceType> <ns2:hostName>10.x.x.x</ns2:hostName> <ns2:ipAddress>10.x.x.x</ns2:ipAddress> <ns2:location/> <ns2:modelName>NetBotz Rack Monitor 200</ns2:modelName> <ns2:modelNumber/> <ns2:parentID>B987654</ns2:parentID> <ns2:serialNumber>ZA1438017179</ns2:serialNumber> <ns2:ISXCDeviceState>NONE</ns2:ISXCDeviceState> <ns2:supplemental xsi:nil="true"/> </ns2:ISXCDevice> <ns2:ISXCDevice xmlns:ns2="http://www.apc.com/stdws/xsd/ISXCentral/2009/10"> <ns2:ISXCNamedElement> <ns2:ISXCElement> <ns2:ISXCElementType>DEVICE</ns2:ISXCElementType> <ns2:id>B987654_nbCustomSensorEnc2394E22A</ns2:id> </ns2:ISXCElement> <ns2:name>計中Humidity</ns2:name> </ns2:ISXCNamedElement> <ns2:ISXCCommState>ONLINE</ns2:ISXCCommState> <ns2:ISXCDeviceType>UNKNOWN</ns2:ISXCDeviceType> <ns2:hostName/> <ns2:ipAddress/> <ns2:location/> <ns2:modelName>Virtual Device</ns2:modelName> <ns2:modelNumber/> <ns2:parentID>B987654</ns2:parentID> <ns2:serialNumber/> <ns2:ISXCDeviceState>NONE</ns2:ISXCDeviceState> <ns2:supplemental xsi:nil="true"/> </ns2:ISXCDevice> </ns1:ArrayOfISXCDevice> </ns1:getAllDevicesResponse> </soap:Body> </soap:Envelope> '; ?>

(CID:154796037)

1 REPLY 1
Highlighted

🔒 Closed

This question is closed for comments. You're welcome to start a new topic if you have further comments on this issue.