<%@ page language="java" session="false" contentType="text/html;charset=iso-8859-1" import="org.apache.axis.discovery.client.Client, java.util.List, org.apache.axis.discovery.core.Const, java.io.IOException, java.io.PrintWriter, java.io.StringWriter"%> Axis WS-Discovery

Axis Discovery

<%! public static final String uriParam="uri"; public static final String ttlParam = "ttl"; public void listEndpoints( String[] endpoints, JspWriter out) throws IOException{ int length = endpoints.length; out.write("Found "+length+" endpoint(s)"); out.write("

"); for (int i = 0; i < length; i++) { String endpoint = endpoints[i]; out.write("\n"); } out.write("
"); out.write(endpoint); out.write("
"); } public void logException(JspWriter out, Throwable e) throws IOException { out.write("

Exception "); out.write(e.toString()); out.write("

\n"); if(e.getMessage()!=null) { out.write(e.getMessage()); } out.write("\n
\n");
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        out.write(sw.toString());
        out.write("
"); } public int getIntParam(HttpServletRequest request, String name, int defVal) { int result; try { result = Integer.parseInt(request.getParameter(name)); } catch (NumberFormatException e) { result = defVal; } return result; } %> <% /* * demo page to use discovery to find and display services. * yes, jsps with code are ugly, but JSTL is even worse to debug */ String uri=request.getParameter(uriParam); if(uri==null) { %>
url
time to live (0-255)
timeout (seconds)
max number to find
<% } else { int ttl= getIntParam(request,"ttl",3); int timeout= getIntParam(request, "ttl", 1)*1000; int limit= getIntParam(request, "limit", 0); %>

Searching...

<% try { Client client; List responses; String[] endpoints; client = new Client(); responses= client.findEndpoints(uri, ttl, timeout, limit); endpoints = client.extractEndpointArray(responses); listEndpoints(endpoints,out); } catch (Throwable e) { logException(out,e); } } %>