summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/vhost/samples/getting-started/files/wsClient.html
blob: 402f30cdf8c3ec282eaa2688649f98d3ed069864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!--
    
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
    
    http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->

<!--
Simple html page that presents a form to post xml to a web service endpoint and display the response xml.
Copied from ServiceMix wsdl first example.
-->

<html>
<head>
<title>Tuscany Web service Sample Client</title>
<script type="text/javascript">

var urlToOpen = "http://localhost:8085/HelloworldComponent/Helloworld"; //default URL to open

function getHTTPObject() {
  var xmlhttp = false;

  /* Compilation conditionnelle d'IE */
  /*@cc_on
  @if (@_jscript_version >= 5)
     try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
        try {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
           xmlhttp = false;
        }
     }
  @else
     xmlhttp = false;
  @end @*/

  /* on essaie de cr�er l'objet si ce n'est pas d�j� fait */
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
     try {
        xmlhttp = new XMLHttpRequest();
     } catch (e) {
        xmlhttp = false;
     }
  }

  if (xmlhttp) {
     /* on d�finit ce qui doit se passer quand la page r�pondra */
     xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState == 4) { /* 4 : �tat "complete" */
           var response = document.getElementById("response");
           var responseStatus = "";
           try {
             responseStatus = xmlhttp.status + "";
           } catch (e) {
             responseStatus = "ERROR WHILE RETRIEVING STATUS; MAYBE UNABLE TO CONNECT.";
           }
           response.value = xmlhttp.responseText;
        }
     }
  }
  return xmlhttp;
}

function send() {
  if ((document.getElementById("urlToOpen").value != urlToOpen) && (document.getElementById("urlToOpen").value != "")) {
    //use user entry only if it at least can be okay
    urlToOpen = document.getElementById("urlToOpen").value;
  }  
  var xmlhttp = getHTTPObject();
  if (!xmlhttp) {
    alert('cound not create XMLHttpRequest object');
    return;
  }
  var request = document.getElementById("request");
  var response = document.getElementById("response");
  try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite");
  } catch (e) {
  }


  try {
    xmlhttp.open("POST", urlToOpen, true);
  } catch (e) {
    alert('error opening');
  }
  xmlhttp.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
  xmlhttp.send(request.value);
}

</script>
</head>

<body>

<h1>Tuscany Web service Sample Client</h1>

<p>Tuscany Web service Sample Client</p>

<p>Sends a request to a Web Service endpoint. (This requires JavaScript)</p> 
<p>Target: <input type="text" size="50" id="urlToOpen" value=""><script type="text/javascript">document.getElementById("urlToOpen").value = urlToOpen;</script>.</p>
  
<table>
  <tr>
    <td>
  <textarea id="request" style="width:600px;height:400px" ><?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:sayHello xmlns:ns="http://helloworld">
<ns:name>petra</ns:name>
</ns:sayHello>
</soapenv:Body>
</soapenv:Envelope>

  </textarea>
    </td>
    <td>
  <textarea id="response" style="width:600px;height:400px">
  </textarea>
    </td>
  </tr>
  <tr>
    <td colspan=2>
  <input type="button" value="Send" onClick="send();"/>
    </td>
  </tr>
</table>
</body>
</html>