Jump to content

(another) possibly silly SOAP question...


MWareman

Recommended Posts

...or is it a Beta issue. Not sure yet.

 

I have a PHP script that mainly uses REST to connect to the ISY. However, I'm also obtaining the 'Description' 'Load' and 'Location' fields of objects via SOAP (since I cannot get these via REST apparently..).

 

This has been working fine - until sometime in the last few versions.. Now on 4.2.1 and it's definitely broken currently. I don't know if it's my code - or the ISY..

 

So this is what I'm doing. Using REST I'm retrieving the devices (http://$ISYuser:$ISYpassword@$ISYurl/rest/nodes).

 

I then loop thru the nodes, one at a time, and form a SOAP request - which I post to /services, extracting and parsing the XML returned to get the data I need:

 $SOAPreq = "";
 $SOAPreq .= $node_address;
 $SOAPreq .= "";
 $opts = array('http' => array( 'method'  => 'POST', 'header'  => 'Content-type: text/xml', 'content' => $SOAPreq ));
 $context  = stream_context_create($opts);
 $url = "http://$ISYuser:$ISYpassword@$ISYurl/services";
 $xml = simplexml_load_string(file_get_contents("http://$ISYuser:$ISYpassword@$ISYurl/services/", false, $context));
 $isLoad = $xml->isLoad;
 $location = $xml->location;
 $desc = $xml->description;

 

$ISYurl contains the IP address of the ISY, $ISYuser and $ISYpassword the user and password of the account to manage the ISY.

 

As mentioned - this was working not so long ago on 4.0.3. Now (4.2.1), I get:

 

Warning: file_get_contents(http://...@x.x.x.x/services/): failed to open stream: HTTP request failed! HTTP/1.1 404 OK in /var/www/api/refresh.php on line 80 Notice: Trying to get property of non-object in /var/www/api/refresh.php on line 81 Notice: Trying to get property of non-object in /var/www/api/refresh.php on line 82 Notice: Trying to get property of non-object in /var/www/api/refresh.php on line 83

 

Line 80 is the simplexml_load_string - so the request to /services is being rejected by ISY with a 404..

I have pointed my regular browser at http://ISY/services and get:

/services not found

 

Am I missing something?

 

Thanks,

 

Michael.

Link to comment
http://isy/services will always fail on a browser because GET is not supported on this URL

 

Well, that explains that one then...

 

As far as getting node properties, can you please do me a favor? Can you please use the Admin Console and let me know if it returns your properties for that node?

 

Not sure it's a worthwhile test to be honest - every node is failing when I try to get the properties with a SOAP formatted POST (my code loops thru all of them - and I get the exact same error for all nodes) - and all are working in the admin console.. Strange indeed.. Maybe I'm formatting the node incorrectly - or not escaping it properly.. The nodes I get from the REST interface appear to be a simple string in the format '11 31 DC 1'.

Link to comment
Is it at all possible to have the output of your SOAP request saved into a file and then pasted here? It must be something simple that my eyes didn't catch.

 

Michel, sure

 

9 4A EF 1

 

I wasn't able to capture the header (yet). If there is nothing obvious here I'll tcpdump it and capture a full packet from the wire - rather that capturing it within the php code that's generating it.

 

Michael.

Link to comment

Michel,

 

Here is a packet dump: (I obfuscated the actual URL and the basic auth header - but kept the byte counts matched by replacing with x's and 0's..)

 

tcpdump -s 0 -X host [ip.of.isy]

22:20:05.300192 IP linux.domain.com.33959 > isy.domain.com.http: Flags [s], seq 301973918, win 29200, options [mss 1460,sackOK,TS val 199734276 ecr 0], length 0
       0x0000:  4500 0038 759a 4000 4006 6ad4 ac14 0115  E..8u.@.@.j.....
       0x0010:  ac14 0114 84a7 0050 11ff c19e 0000 0000  .......P........
       0x0020:  9002 7210 5a7c 0000 0204 05b4 0402 080a  ..r.Z|..........
       0x0030:  0be7 b404 0000 0000                      ........
22:20:05.300686 IP isy.domain.com.http > linux.domain.com.33959: Flags [s.], seq 3358484315, ack 301973919, win 4644, options [mss 1460,sackOK,nop,eol], length 0
       0x0000:  4500 0030 ded9 0000 3c06 459d ac14 0114  E..0....<.E.....
       0x0010:  ac14 0115 0050 84a7 c82e 675b 11ff c19f  .....P....g[....
       0x0020:  7012 1224 8e7a 0000 0204 05b4 0402 0100  p..$.z..........
22:20:05.300727 IP linux.domain.com.33959 > isy.domain.com.http: Flags [.], ack 1, win 29200, length 0
       0x0000:  4500 0028 759b 4000 4006 6ae3 ac14 0115  E..(u.@.@.j.....
       0x0010:  ac14 0114 84a7 0050 11ff c19f c82e 675c  .......P......g\
       0x0020:  5010 7210 5a6c 0000                      P.r.Zl..
22:20:05.300793 IP linux.domain.com.33959 > isy.domain.com.http: Flags [P.], seq 1:26, ack 1, win 29200, length 25
       0x0000:  4500 0041 759c 4000 4006 6ac9 ac14 0115  E..Au.@.@.j.....
       0x0010:  ac14 0114 84a7 0050 11ff c19f c82e 675c  .......P......g\
       0x0020:  5018 7210 5a85 0000 504f 5354 202f 7365  P.r.Z...POST./se
       0x0030:  7276 6963 6573 2048 5454 502f 312e 300d  rvices.HTTP/1.0.
       0x0040:  0a                                       .
22:20:05.301569 IP isy.domain.com.http > linux.domain.com.33959: Flags [.], ack 26, win 4619, length 0
       0x0000:  4500 0028 deda 0000 3c06 45a4 ac14 0114  E..(....<.E.....
       0x0010:  ac14 0115 0050 84a7 c82e 675c 11ff c1b8  .....P....g\....
       0x0020:  5010 120b bb3d 0000 0000 0000 0000       P....=........
22:20:05.301594 IP linux.domain.com.33959 > isy.domain.com.http: Flags [P.], seq 26:302, ack 1, win 29200, length 276
       0x0000:  4500 013c 759d 4000 4006 69cd ac14 0115  E..        0x0010:  ac14 0114 84a7 0050 11ff c1b8 c82e 675c  .......P......g\
       0x0020:  5018 7210 5b80 0000 4175 7468 6f72 697a  P.r.[...Authoriz
       0x0030:  6174 696f 6e3a 2042 6173 6963 2000 0000  ation:.Basic.xxx
       0x0040:  0000 0000 0000 0000 0000 0000 0000 0000  xxxxxxxxxxxxxxxx
       0x0050:  0000 0000 000d 0a48 6f73 743a 2069 7379  xxxxx..Host:.isy
       0x0060:  2e00 0000 0000 0000 0000 0000 0000 2e63  .xxxxxxxxxxxxx.c
       0x0070:  6f6d 0d0a 436f 6e74 656e 742d 4c65 6e67  om..Content-Leng
       0x0080:  7468 3a20 3135 330d 0a43 6f6e 7465 6e74  th:.153..Content
       0x0090:  2d74 7970 653a 2074 6578 742f 786d 6c0d  -type:.text/xml.
       0x00a0:  0a0d 0a3c 733a 456e 7665 6c6f 7065 3e3c  ...<
       0x00b0:  733a 426f 6479 3e3c 753a 4765 744e 6f64  s:Body>        0x00c0:  6550 726f 7073 2078 6d6c 6e73 3a75 3d22  eProps.xmlns:u="
       0x00d0:  7572 6e3a 7564 692d 636f 6d3a 7365 7276  urn:udi-com:serv
       0x00e0:  6963 653a 585f 496e 7374 656f 6e5f 4c69  ice:X_Insteon_Li
       0x00f0:  6768 7469 6e67 5f53 6572 7669 6365 3a31  ghting_Service:1
       0x0100:  223e 3c69 643e 3131 2033 3120 4443 2031  ">11.31.DC.1
       0x0110:  3c2f 6964 3e3c 2f75 3a47 6574 4e6f 6465  
       0x0120:  5072 6f70 733e 3c2f 733a 426f 6479 3e3c  Props><
       0x0130:  2f73 3a45 6e76 656c 6f70 653e            /s:Envelope>
22:20:05.302007 IP isy.domain.com.http > linux.domain.com.33959: Flags [.], ack 302, win 4343, length 0
       0x0000:  4500 0028 dedb 0000 3c06 45a3 ac14 0114  E..(....<.E.....
       0x0010:  ac14 0115 0050 84a7 c82e 675c 11ff c2cc  .....P....g\....
       0x0020:  5010 10f7 bb3d 0000 0000 0000 0000       P....=........
22:20:05.389336 IP isy.domain.com.http > linux.domain.com.33959: Flags [P.], seq 1:91, ack 302, win 4343, length 90
       0x0000:  4500 0082 dedd 0000 3c06 4547 ac14 0114  E.......<.EG....
       0x0010:  ac14 0115 0050 84a7 c82e 675c 11ff c2cc  .....P....g\....
       0x0020:  5018 10f7 6d2c 0000 4854 5450 2f31 2e31  P...m,..HTTP/1.1
       0x0030:  2034 3034 204f 4b0d 0a43 6f6e 7465 6e74  .404.OK..Content
       0x0040:  2d4c 656e 6774 683a 2039 300d 0a43 6f6e  -Length:.90..Con
       0x0050:  6e65 6374 696f 6e3a 204b 6565 702d 416c  nection:.Keep-Al
       0x0060:  6976 650d 0a43 6f6e 7465 6e74 2d54 7970  ive..Content-Typ
       0x0070:  653a 2074 6578 742f 6874 6d6c 0d0a 0d0a  e:.text/html....
       0x0080:  0d0a                                     ..
22:20:05.389357 IP linux.domain.com.33959 > isy.domain.com.http: Flags [.], ack 91, win 29200, length 0
       0x0000:  4500 0028 759e 4000 4006 6ae0 ac14 0115  E..(u.@.@.j.....
       0x0010:  ac14 0114 84a7 0050 11ff c2cc c82e 67b6  .......P......g.
       0x0020:  5010 7210 5a6c 0000                      P.r.Zl..
22:20:05.389445 IP linux.domain.com.33959 > isy.domain.com.http: Flags [F.], seq 302, ack 91, win 29200, length 0
       0x0000:  4500 0028 759f 4000 4006 6adf ac14 0115  E..(u.@.@.j.....
       0x0010:  ac14 0114 84a7 0050 11ff c2cc c82e 67b6  .......P......g.
       0x0020:  5011 7210 5a6c 0000                      P.r.Zl..
22:20:05.389915 IP isy.domain.com.http > linux.domain.com.33959: Flags [.], ack 303, win 4342, length 0
       0x0000:  4500 0028 dede 0000 3c06 45a0 ac14 0114  E..(....<.E.....
       0x0010:  ac14 0115 0050 84a7 c82e 67b6 11ff c2cd  .....P....g.....
       0x0020:  5010 10f6 bae3 0000 0000 0000 0000       P.............
22:20:05.396763 IP isy.domain.com.http > linux.domain.com.33959: Flags [F.], seq 91, ack 303, win 4342, length 0
       0x0000:  4500 0028 dedf 0000 3c06 459f ac14 0114  E..(....<.E.....
       0x0010:  ac14 0115 0050 84a7 c82e 67b6 11ff c2cd  .....P....g.....
       0x0020:  5011 10f6 bae2 0000 0000 0000 0000       P.............
22:20:05.396791 IP linux.domain.com.33959 > isy.domain.com.http: Flags [.], ack 92, win 29200, length 0
       0x0000:  4500 0028 0000 4000 4006 e07e ac14 0115  E..(..@.@..~....
       0x0010:  ac14 0114 84a7 0050 11ff c2cd c82e 67b7  .......P......g.
       0x0020:  5010 7210 59c8 0000                      P.r.Y...

 

In 22:20:05.302007, the ISY ACK's the SOAP POST to /services, then replies (22:20:05.389336) with a 404. Not sure why ISY is 404'ng this... but it seems to be an issue somewhere...

 

This is the PHP code I used that produced this tcpdump (you should be able to put this into a .php file on a PHP enabled server and replace the variables at the top):

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);
ob_end_flush();

$ISYuser = "isy_username";
$ISYpassword = "isy_password";
$ISYurl = "isy.domain.com";
$node_address = "11 31 DC 1";
$node_name = "Master BR Light";

echo "Getting advanced node properties from ISY.
\n";
echo "Getting details for: $node_address ($node_name)
\n";
$SOAPreq = "";
$SOAPreq .= $node_address;
$SOAPreq .= "";
$opts = array('http' => array( 'method'  => 'POST', 'header'  => 'Content-type: text/xml', 'content' => $SOAPreq ));
$context  = stream_context_create($opts);
$url = "http://$ISYuser:$ISYpassword@$ISYurl/services";
echo "POST URL: $url
\n";
$xml = simplexml_load_string(file_get_contents("http://$ISYuser:$ISYpassword@$ISYurl/services", false, $context));
$isLoad = $xml->isLoad;
$location = $xml->location;
$desc = $xml->description;
echo "$SOAPreq
\n";
echo "$desc
\n";

echo "
\n";
echo "Reached end!";
?>

 

As you can see - I don't calculate content length in code - the stack does this for me (and is likely to be correct I suspect..)

 

The HTML the browser sees from this:


Getting advanced node properties from ISY.

Getting details for: 11 31 DC 1 (Master BR Light)

POST URL: http://isy_username:isy_password@isy.domain.com/services


Warning: file_get_contents(http://...@isy.domain.com/services): failed to open stream: HTTP request failed! HTTP/1.1 404 OK
in /var/www/api/test.php on line 21

Notice: Trying to get property of non-object in /var/www/api/test.php on line 22

Notice: Trying to get property of non-object in /var/www/api/test.php on line 23

Notice: Trying to get property of non-object in /var/www/api/test.php on line 24
11 31 DC 1





Reached end!

Link to comment

Hi Michael,

 

Thanks so very much. Just went through our code:

1. If the id is null or ISY cannot find the node with that id, you would get 500

2. The only time you would get 404 is if there's really no properties file for that node

 

So, the main question again is whether or not the Admin Console actually returns the properties for that specific node.

 

With kind regards,

Michel

Link to comment
Hi Michael,

 

Thank you. Can you please try the without the '.' ? i.e.

11.31.DC.1 to

11 31 DC 1

 

With kind regards,

Michel

 

Everything is already sent without a '.'. The '.' in the tcpdump represents an 'unprintable' character - you have to look at the hex code on the left. In this case it's ACSII code 20 - a space.

 

Do you want me to try it with a '.'?

 

Thanks,

 

Michael.

Link to comment

Michel,

 

I'll get the log to you in email (it's pretty small).

 

I wanted to post what I saw. I ran the exact program posted in this thread (the single node version) - and each time it runs I get this is the log:

 

[FileOpen ] Open failed for [CONF/47.PRP] ®

 

Do you know what this means?

 

Thanks,

 

Michael.

Link to comment

Mystery Solved...

 

I edited the node in question - went to 'Notes' and entered something in the 'Location' string. Now - I don't get the 404 - for that device.

 

I realize that the properties file does not exist unless there are properties to store - but it seems really odd that ISY would return 404 to a request for properties like that.

 

Is there any way ISY could simply 200 the request - and return XML indicating that the properties are empty? It certainly used to work that way..

 

Michael.

Link to comment

Michel,

 

The more I think about it, the more I feel 404 is the correct response. I'm asking for properties, and if none are defined they don't exist. 404 'seems' correct.

 

I should be checking that in the code though - and its certainly a change in behavior at some point. ISY used to return XML, just with empty strings. Now it returns 404.

 

So that I don't have to change the code again, is this current behavior the design - or a feature that will be rectified in a future version?

 

Thanks for all your help, it helped me get to the root of what seemed to me like a very strange issue.

 

Michael.

Link to comment

Sounds perfect - thanks!

 

For the time being, I'm going to change my code to check for 404, and just instance zero byte variables so that the rest of my code simply sees these as empty values, as it was doing before. That way it will keep functioning g for now and if you change the response in the future it will keep on working.

 

Thank you very much for working thru this with me!

 

Michael.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...