You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/07/14 02:30:59 UTC
svn commit: r216290 [2/8] - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis2/transport/
core/src/org/apache/axis2/transport/http/ core/webapp/
saaj/src/org/apache/axis2/saaj/ samples/src/sample/amazon/search/
samples/src/userguide/cli...
Modified: webservices/axis/trunk/java/modules/core/webapp/HappyAxis.jsp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/webapp/HappyAxis.jsp?rev=216290&r1=216289&r2=216290&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/webapp/HappyAxis.jsp (original)
+++ webservices/axis/trunk/java/modules/core/webapp/HappyAxis.jsp Wed Jul 13 17:30:55 2005
@@ -1,496 +1,490 @@
-<html>
-<%@ page import="java.io.InputStream,
- java.io.IOException,
- javax.xml.parsers.SAXParser,
- javax.xml.parsers.SAXParserFactory,
- org.apache.axis2.clientapi.Call,
- javax.xml.stream.XMLStreamConstants,
- javax.xml.stream.XMLStreamReader,
- org.apache.axis2.addressing.AddressingConstants,
- org.apache.axis2.addressing.EndpointReference,
- org.apache.axis2.clientapi.Call,
- org.apache.axis2.om.*,
- org.apache.axis2.soap.SOAPBody,
- org.apache.axis2.soap.SOAPEnvelope,
- org.apache.axis2.soap.SOAPFactory,
- org.apache.axis2.Constants,
- javax.xml.stream.XMLOutputFactory,
- org.apache.axis2.engine.AxisFault,
- javax.xml.stream.XMLStreamException,
- javax.xml.namespace.QName,
- java.io.StringWriter"
- session="false" %>
- <%
- /*
- * Copyright 2002,2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
- %>
-<head>
-<title>Axis2 Happiness Page</title>
-<link href="css/axis-style.css" rel="stylesheet" type="text/css">
-</head>
-<body>
- <jsp:include page="include/header.inc"></jsp:include>
-<%port =request.getServerPort();%>
-<%IP=request.getRequestURL().toString();
- int lastindex = IP.lastIndexOf('/');
- IP = IP.substring(0,lastindex);
- targetEPR = new EndpointReference(AddressingConstants.WSA_TO,
- IP + "/services/Version/getVersion");
-%>
-<%!
- /*
- * Happiness tests for axis. These look at the classpath and warn if things
- * are missing. Normally addng this much code in a JSP page is mad
- * but here we want to validate JSP compilation too, and have a drop-in
- * page for easy re-use
- */
- int port = 0;
- String IP;
- EndpointReference targetEPR ;
- /**
- * Get a string providing install information.
- * TODO: make this platform aware and give specific hints
- */
- public String getInstallHints(HttpServletRequest request) {
-
- String hint=
- "<B><I>Note:</I></B> On Tomcat 4.x and Java1.4, you may need to put libraries that contain "
- +"java.* or javax.* packages into CATALINA_HOME/common/lib"
- +"<br>jaxrpc.jar and saaj.jar are two such libraries.";
- return hint;
- }
-
- /**
- * test for a class existing
- * @param classname
- * @return class iff present
- */
- Class classExists(String classname) {
- try {
- return Class.forName(classname);
- } catch (ClassNotFoundException e) {
- return null;
- }
- }
-
- /**
- * test for resource on the classpath
- * @param resource
- * @return true iff present
- */
- boolean resourceExists(String resource) {
- boolean found;
- InputStream instream=this.getClass().getResourceAsStream(resource);
- found=instream!=null;
- if(instream!=null) {
- try {
- instream.close();
- } catch (IOException e) {
- }
- }
- return found;
- }
-
- /**
- * probe for a class, print an error message is missing
- * @param out stream to print stuff
- * @param category text like "warning" or "error"
- * @param classname class to look for
- * @param jarFile where this class comes from
- * @param errorText extra error text
- * @param homePage where to d/l the library
- * @return the number of missing classes
- * @throws IOException
- */
- int probeClass(JspWriter out,
- String category,
- String classname,
- String jarFile,
- String description,
- String errorText,
- String homePage) throws IOException {
- try {
- Class clazz = classExists(classname);
- if(clazz == null) {
- String url="";
- if(homePage!=null) {
- url="<br> See <a href="+homePage+">"+homePage+"</a>";
- }
- out.write("<p>"+category+": could not find class "+classname
- +" from file <b>"+jarFile
- +"</b><br> "+errorText
- +url
- +"<p>");
- return 1;
- } else {
- String location = getLocation(out, clazz);
- if(location == null) {
- out.write("Found "+ description + " (" + classname + ")<br>");
- }
- else {
- out.write("Found "+ description + " (" + classname + ") at " + location + "<br>");
- }
- return 0;
- }
- } catch(NoClassDefFoundError ncdfe) {
- String url="";
- if(homePage!=null) {
- url="<br> See <a href="+homePage+">"+homePage+"</a>";
- }
- out.write("<p>"+category+": could not find a dependency"
- +" of class "+classname
- +" from file <b>"+jarFile
- +"</b><br> "+errorText
- +url
- +"<br>The root cause was: "+ncdfe.getMessage()
- +"<br>This can happen e.g. if "+classname+" is in"
- +" the 'common' classpath, but a dependency like "
- +" activation.jar is only in the webapp classpath."
- +"<p>");
- return 1;
- }
- }
-
- /**
- * get the location of a class
- * @param out
- * @param clazz
- * @return the jar file or path where a class was found
- */
-
- String getLocation(JspWriter out,
- Class clazz) {
- try {
- java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
- String location = url.toString();
- if(location.startsWith("jar")) {
- url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL();
- location = url.toString();
- }
-
- if(location.startsWith("file")) {
- java.io.File file = new java.io.File(url.getFile());
- return file.getAbsolutePath();
- } else {
- return url.toString();
- }
- } catch (Throwable t){
- }
- return "an unknown location";
- }
-
- /**
- * a class we need if a class is missing
- * @param out stream to print stuff
- * @param classname class to look for
- * @param jarFile where this class comes from
- * @param errorText extra error text
- * @param homePage where to d/l the library
- * @throws IOException when needed
- * @return the number of missing libraries (0 or 1)
- */
- int needClass(JspWriter out,
- String classname,
- String jarFile,
- String description,
- String errorText,
- String homePage) throws IOException {
- return probeClass(out,
- "<b>Error</b>",
- classname,
- jarFile,
- description,
- errorText,
- homePage);
- }
-
- /**
- * print warning message if a class is missing
- * @param out stream to print stuff
- * @param classname class to look for
- * @param jarFile where this class comes from
- * @param errorText extra error text
- * @param homePage where to d/l the library
- * @throws IOException when needed
- * @return the number of missing libraries (0 or 1)
- */
- int wantClass(JspWriter out,
- String classname,
- String jarFile,
- String description,
- String errorText,
- String homePage) throws IOException {
- return probeClass(out,
- "<b>Warning</b>",
- classname,
- jarFile,
- description,
- errorText,
- homePage);
- }
-
- /**
- * probe for a resource existing,
- * @param out
- * @param resource
- * @param errorText
- * @throws Exception
- */
- int wantResource(JspWriter out,
- String resource,
- String errorText) throws Exception {
- if(!resourceExists(resource)) {
- out.write("<p><b>Warning</b>: could not find resource "+resource
- +"<br>"
- +errorText);
- return 0;
- } else {
- out.write("found "+resource+"<br>");
- return 1;
- }
- }
-
-
- /**
- * get servlet version string
- *
- */
-
- public String getServletVersion() {
- ServletContext context=getServletConfig().getServletContext();
- int major = context.getMajorVersion();
- int minor = context.getMinorVersion();
- return Integer.toString(major) + '.' + Integer.toString(minor);
- }
-
-
-
- /**
- * what parser are we using.
- * @return the classname of the parser
- */
- private String getParserName() {
- SAXParser saxParser = getSAXParser();
- if (saxParser == null) {
- return "Could not create an XML Parser";
- }
-
- // check to what is in the classname
- String saxParserName = saxParser.getClass().getName();
- return saxParserName;
- }
-
- /**
- * Create a JAXP SAXParser
- * @return parser or null for trouble
- */
- private SAXParser getSAXParser() {
- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
- if (saxParserFactory == null) {
- return null;
- }
- SAXParser saxParser = null;
- try {
- saxParser = saxParserFactory.newSAXParser();
- } catch (Exception e) {
- }
- return saxParser;
- }
-
- /**
- * get the location of the parser
- * @return path or null for trouble in tracking it down
- */
-
- private String getParserLocation(JspWriter out) {
- SAXParser saxParser = getSAXParser();
- if (saxParser == null) {
- return null;
- }
- String location = getLocation(out,saxParser.getClass());
- return location;
- }
-
- private String value;
- private QName operationName = new QName("getVersion");
- private OMElement createEnvelope() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement method = fac.createOMElement("Version", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- method.addChild(value);
- return method;
- }
- public boolean inVokeTheService() {
- try {
- OMElement payload = createEnvelope();
- Call call = new Call();
- call.setTo(targetEPR);
- call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
-
- OMElement result =
- (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
- StringWriter writer = new StringWriter();
- result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(writer)));
- writer.flush();
- value = writer.toString();
- return true;
- } catch (AxisFault axisFault) {
- value = axisFault.getMessage();
- return false;
- } catch (XMLStreamException e) {
- value = e.getMessage();
- return false;
- }
- }
-%>
-<html><head><title>Axis2 Happiness Page</title></head>
-<body>
-<h1>Axis2 Happiness Page</h1>
-<h2>Examining webapp configuration</h2>
-
-<p>
-<h3>Needed Components</h3>
-<%
- int needed=0,wanted=0;
-
- /**
- * the essentials, without these Axis is not going to work
- */
- needed=needClass(out, "org.apache.axis2.transport.http.AxisServlet",
- "axis2-0.9.jar",
- "Apache-Axis",
- "Axis2 will not work",
- "http://xml.apache.org/axis/");
- needed+=needClass(out, "org.apache.commons.logging.Log",
- "commons-logging.jar",
- "Jakarta-Commons Logging",
- "Axis2 will not work",
- "http://jakarta.apache.org/commons/logging.html");
-
- needed+=needClass(out, "org.apache.log4j.Layout",
- "log4j-1.2.8.jar",
- "Log4j",
- "Axis2 may not work",
- "http://jakarta.apache.org/log4j");
- needed+=needClass(out, "javax.xml.stream.XMLStreamReader",
- "stax-api-1.0.jar",
- "Streaming API for XML",
- "Axis2 will not work",
- "http://dist.codehaus.org/stax/jars/");
- needed+=needClass(out, "com.bea.xml.stream.MXParser",
- "stax-1.1.1-dev.jar",
- "Streaming API for XML implementation",
- "Axis2 will not work",
- "http://dist.codehaus.org/stax/jars/");
-
-%>
-
-<%
- /*
- * resources on the classpath path
- */
- /* broken; this is a file, not a resource
- wantResource(out,"/server-config.wsdd",
- "There is no server configuration file;"
- +"run AdminClient to create one");
- */
- /* add more libraries here */
-
- out.write("<h3>");
- //is everythng we need here
- if(needed==0) {
- //yes, be happy
- out.write("<i>The core axis libraries are present. </i>");
- } else {
- //no, be very unhappy
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- out.write("<i>"
- +needed
- +" core axis librar"
- +(needed==1?"y is":"ies are")
- +" missing</i>");
- }
- //now look at wanted stuff
-
- out.write("</h3>");
-%>
-<p>
-<B><I>Note:</I></B> Even if everything this page probes for is present, there is no guarantee your
-web service will work, because there are many configuration options that we do
-not check for. These tests are <i>necessary</i> but not <i>sufficient</i>
-<hr>
-<h2>Examining echo service</h2>
- <%
- boolean serviceStatus = inVokeTheService();
- if(serviceStatus){
- %>
- <p>
- <font color="blue" >
- Found the echo service and Axis2 is working properly, and now you can drop any web service in
- to axis2/WEB-INF/service and check it is working.and got the following result
- <br>
- <%= value%> </font>
- </p>
- <hr>
- <%
- } else {
- %>
- <p>
- <font color="brown" >
- You can test the deployement functionality by uploading the echo service jar, which can be found in the
- samples directory of the axis distribution.
- <br>
- </font>
- </p>
- <hr>
- <%
- }
- %>
- <h2>Examining Application Server</h2>
- <table>
- <tr><td>Servlet version</td><td><%=getServletVersion()%></td></tr>
- <tr><td>Platform</td><td><%=getServletConfig().getServletContext().getServerInfo()%></td></tr>
- </table>
-
- <h2>Examining System Properties</h2>
-<%
- /**
- * Dump the system properties
- */
- java.util.Enumeration e=null;
- try {
- e= System.getProperties().propertyNames();
- } catch (SecurityException se) {
- }
- if(e!=null) {
- out.write("<pre>");
- for (;e.hasMoreElements();) {
- String key = (String) e.nextElement();
- out.write(key + "=" + System.getProperty(key)+"\n");
- }
- out.write("</pre><p>");
- } else {
- out.write("System properties are not accessible<p>");
- }
-%>
-
- <jsp:include page="include/link-footer.inc"></jsp:include>
- <jsp:include page="include/footer.inc"></jsp:include>
-</body>
-</html>
-
-
+<html>
+<%@ page import="java.io.InputStream,
+ java.io.IOException,
+ javax.xml.parsers.SAXParser,
+ javax.xml.parsers.SAXParserFactory,
+ org.apache.axis2.clientapi.Call,
+ org.apache.axis2.addressing.AddressingConstants,
+ org.apache.axis2.addressing.EndpointReference,
+ org.apache.axis2.om.*,
+ org.apache.axis2.Constants,
+ javax.xml.stream.XMLOutputFactory,
+ org.apache.axis2.engine.AxisFault,
+ javax.xml.stream.XMLStreamException,
+ javax.xml.namespace.QName,
+ java.io.StringWriter"
+ session="false" %>
+<%
+ /*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ %>
+<head>
+<title>Axis2 Happiness Page</title>
+<link href="css/axis-style.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+ <jsp:include page="include/header.inc"></jsp:include>
+<%port =request.getServerPort();%>
+<%IP=request.getRequestURL().toString();
+ int lastindex = IP.lastIndexOf('/');
+ IP = IP.substring(0,lastindex);
+ targetEPR = new EndpointReference(AddressingConstants.WSA_TO,
+ IP + "/services/Version/getVersion");
+%>
+<%!
+ /*
+ * Happiness tests for axis. These look at the classpath and warn if things
+ * are missing. Normally addng this much code in a JSP page is mad
+ * but here we want to validate JSP compilation too, and have a drop-in
+ * page for easy re-use
+ */
+ int port = 0;
+ String IP;
+ EndpointReference targetEPR ;
+ /**
+ * Get a string providing install information.
+ * TODO: make this platform aware and give specific hints
+ */
+ public String getInstallHints(HttpServletRequest request) {
+
+ String hint=
+ "<B><I>Note:</I></B> On Tomcat 4.x and Java1.4, you may need to put libraries that contain "
+ +"java.* or javax.* packages into CATALINA_HOME/common/lib"
+ +"<br>jaxrpc.jar and saaj.jar are two such libraries.";
+ return hint;
+ }
+
+ /**
+ * test for a class existing
+ * @param classname
+ * @return class iff present
+ */
+ Class classExists(String classname) {
+ try {
+ return Class.forName(classname);
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+
+ /**
+ * test for resource on the classpath
+ * @param resource
+ * @return true iff present
+ */
+ boolean resourceExists(String resource) {
+ boolean found;
+ InputStream instream=this.getClass().getResourceAsStream(resource);
+ found=instream!=null;
+ if(instream!=null) {
+ try {
+ instream.close();
+ } catch (IOException e) {
+ }
+ }
+ return found;
+ }
+
+ /**
+ * probe for a class, print an error message is missing
+ * @param out stream to print stuff
+ * @param category text like "warning" or "error"
+ * @param classname class to look for
+ * @param jarFile where this class comes from
+ * @param errorText extra error text
+ * @param homePage where to d/l the library
+ * @return the number of missing classes
+ * @throws IOException
+ */
+ int probeClass(JspWriter out,
+ String category,
+ String classname,
+ String jarFile,
+ String description,
+ String errorText,
+ String homePage) throws IOException {
+ try {
+ Class clazz = classExists(classname);
+ if(clazz == null) {
+ String url="";
+ if(homePage!=null) {
+ url="<br> See <a href="+homePage+">"+homePage+"</a>";
+ }
+ out.write("<p>"+category+": could not find class "+classname
+ +" from file <b>"+jarFile
+ +"</b><br> "+errorText
+ +url
+ +"<p>");
+ return 1;
+ } else {
+ String location = getLocation(out, clazz);
+ if(location == null) {
+ out.write("Found "+ description + " (" + classname + ")<br>");
+ }
+ else {
+ out.write("Found "+ description + " (" + classname + ") at " + location + "<br>");
+ }
+ return 0;
+ }
+ } catch(NoClassDefFoundError ncdfe) {
+ String url="";
+ if(homePage!=null) {
+ url="<br> See <a href="+homePage+">"+homePage+"</a>";
+ }
+ out.write("<p>"+category+": could not find a dependency"
+ +" of class "+classname
+ +" from file <b>"+jarFile
+ +"</b><br> "+errorText
+ +url
+ +"<br>The root cause was: "+ncdfe.getMessage()
+ +"<br>This can happen e.g. if "+classname+" is in"
+ +" the 'common' classpath, but a dependency like "
+ +" activation.jar is only in the webapp classpath."
+ +"<p>");
+ return 1;
+ }
+ }
+
+ /**
+ * get the location of a class
+ * @param out
+ * @param clazz
+ * @return the jar file or path where a class was found
+ */
+
+ String getLocation(JspWriter out,
+ Class clazz) {
+ try {
+ java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
+ String location = url.toString();
+ if(location.startsWith("jar")) {
+ url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL();
+ location = url.toString();
+ }
+
+ if(location.startsWith("file")) {
+ java.io.File file = new java.io.File(url.getFile());
+ return file.getAbsolutePath();
+ } else {
+ return url.toString();
+ }
+ } catch (Throwable t){
+ }
+ return "an unknown location";
+ }
+
+ /**
+ * a class we need if a class is missing
+ * @param out stream to print stuff
+ * @param classname class to look for
+ * @param jarFile where this class comes from
+ * @param errorText extra error text
+ * @param homePage where to d/l the library
+ * @throws IOException when needed
+ * @return the number of missing libraries (0 or 1)
+ */
+ int needClass(JspWriter out,
+ String classname,
+ String jarFile,
+ String description,
+ String errorText,
+ String homePage) throws IOException {
+ return probeClass(out,
+ "<b>Error</b>",
+ classname,
+ jarFile,
+ description,
+ errorText,
+ homePage);
+ }
+
+ /**
+ * print warning message if a class is missing
+ * @param out stream to print stuff
+ * @param classname class to look for
+ * @param jarFile where this class comes from
+ * @param errorText extra error text
+ * @param homePage where to d/l the library
+ * @throws IOException when needed
+ * @return the number of missing libraries (0 or 1)
+ */
+ int wantClass(JspWriter out,
+ String classname,
+ String jarFile,
+ String description,
+ String errorText,
+ String homePage) throws IOException {
+ return probeClass(out,
+ "<b>Warning</b>",
+ classname,
+ jarFile,
+ description,
+ errorText,
+ homePage);
+ }
+
+ /**
+ * probe for a resource existing,
+ * @param out
+ * @param resource
+ * @param errorText
+ * @throws Exception
+ */
+ int wantResource(JspWriter out,
+ String resource,
+ String errorText) throws Exception {
+ if(!resourceExists(resource)) {
+ out.write("<p><b>Warning</b>: could not find resource "+resource
+ +"<br>"
+ +errorText);
+ return 0;
+ } else {
+ out.write("found "+resource+"<br>");
+ return 1;
+ }
+ }
+
+
+ /**
+ * get servlet version string
+ *
+ */
+
+ public String getServletVersion() {
+ ServletContext context=getServletConfig().getServletContext();
+ int major = context.getMajorVersion();
+ int minor = context.getMinorVersion();
+ return Integer.toString(major) + '.' + Integer.toString(minor);
+ }
+
+
+
+ /**
+ * what parser are we using.
+ * @return the classname of the parser
+ */
+ private String getParserName() {
+ SAXParser saxParser = getSAXParser();
+ if (saxParser == null) {
+ return "Could not create an XML Parser";
+ }
+
+ // check to what is in the classname
+ String saxParserName = saxParser.getClass().getName();
+ return saxParserName;
+ }
+
+ /**
+ * Create a JAXP SAXParser
+ * @return parser or null for trouble
+ */
+ private SAXParser getSAXParser() {
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ if (saxParserFactory == null) {
+ return null;
+ }
+ SAXParser saxParser = null;
+ try {
+ saxParser = saxParserFactory.newSAXParser();
+ } catch (Exception e) {
+ }
+ return saxParser;
+ }
+
+ /**
+ * get the location of the parser
+ * @return path or null for trouble in tracking it down
+ */
+
+ private String getParserLocation(JspWriter out) {
+ SAXParser saxParser = getSAXParser();
+ if (saxParser == null) {
+ return null;
+ }
+ String location = getLocation(out,saxParser.getClass());
+ return location;
+ }
+
+ private String value;
+ private QName operationName = new QName("getVersion");
+ private OMElement createEnvelope() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+ OMElement method = fac.createOMElement("Version", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ method.addChild(value);
+ return method;
+ }
+ public boolean inVokeTheService() {
+ try {
+ OMElement payload = createEnvelope();
+ Call call = new Call();
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
+
+ OMElement result =
+ (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+ StringWriter writer = new StringWriter();
+ result.serializeWithCache(XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
+ writer.flush();
+ value = writer.toString();
+ return true;
+ } catch (AxisFault axisFault) {
+ value = axisFault.getMessage();
+ return false;
+ } catch (XMLStreamException e) {
+ value = e.getMessage();
+ return false;
+ }
+ }
+%>
+<html><head><title>Axis2 Happiness Page</title></head>
+<body>
+<h1>Axis2 Happiness Page</h1>
+<h2>Examining webapp configuration</h2>
+
+<p>
+<h3>Needed Components</h3>
+<%
+ int needed=0,wanted=0;
+
+ /**
+ * the essentials, without these Axis is not going to work
+ */
+ needed=needClass(out, "org.apache.axis2.transport.http.AxisServlet",
+ "axis2-0.9.jar",
+ "Apache-Axis",
+ "Axis2 will not work",
+ "http://xml.apache.org/axis/");
+ needed+=needClass(out, "org.apache.commons.logging.Log",
+ "commons-logging.jar",
+ "Jakarta-Commons Logging",
+ "Axis2 will not work",
+ "http://jakarta.apache.org/commons/logging.html");
+
+ needed+=needClass(out, "org.apache.log4j.Layout",
+ "log4j-1.2.8.jar",
+ "Log4j",
+ "Axis2 may not work",
+ "http://jakarta.apache.org/log4j");
+ needed+=needClass(out, "javax.xml.stream.XMLStreamReader",
+ "stax-api-1.0.jar",
+ "Streaming API for XML",
+ "Axis2 will not work",
+ "http://dist.codehaus.org/stax/jars/");
+ needed+=needClass(out, "com.bea.xml.stream.MXParser",
+ "stax-1.1.1-dev.jar",
+ "Streaming API for XML implementation",
+ "Axis2 will not work",
+ "http://dist.codehaus.org/stax/jars/");
+
+%>
+
+<%
+ /*
+ * resources on the classpath path
+ */
+ /* broken; this is a file, not a resource
+ wantResource(out,"/server-config.wsdd",
+ "There is no server configuration file;"
+ +"run AdminClient to create one");
+ */
+ /* add more libraries here */
+
+ out.write("<h3>");
+ //is everythng we need here
+ if(needed==0) {
+ //yes, be happy
+ out.write("<i>The core axis libraries are present. </i>");
+ } else {
+ //no, be very unhappy
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ out.write("<i>"
+ +needed
+ +" core axis librar"
+ +(needed==1?"y is":"ies are")
+ +" missing</i>");
+ }
+ //now look at wanted stuff
+
+ out.write("</h3>");
+%>
+<p>
+<B><I>Note:</I></B> Even if everything this page probes for is present, there is no guarantee your
+web service will work, because there are many configuration options that we do
+not check for. These tests are <i>necessary</i> but not <i>sufficient</i>
+<hr>
+<h2>Examining echo service</h2>
+ <%
+ boolean serviceStatus = inVokeTheService();
+ if(serviceStatus){
+ %>
+ <p>
+ <font color="blue" >
+ Found the echo service and Axis2 is working properly, and now you can drop any web service in
+ to axis2/WEB-INF/service and check it is working.and got the following result
+ <br>
+ <%= value%> </font>
+ </p>
+ <hr>
+ <%
+ } else {
+ %>
+ <p>
+ <font color="brown" >
+ You can test the deployement functionality by uploading the echo service jar, which can be found in the
+ samples directory of the axis distribution.
+ <br>
+ </font>
+ </p>
+ <hr>
+ <%
+ }
+ %>
+ <h2>Examining Application Server</h2>
+ <table>
+ <tr><td>Servlet version</td><td><%=getServletVersion()%></td></tr>
+ <tr><td>Platform</td><td><%=getServletConfig().getServletContext().getServerInfo()%></td></tr>
+ </table>
+
+ <h2>Examining System Properties</h2>
+<%
+ /**
+ * Dump the system properties
+ */
+ java.util.Enumeration e=null;
+ try {
+ e= System.getProperties().propertyNames();
+ } catch (SecurityException se) {
+ }
+ if(e!=null) {
+ out.write("<pre>");
+ for (;e.hasMoreElements();) {
+ String key = (String) e.nextElement();
+ out.write(key + "=" + System.getProperty(key)+"\n");
+ }
+ out.write("</pre><p>");
+ } else {
+ out.write("System properties are not accessible<p>");
+ }
+%>
+
+ <jsp:include page="include/link-footer.inc"></jsp:include>
+ <jsp:include page="include/footer.inc"></jsp:include>
+</body>
+</html>
+
+
Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java?rev=216290&r1=216289&r2=216290&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java (original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java Wed Jul 13 17:30:55 2005
@@ -1,218 +1,218 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-package org.apache.axis2.saaj;
-
-import org.apache.axis2.om.OMOutput;
-import org.apache.axis2.transport.http.HTTPConstants;
-
-import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPPart;
-import javax.xml.stream.XMLOutputFactory;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Iterator;
-
-/**
- * @author Ashutosh Shahi ashutosh.shahi@gmail.com
- * <p/>
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class SOAPMessageImpl extends SOAPMessage {
-
- private SOAPPartImpl mSOAPPart;
- private java.util.Hashtable mProps = new java.util.Hashtable();
- private MimeHeaders headers;
-
- public SOAPMessageImpl(Object initialContents) {
- try {
- setup(initialContents, false, null, null, null);
- } catch (SOAPException e) {
- e.printStackTrace();
- }
- }
-
- public SOAPMessageImpl(Object initialContents,
- boolean bodyInStream,
- javax.xml.soap.MimeHeaders headers) {
- try {
- setup(initialContents,
- bodyInStream,
- null,
- null,
- (MimeHeaders) headers);
- } catch (SOAPException e) {
- e.printStackTrace();
- }
- }
-
- private void setup(Object initialContents, boolean bodyInStream,
- String contentType, String contentLocation,
- MimeHeaders mimeHeaders) throws SOAPException {
- if (null == mSOAPPart)
- mSOAPPart = new SOAPPartImpl(this, initialContents, bodyInStream);
- else
- mSOAPPart.setMessage(this);
-
- headers = (mimeHeaders == null) ?
- new MimeHeaders() : new MimeHeaders(mimeHeaders);
- }
-
- /**
- * Retrieves a description of this <CODE>SOAPMessage</CODE>
- * object's content.
- *
- * @return a <CODE>String</CODE> describing the content of this
- * message or <CODE>null</CODE> if no description has been
- * set
- * @see #setContentDescription(java.lang.String) setContentDescription(java.lang.String)
- */
- public String getContentDescription() {
- String values[] = headers.getHeader(
- HTTPConstants.HEADER_CONTENT_DESCRIPTION);
- if (values != null && values.length > 0)
- return values[0];
- return null;
- }
-
- /**
- * Sets the description of this <CODE>SOAPMessage</CODE>
- * object's content with the given description.
- *
- * @param description a <CODE>String</CODE>
- * describing the content of this message
- * @see #getContentDescription() getContentDescription()
- */
- public void setContentDescription(String description) {
- headers.setHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION,
- description);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#getSOAPPart()
- */
- public SOAPPart getSOAPPart() {
- return mSOAPPart;
- }
-
- public SOAPBody getSOAPBody() throws SOAPException {
- return mSOAPPart.getEnvelope().getBody();
- }
-
- public SOAPHeader getSOAPHeader() throws SOAPException {
- return mSOAPPart.getEnvelope().getHeader();
- }
-
- public void setProperty(String property, Object value) throws SOAPException {
- mProps.put(property, value);
- }
-
- public Object getProperty(String property) throws SOAPException {
- return mProps.get(property);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#removeAllAttachments()
- */
- public void removeAllAttachments() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#countAttachments()
- */
- public int countAttachments() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#getAttachments()
- */
- public Iterator getAttachments() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#getAttachments(javax.xml.soap.MimeHeaders)
- */
- public Iterator getAttachments(javax.xml.soap.MimeHeaders headers) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#addAttachmentPart(javax.xml.soap.AttachmentPart)
- */
- public void addAttachmentPart(AttachmentPart attachmentpart) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#createAttachmentPart()
- */
- public AttachmentPart createAttachmentPart() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#getMimeHeaders()
- */
- public javax.xml.soap.MimeHeaders getMimeHeaders() {
-
- return headers;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#saveChanges()
- */
- public void saveChanges() throws SOAPException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#saveRequired()
- */
- public boolean saveRequired() {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.soap.SOAPMessage#writeTo(java.io.OutputStream)
- */
- public void writeTo(OutputStream out) throws SOAPException, IOException {
- try {
- OMOutput omOutput = new OMOutput(
- XMLOutputFactory.newInstance().createXMLStreamWriter(out));
- ((SOAPEnvelopeImpl) mSOAPPart.getEnvelope()).getOMEnvelope()
- .serialize(omOutput);
- omOutput.flush();
- } catch (Exception e) {
- throw new SOAPException(e);
- }
- }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.axis2.saaj;
+
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ * <p/>
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPMessageImpl extends SOAPMessage {
+
+ private SOAPPartImpl mSOAPPart;
+ private java.util.Hashtable mProps = new java.util.Hashtable();
+ private MimeHeaders headers;
+
+ public SOAPMessageImpl(Object initialContents) {
+ try {
+ setup(initialContents, false, null, null, null);
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public SOAPMessageImpl(Object initialContents,
+ boolean bodyInStream,
+ javax.xml.soap.MimeHeaders headers) {
+ try {
+ setup(initialContents,
+ bodyInStream,
+ null,
+ null,
+ (MimeHeaders) headers);
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void setup(Object initialContents, boolean bodyInStream,
+ String contentType, String contentLocation,
+ MimeHeaders mimeHeaders) throws SOAPException {
+ if (null == mSOAPPart)
+ mSOAPPart = new SOAPPartImpl(this, initialContents, bodyInStream);
+ else
+ mSOAPPart.setMessage(this);
+
+ headers = (mimeHeaders == null) ?
+ new MimeHeaders() : new MimeHeaders(mimeHeaders);
+ }
+
+ /**
+ * Retrieves a description of this <CODE>SOAPMessage</CODE>
+ * object's content.
+ *
+ * @return a <CODE>String</CODE> describing the content of this
+ * message or <CODE>null</CODE> if no description has been
+ * set
+ * @see #setContentDescription(java.lang.String) setContentDescription(java.lang.String)
+ */
+ public String getContentDescription() {
+ String values[] = headers.getHeader(
+ HTTPConstants.HEADER_CONTENT_DESCRIPTION);
+ if (values != null && values.length > 0)
+ return values[0];
+ return null;
+ }
+
+ /**
+ * Sets the description of this <CODE>SOAPMessage</CODE>
+ * object's content with the given description.
+ *
+ * @param description a <CODE>String</CODE>
+ * describing the content of this message
+ * @see #getContentDescription() getContentDescription()
+ */
+ public void setContentDescription(String description) {
+ headers.setHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION,
+ description);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getSOAPPart()
+ */
+ public SOAPPart getSOAPPart() {
+ return mSOAPPart;
+ }
+
+ public SOAPBody getSOAPBody() throws SOAPException {
+ return mSOAPPart.getEnvelope().getBody();
+ }
+
+ public SOAPHeader getSOAPHeader() throws SOAPException {
+ return mSOAPPart.getEnvelope().getHeader();
+ }
+
+ public void setProperty(String property, Object value) throws SOAPException {
+ mProps.put(property, value);
+ }
+
+ public Object getProperty(String property) throws SOAPException {
+ return mProps.get(property);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#removeAllAttachments()
+ */
+ public void removeAllAttachments() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#countAttachments()
+ */
+ public int countAttachments() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getAttachments()
+ */
+ public Iterator getAttachments() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getAttachments(javax.xml.soap.MimeHeaders)
+ */
+ public Iterator getAttachments(javax.xml.soap.MimeHeaders headers) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#addAttachmentPart(javax.xml.soap.AttachmentPart)
+ */
+ public void addAttachmentPart(AttachmentPart attachmentpart) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#createAttachmentPart()
+ */
+ public AttachmentPart createAttachmentPart() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getMimeHeaders()
+ */
+ public javax.xml.soap.MimeHeaders getMimeHeaders() {
+
+ return headers;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#saveChanges()
+ */
+ public void saveChanges() throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#saveRequired()
+ */
+ public boolean saveRequired() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#writeTo(java.io.OutputStream)
+ */
+ public void writeTo(OutputStream out) throws SOAPException, IOException {
+ try {
+ XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+ ((SOAPEnvelopeImpl) mSOAPPart.getEnvelope()).getOMEnvelope()
+ .serialize(writer);
+ writer.flush();
+ } catch (Exception e) {
+ throw new SOAPException(e);
+ }
+ }
+
+}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java?rev=216290&r1=216289&r2=216290&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/AsynchronousClient.java Wed Jul 13 17:30:55 2005
@@ -1,191 +1,187 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-package sample.amazon.search;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.OperationDescription;
-import org.apache.axis2.engine.AxisFault;
-import org.apache.axis2.om.OMOutput;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-
-/**
- * This class implements main() method and sendMsg() methods,
- * check the availability of License key
- * Builds call objects and set it's properties,
- * Also keep few important variables as static and protected those frequently need by other classes
- *
- * @auther Gayan Asanka (gayan@opensource.lk)
- */
-
-public class AsynchronousClient {
-
- /**
- * Query parameter
- */
- protected static String search = "";
-
- /**
- * Query parameters sent with the last request
- */
- protected static String prevSearch = "";
-
- /**
- * License key
- */
- protected static String amazonkey;
-
- /**
- * properties file to store the license key
- */
- protected static Properties prop;
-
- /**
- * maximum results per page
- */
- protected static String maxResults = String.valueOf(2);
-
- /**
- * when this is set, thread sends a new request
- */
- protected static boolean doSearch = false;
-
- public static void main(String[] args) {
- GUIHandler gui;
- Thread linkThread, guiThread;
- LinkFollower page;
- File propertyFile;
-
- page = new LinkFollower(); //this object used to build the linkfollower thread
- LinkFollower.showURL = false;
- gui = new GUIHandler();
-
- /*check the license key, if it is not there, ask user to enter the key*/
-
- prop = new Properties();
- try {
- String workingDir = System.getProperty("user.dir");
- propertyFile = new File(workingDir + File.separator + "samples" +
- File.separator +
- "key.properties");
- propertyFile.createNewFile();
- prop.load(new FileInputStream(propertyFile));
- amazonkey = prop.getProperty("amazonKey");
- System.out.println("key is " + amazonkey);
- if (amazonkey == null) {
- gui.setKey();
- }
- prop = null; //Useless from now onwards
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- gui.buildFrame(); //GUI is built and desplayed
-
- linkThread = new Thread(page);
- guiThread = new Thread(gui);
-
- guiThread.start();
- linkThread.start();
- guiThread.run(); //To listen to the GUI and send messages
- linkThread.run(); //To detect hyperLink actions and open Simple Web Browser
- }
-
- /**
- * constructor
- */
- public AsynchronousClient() {
-
- }
-
- /**
- * Method sendMsg()
- * build the Call Object
- * Set the URL : To use TCP monitor comment the line where url is hard coded
- * and uncomment the following line
- * Get built the messageContext
- * Invoke the sending operation
- *
- * @throws AxisFault
- */
- public static void sendMsg() throws AxisFault {
- search.trim();
- prevSearch = search;
- Call call = new Call();
- URL url = null;
- try {
- url =
- new URL("http",
- "soap.amazon.com",
- "/onca/soap?Service=AlexaWebInfoService");
-
- /** Uncomment the folowing to use TCP Monitor, and comment the above */
-
- //url = new URL("http", "localhost",8080, "/onca/soap?Service=AlexaWebInfoService");
-
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- call.setTo(
- new EndpointReference(AddressingConstants.WSA_TO,
- url.toString()));
- MessageContext requestContext = ClientUtil.getMessageContext();
- try {
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP,
- false);
-
- System.out.println("Sending the Async message ....");
-
- OMOutput omOutput = new OMOutput(XMLOutputFactory.newInstance()
- .createXMLStreamWriter
- (System.out));
- requestContext.getEnvelope().serialize(omOutput);
- omOutput.flush();
-
- System.out.println();
- QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
- OperationDescription opdesc = new OperationDescription(opName);
- call.invokeNonBlocking(opdesc,
- requestContext,
- new ClientCallbackHandler());
- } catch (AxisFault e1) {
- e1.printStackTrace();
- } catch (XMLStreamException e) {
- e.printStackTrace();
- }
- System.out.println(
- "Message sent and the client thread is returned....");
- }
-}
-
-
-
-
-
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package sample.amazon.search;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.engine.AxisFault;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ * This class implements main() method and sendMsg() methods,
+ * check the availability of License key
+ * Builds call objects and set it's properties,
+ * Also keep few important variables as static and protected those frequently need by other classes
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+
+public class AsynchronousClient {
+
+ /**
+ * Query parameter
+ */
+ protected static String search = "";
+
+ /**
+ * Query parameters sent with the last request
+ */
+ protected static String prevSearch = "";
+
+ /**
+ * License key
+ */
+ protected static String amazonkey;
+
+ /**
+ * properties file to store the license key
+ */
+ protected static Properties prop;
+
+ /**
+ * maximum results per page
+ */
+ protected static String maxResults = String.valueOf(2);
+
+ /**
+ * when this is set, thread sends a new request
+ */
+ protected static boolean doSearch = false;
+
+ public static void main(String[] args) {
+ GUIHandler gui;
+ Thread linkThread, guiThread;
+ LinkFollower page;
+ File propertyFile;
+
+ page = new LinkFollower(); //this object used to build the linkfollower thread
+ LinkFollower.showURL = false;
+ gui = new GUIHandler();
+
+ /*check the license key, if it is not there, ask user to enter the key*/
+
+ prop = new Properties();
+ try {
+ String workingDir = System.getProperty("user.dir");
+ propertyFile = new File(workingDir + File.separator + "samples" +
+ File.separator +
+ "key.properties");
+ propertyFile.createNewFile();
+ prop.load(new FileInputStream(propertyFile));
+ amazonkey = prop.getProperty("amazonKey");
+ System.out.println("key is " + amazonkey);
+ if (amazonkey == null) {
+ gui.setKey();
+ }
+ prop = null; //Useless from now onwards
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ gui.buildFrame(); //GUI is built and desplayed
+
+ linkThread = new Thread(page);
+ guiThread = new Thread(gui);
+
+ guiThread.start();
+ linkThread.start();
+ guiThread.run(); //To listen to the GUI and send messages
+ linkThread.run(); //To detect hyperLink actions and open Simple Web Browser
+ }
+
+ /**
+ * constructor
+ */
+ public AsynchronousClient() {
+
+ }
+
+ /**
+ * Method sendMsg()
+ * build the Call Object
+ * Set the URL : To use TCP monitor comment the line where url is hard coded
+ * and uncomment the following line
+ * Get built the messageContext
+ * Invoke the sending operation
+ *
+ * @throws AxisFault
+ */
+ public static void sendMsg() throws AxisFault {
+ search.trim();
+ prevSearch = search;
+ Call call = new Call();
+ URL url = null;
+ try {
+ url =
+ new URL("http",
+ "soap.amazon.com",
+ "/onca/soap?Service=AlexaWebInfoService");
+
+ /** Uncomment the folowing to use TCP Monitor, and comment the above */
+
+ //url = new URL("http", "localhost",8080, "/onca/soap?Service=AlexaWebInfoService");
+
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ call.setTo(
+ new EndpointReference(AddressingConstants.WSA_TO,
+ url.toString()));
+ MessageContext requestContext = ClientUtil.getMessageContext();
+ try {
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+
+ System.out.println("Sending the Async message ....");
+ requestContext.getEnvelope().serialize(
+ XMLOutputFactory.newInstance()
+ .createXMLStreamWriter
+ (System.out));
+ System.out.println();
+ QName opName = new QName("urn:GoogleSearch", "doGoogleSearch");
+ OperationDescription opdesc = new OperationDescription(opName);
+ call.invokeNonBlocking(opdesc,
+ requestContext,
+ new ClientCallbackHandler());
+ } catch (AxisFault e1) {
+ e1.printStackTrace();
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+ System.out.println(
+ "Message sent and the client thread is returned....");
+ }
+}
+
+
+
+
+
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java?rev=216290&r1=216289&r2=216290&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/search/ClientCallbackHandler.java Wed Jul 13 17:30:55 2005
@@ -1,208 +1,205 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-package sample.amazon.search;
-
-import org.apache.axis2.clientapi.AsyncResult;
-import org.apache.axis2.clientapi.Callback;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.om.OMOutput;
-import org.apache.axis2.soap.SOAPEnvelope;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import java.util.Iterator;
-
-/**
- * This class implements the onComplete method extended by call back
- * recieves the Response
- * process the soap with OM to extract the data
- * Find the <NavigationURL> element and get the text from it
- *
- * @auther Gayan Asanka (gayan@opensource.lk)
- */
-
-public class ClientCallbackHandler extends Callback {
-
- /**
- * HTML Header to desplay snippet text
- */
- private String beginHTML = "<HTML><HEAD><TITLE>Wow</TITLE></HEAD><BODY>";
-
- /**
- * HTML footer
- */
- private String endHTML = "</BODY></HTML>";
-
- /**
- * Store the URLs read by soap
- */
- private String strURL = beginHTML;
-
- /**
- * Stores the response
- */
- private AsyncResult myResult;
-
- /**
- * method onComplete
- *
- * @param result
- */
- public void onComplete(AsyncResult result) {
- System.out.println(
- "Responce message received to the ClientCallbackHandler ...");
- try {
- OMOutput omOutput = new OMOutput(
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- System.out));
- result.getResponseEnvelope().serialize(omOutput);
- omOutput.flush();
- } catch (XMLStreamException e) {
- System.out.println("Error occured after responce is received");
- e.printStackTrace();
- } catch (FactoryConfigurationError e) {
- System.out.println("Error occured after responce is received");
- e.printStackTrace();
- }
- myResult = result;
- extractDetails(myResult);
- }
-
- /**
- * method extractDetails
- *
- * @param result
- */
- private void extractDetails(AsyncResult result) {
- Iterator iterator0, iterator1, iterator2, iterator3, iterator4;
- SOAPEnvelope resEnvilop;
- OMElement body;
- OMElement operation;
- OMNode node;
- OMElement elem;
-
- resEnvilop = result.getResponseEnvelope();
- body = resEnvilop.getBody();
- operation = body.getFirstElement();
-
- String opLocalName = operation.getLocalName();
- if (opLocalName.equals("Fault")) {
- System.out.println(
- "A Fault message recieved, Check your Licence key");
- strURL =
- strURL +
- "A Fault message recieved, Check your Licence key. Else you have reached the " +
- "daily limit of 1000 requests";
- } else {
- System.out.println("this is opera: " + operation.getLocalName());
- iterator0 = operation.getChildren();
-
- while (iterator0.hasNext()) {
- node = (OMNode) iterator0.next();
- if (node.getType() == OMNode.ELEMENT_NODE) {
- elem = (OMElement) node;
- String str = elem.getLocalName();
- System.out.println(str);
- if (str.equals("SearchResult")) {
- System.out.println("Got Search Results");
- iterator1 = elem.getChildren();
- while (iterator1.hasNext()) {
- node = (OMNode) iterator1.next();
- if (node.getType() == OMNode.ELEMENT_NODE) {
- elem = (OMElement) node;
- String str1 = elem.getLocalName();
- System.out.println(str1);
- if (str1.equals("Alexa")) {
- System.out.println("Got Alexa");
- elem = elem.getFirstElement(); //elem -> websearch
- System.out.println("Should be WebSearch " +
- elem.getLocalName());
- iterator2 = elem.getChildren();
- while (iterator2.hasNext()) {
- node = (OMNode) iterator2.next();
- if (node.getType() ==
- OMNode.ELEMENT_NODE) {
- elem = (OMElement) node;
- String str3 = elem.getLocalName();
- System.out.println(str3);
- if (str3.equals("Results")) {
- System.out.println(
- "Got Results");
- iterator3 = elem.getChildren();
- while (iterator3.hasNext()) {
- node =
- (OMNode) iterator3.next();
- if (node.getType() ==
- OMNode.ELEMENT_NODE) {
- elem =
- (OMElement) node;
- String str4 = elem.getLocalName();
- System.out.println(
- str4);
- if (str4.equals(
- "Result")) {
- iterator4 =
- elem.getChildren();
- while (iterator4.hasNext()) {
- node =
- (OMNode) iterator4.next();
- if (node.getType() ==
- OMNode.ELEMENT_NODE) {
- elem =
- (OMElement) node;
- String str5 = elem.getLocalName();
- System.out.println(
- str5);
- if (str5.equals(
- "NavigableUrl")) {
- String txt = elem.getText();
- strURL =
- strURL +
- "<a href= " +
- txt +
- ">" +
- txt +
- "</a><br>";
- System.out.println(
- strURL);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- System.out.println("Outside of loop");
- GUIHandler.showResults(strURL + endHTML);
- }
-
- public void reportError(Exception e) {
- System.out.println("Error occured after responce is received");
- e.printStackTrace();
- }
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package sample.amazon.search;
+
+import org.apache.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.soap.SOAPEnvelope;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.util.Iterator;
+
+/**
+ * This class implements the onComplete method extended by call back
+ * recieves the Response
+ * process the soap with OM to extract the data
+ * Find the <NavigationURL> element and get the text from it
+ *
+ * @auther Gayan Asanka (gayan@opensource.lk)
+ */
+
+public class ClientCallbackHandler extends Callback {
+
+ /**
+ * HTML Header to desplay snippet text
+ */
+ private String beginHTML = "<HTML><HEAD><TITLE>Wow</TITLE></HEAD><BODY>";
+
+ /**
+ * HTML footer
+ */
+ private String endHTML = "</BODY></HTML>";
+
+ /**
+ * Store the URLs read by soap
+ */
+ private String strURL = beginHTML;
+
+ /**
+ * Stores the response
+ */
+ private AsyncResult myResult;
+
+ /**
+ * method onComplete
+ *
+ * @param result
+ */
+ public void onComplete(AsyncResult result) {
+ System.out.println(
+ "Responce message received to the ClientCallbackHandler ...");
+ try {
+ result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
+ System.out));
+ } catch (XMLStreamException e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ } catch (FactoryConfigurationError e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ }
+ myResult = result;
+ extractDetails(myResult);
+ }
+
+ /**
+ * method extractDetails
+ *
+ * @param result
+ */
+ private void extractDetails(AsyncResult result) {
+ Iterator iterator0, iterator1, iterator2, iterator3, iterator4;
+ SOAPEnvelope resEnvilop;
+ OMElement body;
+ OMElement operation;
+ OMNode node;
+ OMElement elem;
+
+ resEnvilop = result.getResponseEnvelope();
+ body = resEnvilop.getBody();
+ operation = body.getFirstElement();
+
+ String opLocalName = operation.getLocalName();
+ if (opLocalName.equals("Fault")) {
+ System.out.println(
+ "A Fault message recieved, Check your Licence key");
+ strURL =
+ strURL +
+ "A Fault message recieved, Check your Licence key. Else you have reached the " +
+ "daily limit of 1000 requests";
+ } else {
+ System.out.println("this is opera: " + operation.getLocalName());
+ iterator0 = operation.getChildren();
+
+ while (iterator0.hasNext()) {
+ node = (OMNode) iterator0.next();
+ if (node.getType() == OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str = elem.getLocalName();
+ System.out.println(str);
+ if (str.equals("SearchResult")) {
+ System.out.println("Got Search Results");
+ iterator1 = elem.getChildren();
+ while (iterator1.hasNext()) {
+ node = (OMNode) iterator1.next();
+ if (node.getType() == OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str1 = elem.getLocalName();
+ System.out.println(str1);
+ if (str1.equals("Alexa")) {
+ System.out.println("Got Alexa");
+ elem = elem.getFirstElement(); //elem -> websearch
+ System.out.println("Should be WebSearch " +
+ elem.getLocalName());
+ iterator2 = elem.getChildren();
+ while (iterator2.hasNext()) {
+ node = (OMNode) iterator2.next();
+ if (node.getType() ==
+ OMNode.ELEMENT_NODE) {
+ elem = (OMElement) node;
+ String str3 = elem.getLocalName();
+ System.out.println(str3);
+ if (str3.equals("Results")) {
+ System.out.println(
+ "Got Results");
+ iterator3 = elem.getChildren();
+ while (iterator3.hasNext()) {
+ node =
+ (OMNode) iterator3.next();
+ if (node.getType() ==
+ OMNode.ELEMENT_NODE) {
+ elem =
+ (OMElement) node;
+ String str4 = elem.getLocalName();
+ System.out.println(
+ str4);
+ if (str4.equals(
+ "Result")) {
+ iterator4 =
+ elem.getChildren();
+ while (iterator4.hasNext()) {
+ node =
+ (OMNode) iterator4.next();
+ if (node.getType() ==
+ OMNode.ELEMENT_NODE) {
+ elem =
+ (OMElement) node;
+ String str5 = elem.getLocalName();
+ System.out.println(
+ str5);
+ if (str5.equals(
+ "NavigableUrl")) {
+ String txt = elem.getText();
+ strURL =
+ strURL +
+ "<a href= " +
+ txt +
+ ">" +
+ txt +
+ "</a><br>";
+ System.out.println(
+ strURL);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ System.out.println("Outside of loop");
+ GUIHandler.showResults(strURL + endHTML);
+ }
+
+ public void reportError(Exception e) {
+ System.out.println("Error occured after responce is received");
+ e.printStackTrace();
+ }
}
Modified: webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientForWebServiceWithModule.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientForWebServiceWithModule.java?rev=216290&r1=216289&r2=216290&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientForWebServiceWithModule.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/userguide/clients/ClientForWebServiceWithModule.java Wed Jul 13 17:30:55 2005
@@ -1,64 +1,62 @@
-package userguide.clients;
-
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.engine.AxisFault;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMOutput;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import java.io.StringWriter;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-public class ClientForWebServiceWithModule {
- private static EndpointReference targetEPR = new EndpointReference(
- AddressingConstants.WSA_TO,
- "http://127.0.0.1:8080/axis2/services/MyServiceWithModule/echo");
-
- public static void main(String[] args) {
- try {
- OMElement payload = ClientUtil.getEchoOMElement();
- Call call = new Call();
- call.setTo(targetEPR);
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP,
- false);
-
- //Blocking invocation
- OMElement result = (OMElement) call.invokeBlocking("echo",
- payload);
-
- StringWriter writer = new StringWriter();
- result.serializeWithCache(
- new OMOutput(
- XMLOutputFactory.newInstance()
- .createXMLStreamWriter(writer)));
- writer.flush();
-
- System.out.println(writer.toString());
-
- } catch (AxisFault axisFault) {
- axisFault.printStackTrace();
- } catch (XMLStreamException e) {
- e.printStackTrace();
- }
- }
-}
+package userguide.clients;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.engine.AxisFault;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.OMOutputImpl;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.io.StringWriter;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class ClientForWebServiceWithModule {
+ private static EndpointReference targetEPR = new EndpointReference(
+ AddressingConstants.WSA_TO,
+ "http://127.0.0.1:8080/axis2/services/MyServiceWithModule/echo");
+
+ public static void main(String[] args) {
+ try {
+ OMElement payload = ClientUtil.getEchoOMElement();
+ Call call = new Call();
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+
+ //Blocking invocation
+ OMElement result = (OMElement) call.invokeBlocking("echo",
+ payload);
+
+ StringWriter writer = new StringWriter();
+ result.serializeWithCache(XMLOutputFactory.newInstance()
+ .createXMLStreamWriter(writer));
+ writer.flush();
+
+ System.out.println(writer.toString());
+
+ } catch (AxisFault axisFault) {
+ axisFault.printStackTrace();
+ } catch (XMLStreamException e) {
+ e.printStackTrace();
+ }
+ }
+}