在服务器上部署好TerraGate软件后,如何测试其InternetLicense服务是否正常呢?可以通过下面的代码来测试:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>TerraGate6.0 Internet License测试示例代码</title>
6 <meta name="netLicenseServer" content="http://192.168.14.83:8011" />
7 <script type = "text/javascript" language = "javascript">
8 function Test() {
9 try {
10 var SGWorld = CreateSGObj();
11 // if (SGWorld.Version.Type == "2") {
12 var location = SGWorld.Creator.CreateLocationHere();
13 var label1 = SGWorld.Creator.CreateTextLabel(location.Position, "Internet License运行正常", SGWorld.Creator.CreateLabelStyle());
14 label1.Style.FontSize = 30;
15 SGWorld.Creator.DeleteObject(location.ID);
16 // }
17 // else {
18 // alert("请确认客户端安装的是View!");
19 // }
20 }
21 catch (e) {
22 alert(e.message);
23 }
24 }
25
26 /*
27 功能: 创建sgworld对象
28 备注: 赵贺 2012.04.01.
29 */
30 function CreateSGObj() {
31 var obj = $("sgworld");
32 if (obj == null) {
33 obj = document.createElement('object');
34 document.body.appendChild(obj);
35 obj.name = "sgworld";
36 obj.id = "sgworld";
37 obj.classid = "CLSID:3a4f91b0-65a8-11d5-85c1-0001023952c1";
38 }
39 return obj;
40 }
41 function $(id) {
42 return window.document.getElementById(id);
43 }
44 </script>
45 </head>
46 <body>
47 <table>
48 <tr>
49 <td colspan="4">
50 <input id="Button1" type="button" value="测试" onclick="Test()" />
51 </td>
52 </tr>
53 <tr>
54 <td colspan="4">
55 </td>
56 </tr>
57 </table>
58 </body>
59 </html>
2
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>TerraGate6.0 Internet License测试示例代码</title>
6 <meta name="netLicenseServer" content="http://192.168.14.83:8011" />
7 <script type = "text/javascript" language = "javascript">
8 function Test() {
9 try {
10 var SGWorld = CreateSGObj();
11 // if (SGWorld.Version.Type == "2") {
12 var location = SGWorld.Creator.CreateLocationHere();
13 var label1 = SGWorld.Creator.CreateTextLabel(location.Position, "Internet License运行正常", SGWorld.Creator.CreateLabelStyle());
14 label1.Style.FontSize = 30;
15 SGWorld.Creator.DeleteObject(location.ID);
16 // }
17 // else {
18 // alert("请确认客户端安装的是View!");
19 // }
20 }
21 catch (e) {
22 alert(e.message);
23 }
24 }
25
26 /*
27 功能: 创建sgworld对象
28 备注: 赵贺 2012.04.01.
29 */
30 function CreateSGObj() {
31 var obj = $("sgworld");
32 if (obj == null) {
33 obj = document.createElement('object');
34 document.body.appendChild(obj);
35 obj.name = "sgworld";
36 obj.id = "sgworld";
37 obj.classid = "CLSID:3a4f91b0-65a8-11d5-85c1-0001023952c1";
38 }
39 return obj;
40 }
41 function $(id) {
42 return window.document.getElementById(id);
43 }
44 </script>
45 </head>
46 <body>
47 <table>
48 <tr>
49 <td colspan="4">
50 <input id="Button1" type="button" value="测试" onclick="Test()" />
51 </td>
52 </tr>
53 <tr>
54 <td colspan="4">
55 </td>
56 </tr>
57 </table>
58 </body>
59 </html>
测试的时候还需要注意以下几点:
1.测试页面要通过web服务器发布;
2.访问测试页面的客户端要安装TerraExplorer(view)软件;
3.执行测试前要运行TerraExplorer软件,并加载TerraGate发布的地形服务;
4.测试页面中<meta name="netLicenseServer" content="http://192.168.14.83:8011" />
后面的IP地址和端口号要改成实际测试TerraGate使用地址和端口号。