How to send SOAP messages ?


#1

Hello!
How to send SOAP messages on the R1 PAC controller?

Regards
zhhpei


#2

Hello zhhpei,

To send a SOAP message you can either use a TCP comm handle or do an HTTPGet or HttpPost command (all of the related commands in PAC Control are in the “communications” category). This is easiest if you have an exact tcp SOAP message you want to construct, for example, one you captured using Wireshark or some similar tool.

That the method we used in this WEMO example, for example, which received packets back from the WEMO device that looked like this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
<u:GetInsightParamsResponse xmlns:u="urn:Belkin:service:metainfo:1">
<InsightParams>0|1399398226|0|0|0|5551|0|0|0|-600|8000</InsightParams>
</u:GetInsightParamsResponse>
</s:Body> </s:Envelope>

What kind of SOAP packets to you need to send/receive? Will this be done using HTTP or HTTPS or either?

-OptoMary


#3

Hi mstjohn

Thanks for the reply! In order to achieve the PTZ function of the network camera, the network camera supports ONVIF protocol. I saw a part of the ONVIF protocol.It’s too complicated to understand. I just need PTZ control. I just know the R1 controller needs to send SOAP messages to the camera.But I don’t know what the SOAP message is. Can you help me?
Protocol file is ONVIF-PTZ-Service-Spec-v221.pdf。

Thanks.
zhhpei


#4

I’ve used Web Service Studio https://webservicestudio.codeplex.com/ to get the information I needed to call web services from a PAC-S. You should be able to put in the camera’s web service end point and discover the different methods available and then play with it from there. Then copy the Request text out and use it in your PAC.


Soap?
#5

Cool, philip! That looks like I handy tool.

I also find [U][B]this pdf, a programmers guide[/B][/U], which shows a bunch of SOAP REQUEST and SOAP RESPONSE examples in appendix B. On page 157 I find the example I’d try, which is for the command: GotoPreset. (In some camera demos we’ve done here, we found camera control easier to do by setting [I]several presets[/I] using the camera’s user interface, then having buttons in groov or whatever HMI, to go to those various previously configured presets.)

B.5.4.3 GotoPreset
SOAP REQUEST:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
 xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl">
 <soap:Body>
 <tptz:GotoPreset>
 <tptz:ProfileToken>Profile1</tptz:ProfileToken>
 <tptz:PresetToken>Preset1</tptz:PresetToken>
 </tptz:GotoPreset>
 </soap:Body>
</soap:Envelope> 

SOAP RESPONSE – on success

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
 xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl">
 <SOAP-ENV:Body>
 <tptz:GotoPresetResponse>
 </tptz:GotoPresetResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope> 


#6

<?xml version=“1.0” encoding=“utf-8”?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:tptz=“http://www.onvif.org/ver20/ptz/wsdl”>
<soap:Body>
<tptz:GotoPreset>
<tptz:ProfileToken>Profile1</tptz:ProfileToken>
<tptz:PresetToken>Preset1</tptz:PresetToken>
</tptz:GotoPreset>
</soap:Body>
</soap:Envelope>

Thank you
I have read this PDF document, and now I know the above message is the GotoPreset command.
Excuse me. Does R1 need to build a TCP connection before sending the SOAP message? What command is used to establish a connection?
Is the Outgoing Communication Open command?
The first step is to use Outgoing Communication Open to establish a connection, the second step to send the above SOAP message。
Right?


#7

That is one way of doing it, the other is to use the HttpPost or HttpGet commands, which will also add the required HTTP header information for you; and gives the option of using HTTPS vs. just un-secure HTTP.

Do you know if your device requires HTTP[B]S[/B]? Do you have other software you can run on your PC to do these same commands and sniff/capture the commands that work to test your camera and make sure you have the SOAP code you need? (Perhaps the software that philip mentioned above?)


#8

I now know that using the R1 PAC control network camera can be achieved.First, will be tested on the PC with your instructions… Do you know who has done this R1 PAC control network camera PTZ test?Thank you very much!


#9

I found some onvif cameras on our network. (Unfortunately none of them had PTZ.) But I did get them to respond to some SOAP packets I built in OptoScript. Here’s an example:

sHostname = "10.192.0.115"; // IP address of the camera
nPort = 888;                // port 80 is more typical
sURLPath = "/onvif/device_service";

//stPostHeader[0] = "POST /onvif/device_service HTTP/1.1"; // this part of the tcp packet is added by the call the HttpPostFromStringTable, not needed in header
stPostHeader[0] = "Content-Type: application/soap+xml; charset=utf-8; action=" + chr('"') + "http://www.onvif.org/ver10/device/wsdl/GetCapabilities" + chr('"');
stPostHeader[1] = "Content-Length: 297";  // this will get overwritten by a call to HttpPostCalcContentLength
stPostHeader[2] = "Accept-Encoding: gzip, deflate";
stPostHeader[3] = "Connection: Close";

// Now create the soap packet for the content of the HttpPost:
stPostContent[0] = "<?xml version=" + chr('"') + "1.0" + chr('"') + " encoding=" + chr('"') + "UTF-8" + chr('"') + "?>" +
 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=" + chr('"') + "http://www.w3.org/2003/05/soap-envelope" + chr('"') + " xmlns:tds=" + chr('"') + 
 "http://www.onvif.org/ver10/device/wsdl" + chr('"') + ">" +
 "<SOAP-ENV:Body>" +
 "<tds:GetDeviceInformation/>" +
 "</SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope> ";
 
// Calculate the length of the content we're sending
nHTTPResult = HttpPostCalcContentLength(/*Post Content*/stPostContent, /*Post Header*/stPostHeader, /*Length Index*/1);

// Do the post -- if all goes ok this returns a 0 and some soap in the stResponseContent string table
nHTTPPostResult = HttpPostFromStringTable( stResponseContent, stResponseHeader, stPostContent, stPostHeader, nSecuritMode, sURLPath, nHTTPResult, nPort, sHostname );



Here’s what the preset command looked like: Same code as above, but the stPostContent[0] had that command we discussed earlier:



// PAN/TILT - go to a particular preset
stPostContent[0] = "<?xml version=" + chr('"') + "1.0" + chr('"') + " encoding=" + chr('"') + "utf-8" + chr('"') + "?>" + 
 "<soap:Envelope xmlns:soap=" + chr('"') + "http://www.w3.org/2003/05/soap-envelope" + chr('"') + " xmlns:tptz=" + chr('"') + "http://www.onvif.org/ver20/ptz/wsdl" + chr('"') + ">" + 
 "<soap:Body><tptz:GotoPreset>" + 
 "<tptz:ProfileToken>Profile1</tptz:ProfileToken>" +
 "<tptz:PresetToken>Preset1</tptz:PresetToken>" +
 "</tptz:GotoPreset>" +
 "</soap:Body>" +
 "</soap:Envelope>";


See pictures below for the response that came back on the GetDeviceInformation command, showing what Model of FOSCAM camera the R1 talked to


… and the SOAP error message for the preset that wasn’t going to work w/out a PTZ camera:


I hope that helps!


#10

Very well, that’s what I want.
Thank you very much for your help and guidance!
Also thanks to the help of friends in this forum.


#11

This problem has been solved. I am very happy. Thank you very much。
At the same time, I wish you a happy holiday!