|
Page Edited :
SM :
4.07. Testing of service
4.07. Testing of service has been edited by Hans Couder (Feb 05, 2009). Change summary: change of namespace tns: to http://servicemix.apache.org/examples/types Testing the webserviceOn this page, we are going to test our webservice.. Creating the test pageHere is a test HTML page. test.html <!--
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.--> <!-- $Rev: 593004 $ $Date: 2007-11-07 23:04:54 -0500 (Wed, 07 Nov 2007) $ --> <html> <head> <title>ServiceMix WSDL-First Example</title> <script type="text/_javascript_"> var urlToOpen = "http://localhost:8193/HelloService/"; //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. { 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 = "STATUS: " + responseStatus + "\n" + 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.send(request.value); } </script> </head> <body> <h1>ServiceMix CXF example</h1> <p>Welcome to the CXF example for ServiceMix</p> <p>Perform a POST into the HTTP binding. 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" class="code-quote">"send();"><?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://servicemix.apache.org/examples/types"> <env:Body> <tns:SayHello> <tns:name>lada</tns:name> </tns:SayHello> </env:Body> </env:Envelope> </textarea> </td> <td> <textarea id="response" style="width:600px;height:400px"> </textarea> </td> </tr> <tr> <td colspan=2> <input type="button" value="Send" class="code-quote">"send();"/> </td> </tr> </table> </body> </html> This html page allows us testing our service. If we open this page in our favourite internet browser, we will see two text-areas and one button. We can enhanced this example by editing method in our service. We must edit java and wsdl file in our SU's.
Return to start page
|
Unsubscribe or edit your notifications preferences
