Page 1 of 2
Help with XML in variable please.
Posted: Thu May 09, 2013 7:22 pm
by drolaz
Hello Group,
I am trying to send fixed XML/CGI to a webcam but am having no luck. I have researched the web for two days but no go.
Maybe some of you could be kind enough to point me in the right direction.
This is my HTML version which works fine:
<form action="
http://10.0.27.232/cgi-bin/devconfig.cgi" method="post">
<input type="hidden" name="xmlMessage" value='<?xmlversion="1.0"?><DeviceRequest><Action>GET</Action><Authenticate><Username>admin</Username><Password>password</Password></Authenticate></DeviceRequest>'/>
<input type="submit" value="Send Get DeviceConfig XML" />
</form>
So in its basic form I want to do this:
on mouseUp
put "<?xmlversion="1.0"?><DeviceRequest><Action>GET</Action><Authenticate><Username>admin</Username><Password>password</Password></Authenticate>
</DeviceRequest>" into StartProcess
Post StartProcess to URL "
http://10.0.27.193/cgi-bin/devconfig.cgi"
put it into tFormResults
end mouseUp
But my device responds with incorrect XML data.
Now from research it seems that my <> and "" are getting wrecked, what would be the easiest (least amount of lines) to push this variable with the data in-tacked?
Reason being is once this one works I have a ton of other buttons to add.
I have tried:
set the htmltext of tFormResults to uniDecode( uniEncode( tFormResults, "UTF8" ) )
but hat is just kicking errors.
Thanks ahead of time for any help.
Al
Re: Help with XML in variable please.
Posted: Thu May 09, 2013 10:41 pm
by Mark
Hi,
The server doesn't understand which parameter you are sending the data for and the URL is not urlEncoded. You need this:
Code: Select all
put "xmlMessage=" & urlEncode("<?xmlversion=" & quote &"1.0" & quote & "?><DeviceRequest><Action>GET</Action>" & \
"<Authenticate><Username>admin</Username><Password>password</Password></Authenticate>" & \
"</DeviceRequest>") into StartProcess
I don't know if this will make it work, but it solves at least two problems.
Kind regards,
Mark
Re: Help with XML in variable please.
Posted: Fri May 10, 2013 8:05 pm
by drolaz
Mark,
Worked like a charm!
Your the best thank you!
Al
Re: Help with XML in variable please.
Posted: Fri May 10, 2013 8:20 pm
by Simon
I'm going to post a tool I made here because I think it helps with converting to "& quote &":
It's just a simple tool to replace quotes and line breaks.
Hope it's self explanatory.
Oh, and nothing about urlEncode in it.
Simon
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 4:33 pm
by drolaz
Mark and Simon,
A new issue has a appeared and I am scratching my head as I have used this in other builds.
The below works fine:
Post TwoZoom to URL "
http://192.168.1.5/cgi-bin/devconfig.cgi"
but if I try to:
Post TwoZoom to URL "http://[[IpAddress]]/cgi-bin/devconfig.cgi"
I get no results....
As before thank you in advance for any help.
Mouseup below that works..
------------------------------------------
on mouseUp
put field "ipaddress" into IpAddress
put "xmlMessage=" & urlEncode("<?xmlversion=" & quote &"1.0" & quote & "?><DeviceRequest><Action>SETFOCUSMODE</Action>" & \
"<Authenticate><Username>admin</Username><Password>password</Password></Authenticate>" & \
"<Mode>THREE_ZOOM</Mode></DeviceRequest>") into TwoZoom
Post TwoZoom to URL "
http://192.168.1.5/cgi-bin/devconfig.cgi"
put it into tFormResults
end mouseUp
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 4:57 pm
by Mark
Hi,
Could you tell more about what you're trying to do? Why would you write something like [[IpAdressess]]?
Best,
Mark
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 5:04 pm
by drolaz
The "IpAddress" is the Ip address manually added to a field by the user.
The XML that is to be sent works on multiple devices (cameras my company makes).
This app will be sending this data to different devices based on the address entered by the user.
I will have multiple buttons with different functions based on the same mouseup shown earlier.
Did that help?
Al
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 5:05 pm
by drolaz
I have used this before and it worked:
on mouseUp
put field "ipaddress" into IpAddress
#answer "Video feed will begin shortly..Press OK to continue.."
put field "ipaddress" into IpAddress
put "rtsp://[[IpAddress]]:8554/main" into MainPath
launch merge (MainPath) with "c:/ff/bin/ffplay.exe"
end mouseUp
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 5:13 pm
by Mark
Hi,
It looks like your syntax should be
Code: Select all
Post TwoZoom to URL merge("http://[[IpAddress]]/cgi-bin/devconfig.cgi")
Kind regards,
Mark
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 5:56 pm
by drolaz
Bummer....
Didn't work any other thoughts?
Im still trying different variations...
Thanks
Al
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 6:24 pm
by Mark
Hi Al,
Could you post the entire script up to the line containing the merge function?
Best,
Mark
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 6:36 pm
by drolaz
Below is the original working version, below that is the variation you suggested:
on mouseUp
put field "ipaddy" into IpAddress
put "xmlMessage=" & urlEncode("<?xmlversion=" & quote &"1.0" & quote & "?><DeviceRequest><Action>SETFOCUSMODE</Action>" & \
"<Authenticate><Username>admin</Username><Password>password</Password></Authenticate>" & \
"<Mode>THREE_ZOOM</Mode></DeviceRequest>") into ThreeZoom
Post ThreeZoom to URL "
http://192.168.1.5/cgi-bin/devconfig.cgi"
put it into tFormResults
end mouseUp
as suggested but not responding:
on mouseUp
put field "ipaddy" into IpAddress
put "xmlMessage=" & urlEncode("<?xmlversion=" & quote &"1.0" & quote & "?><DeviceRequest><Action>SETFOCUSMODE</Action>" & \
"<Authenticate><Username>admin</Username><Password>password</Password></Authenticate>" & \
"<Mode>THREE_ZOOM</Mode></DeviceRequest>") into ThreeZoom
Post ThreeZoom to URL merge("http://[[IpAddress]]/cgi-bin/devconfig.cgi")
put it into tFormResults
end mouseUp
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 6:54 pm
by Mark
Hi,
What happens if you execute this script?
Code: Select all
on mouseUp
put field "ipaddy" into IpAddress
put "xmlMessage=" & urlEncode("<?xmlversion=" & quote &"1.0" & quote & "?><DeviceRequest><Action>SETFOCUSMODE</Action>" & \
"<Authenticate><Username>admin</Username><Password>password</Password></Authenticate>" & \
"<Mode>THREE_ZOOM</Mode></DeviceRequest>") into ThreeZoom
put merge("http://[[IpAddress]]/cgi-bin/devconfig.cgi") into myUrl
post ThreeZoom to URL myUrl
put the result into rslt
if rslt is empty then
put it into tFormResults
else
beep
answer error rslt
end if
end mouseUp
Do you get an error message?
Best,
Mark
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 7:06 pm
by drolaz
It reports back "invalid host Address"
but if i swap the [[IpAddress]] in the merge line with the actual address it works.
Re: Help with XML in variable please.
Posted: Tue May 14, 2013 7:12 pm
by Mark
Hi,
What happens if you don't use the field but replace the first line with something like
Code: Select all
put field "123.45.67.89" into IpAddress
Best,
Mark