Reputation: 43
I'm looking for help with a php soapclient call:
The call is to a remote panel and I want to pull off the log data. There are various services published via the WSDL and I am able to use several with no issues. Here's the list:
array(12) {
[0]=> string(77) "GetGPTimerChannelsResponse GetGPTimerChannels(GetGPTimerChannels $parameters)"
[1]=> string(74) "GetGPTimerChannelResponse GetGPTimerChannel(GetGPTimerChannel $parameters)"
[2]=> string(74) "SetGPTimerChannelResponse SetGPTimerChannel(SetGPTimerChannel $parameters)"
[3]=> string(47) "GetSlaveResponse GetSlave(GetSlave $parameters)"
[4]=> string(71) "GetLogDataInlineResponse GetLogDataInline(GetLogDataInline $parameters)"
[5]=> string(71) "GetLogItemInlineResponse GetLogItemInline(GetLogItemInline $parameters)"
[6]=> string(59) "GetAlarmListResponse GetAlarmList(GetAlarmList $parameters)"
[7]=> string(50) "GetSyslogResponse GetSyslog(GetSyslog $parameters)"
[8]=> string(47) "SetSlaveResponse SetSlave(SetSlave $parameters)"
[9]=> string(53) "GetVersionResponse GetVersion(GetVersion $parameters)"
[10]=> string(53) "GetTDBInfoResponse GetTDBInfo(GetTDBInfo $parameters)"
[11]=> string(53) "GetLogItemResponse GetLogItem(GetLogItem $parameters)" }
I am trying to use the GetLogDataInline service which requires four parameters - these I'm passing as an array and all seems OK when doing the connection (the request/response takes around 30 seconds to process).
When I look at a var_dump / print_r of the result, it returns NULL, whereas when I do a call to the __getLastResponse all of the data I need to populate my local database is there.
Below is the code for the soapclient call:
$client = new soapclient ("http://192.168.1.126/cgi-bin/cgi.cgi?WSDL",
array("trace" => 1,
"exceptions" => true,
"cache_wsdl" => WSDL_CACHE_NONE,
"features" => SOAP_SINGLE_ELEMENT_ARRAYS
));
$params = array (
"ResponseType" => "Xml",
"Step" => 15,
"Start" => "2012-06-14T12:00:00+01:00",
"End" => "2012-06-14T23:59:45+01:00"
);
$result = $client -> GetLogDataInline ($params);
An extract from the var_dump / __getLastResponse is:
var_dump($client)
object(SoapClient)#1 (4) { ["trace"]=> int(1) ["_features"]=> int(1) ["_soap_version"]=> int(1) ["sdl"]=> resource(4) of type (Unknown) }
var_dump($result)
NULL
__getLastResponse
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body> <GetLogDataResponse xmlns="http://url/RDMPlantTDB/2009/03/13/">
<GetLogDataResult>
<Step>15</Step>
<Start>2012-06-14T12:00:00+01:00</Start>
<End>2012-06-14T23:59:45+01:00</End>
<LogData>
<![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Fields> <Field>External Temperature</Field> <Field>Workshop Lux Level</Field> <Field>Electricity Pulse 100wh</Field> <Field>Workshop PIR Active</Field> <Field>Boiler Flow Temp</Field> <Field>Outside Lux</Field> <Field>Workshop_Light_Override_Hours</Field> <Field>Water Consumption (Litres)</Field> <Field>Electricity kWh Consumption</Field> <Field>Water Consumption M3</Field> <Field>Gas kWh Consumption</Field> <Field>Outside Lighting</Field> <Field>Heating Effective Setpoint</Field> <Field>Router Reset</Field> <Field>Workshop Lighting State</Field> <Field>Heating Run Hours</Field> <Field>Heating On</Field> <Field>Receptin Percent RH</Field> <Field>Reception Temp</Field> <Field>Reception RH</Field> <Field>Reception Temp</Field> </Fields>
<Entries> <Entry> <Time>2012-06-14T12:00:00+01:00</Time> <Values> <Value>-85.6</Value> <Value>2.1</Value> <Value>-1.0</Value> <Value>Off</Value> <Value>-91.5</Value> <Value>13.8</Value> <Value>0.0</Value> <Value>-1.0</Value> <Value>0.0</Value> <Value>0.0</Value> <Value>-0.1</Value> <Value>Off</Value> <Value>21.0</Value> <Value>Off</Value> <Value>Off</Value> <Value>0.0</Value> <Value>Off</Value> <Value>53.0</Value> <Value>22.0</Value> <Value>53.0</Value> <Value>22.0</Value> </Values> </Entry> <Entry> <Time>2012-06-14T12:00:15+01:00</Time> <Values> <Value>-85.4</Value> <Value>2.1</Value> <Value>-1.0</Value> <Value>Off</Value> <Value>-91.8</Value> <Value>13.8</Value> <Value>0.0</Value> <Value>-1.0</Value> <Value>0.0</Value> <Value>0.0</Value> <Value>-0.1</Value> <Value>Off</Value> <Value>21.0</Value> <Value>Off</Value> <Value>Off</Value> <Value>0.0</Value> <Value>Off</Value> <Value>53.0</Value> <Value>22.0</Value> <Value>53.0</Value> <Value>22.0</Value> </Values> </Entry> <Entry> <Time>2012-06-14T12:00:30+01:00</Time> <Values> <Value>-85.4</Value> <Value>2.1</Value> <Value>-1.0</Value> <Value>Off</Value> <Value>-91.8</Value> <Value>13.8</Value> <Value>0.0</Value> <Value>-1.0</Value> <Value>0.0</Value> <Value>0.0</Value> <Value>-0.1</Value> <Value>Off</Value> <Value>21.0</Value> <Value>Off</Value> <Value>Off</Value> <Value>0.0</Value> <Value>Off</Value> <Value>53.0</Value> <Value>22.0</Value> <Value>53.0</Value> <Value>22.0</Value> </Values> </Entry> <Entry> <Time>2012-06-14T12:00:45+01:00</Time> <Values> <Value>-85.4</Value> <Value>2.1</Value> <Value>-1.0</Value> <Value>Off</Value> <Value>-91.5</Value> <Value>13.7</Value> <Value>0.0</Value> <Value>-1.0</Value> <Value>0.0</Value> <Value>0.0</Value> <Value>-0.1</Value> <Value>Off</Value> <Value>21.0</Value> <Value>Off</Value> <Value>Off</Value> <Value>0.0</Value> <Value>Off</Value> <Value>54.0</Value> <Value>22.0</Value> <Value>54.0</Value> <Value>22.0</Value> </Values> </Entry> <Entry>
Upvotes: 2
Views: 5260
Reputation: 1
if your web services has enabled access permissions, then | new SoapClient - First question? Use public IP public or DNS | $result = $client -> Method($params); - Second question? use private IP, depends on the configuration of DNS
$client->__setLocation('http:// youDNSorIPpublic /cgi-bin/cgi.cgi');
var_dump($client);
//$old_location = $client->__setLocation(); // disable location //echo $old_location;
$result = $client -> Method($params); //new request
Upvotes: 0
Reputation: 41
PHP soapClient doesn't support relative namespaces within SOAP very well, this is usually the cause of this behavior.
Upvotes: 0
Reputation: 9165
Not sure why are you getting NULL but i always use the below method for SOAP client to handle errors (if any).
// Calling soap
try{
// Creating soap server object
$client = new SoapClient("http://192.168.1.126/cgi-bin/cgi.cgi?WSDL");
// Creating parameters
$params = array (
"ResponseType" => "Xml",
"Step" => 15,
"Start" => "2012-06-14T12:00:00+01:00",
"End" => "2012-06-14T23:59:45+01:00"
);
// Calling createUser method
$result = $client->__soapCall('METHOD_NAME',$params);
// Check for a fault
if (is_soap_fault($client)) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
}else{
echo "Result: <BR><pre>";
print_r($result);
echo '</pre>';
}
}catch(SoapFault $fault){
$error = "SOAP Fault: (faultcode: {$fault->faultcode}\n" ."faultstring: {$fault->faultstring})";
echo $error;
}catch(Exception $exception){
$error = $exception;
echo "<BR>".$error;
}
In the above example you will have to replace the METHOD_NAME with actual method defined in the soap server to take parameters and return result. But i suspect on the first parameter "ResponseType", is that the actual first parameter expected by the method that handles request?
You can try running above code and see what error occur
I assume that SOAP extension is enabled at the server.
Upvotes: 1