2. Hello World应用
Hello world程序
在完成快速配置后,我们就可以实现一个类似Hello World的实例。
第一步:建立一个文本文件,复制如下内容,另存为helloword.html文件。
<html>
<body>
<form method=POST action=http://OM设备IP地址/xml enctype="multipart/form-data">
<textarea rows="10" cols="80" name="XML_POST">
</textarea><br>
<input type=SUBMIT value='提交'>
</form>
</body>
</html>
注意:将其中OM设备IP地址修改为实际能ping通的地址。
第二步:用浏览器方式打开helloword.html,出现如下图所示页面:
第三步:复制如下内容粘贴到页面文本框中,点击“提交”。
<?xml version="1.0" encoding="utf-8" ?>
<Control attribute="Query">
<DeviceInfo/>
</Control>
成功页面返回,如:
<DeviceInfo>
<manufacturer>New Rock Technologies, Inc</manufacturer>
<model>Rev 1.0.1 WROC2000-1S/1</model>
<version>Rev 2.1.5.85.10</version>
<devices>
<ext lineid="Phone 1" id="216"/>
<ext lineid="IPPhone 5" id="200"/>
<ext lineid="IPPhone 6" id="201"/>
<ext lineid="IPPhone 7" id="202"/>
<ext lineid="IPPhone 8" id="203"/>
<line lineid="Line 2" id="217"/>
<line lineid="IPLine 21" id="238"/>
<group id="10">
<ext id="216"/>
</group>
</devices>
表示helloword执行成功,返回设备信息。
若执行失败,页面返回<unauthorized/>或无响应等。
如何实现
关于OM API的类似Hello World程序是如何编程实现的,将在第3章为你揭开其内部实现的原理和机制。