ws-soap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "feilong" <feil...@dfki.de>
Subject HTTP Servlet and Soap
Date Fri, 19 Nov 2004 20:29:13 GMT
Hallo all,
I wrote a servlet example under Tomcat early. Now I want to run it with Soap. 
How can I convert this servlet under HTTP into SOAP, i.e how can write a client and server
programs?
I installed Tomcat und apache-soap 2.3.1. It works.
Another question: can I change the predefinded web.xml under \jakarta-tomcat-4.1.30\webapps\soap\WEB-INF,
if I want to call another url also with soap protocol for instance http://localhost:8080/Wins/RequestParamExample3.
I tried to change the servlet name and servlet mapping in web.xml under soap. For example
replace <servlet-class> org.apache.soap.server.http.RPCRouterServlet
and <servlet-mapping> /servlet/rpcrouter. But everytime after editing the tomcat server
can't run.
Why servlet in Tomcat without soap can call arbitrary URL, only you should put your java class
in webapps/your-Servletname/WEB-INF/classes
and edit your web.xml to set the servlet name and servlet class and mapping. Why is the url
in soap web-application in client program always http://localhost:8080/soap/servlet/rpcrouter.
The following is web.xml under webapps\soap\WEB-INF and my sevlet program RequestParamExample3.java

------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
  <display-name>Apache-SOAP</display-name>
  <description>no description</description>
  <servlet>
    <servlet-name>rpcrouter</servlet-name>
    <display-name>Apache-SOAP RPC Router</display-name>
    <description>no description</description>
    <servlet-class>org.apache.soap.server.http.RPCRouterServlet</servlet-class>
    <init-param>
      <param-name>faultListener</param-name>
      <param-value>org.apache.soap.server.DOMFaultListener</param-value>
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>messagerouter</servlet-name>
    <display-name>Apache-SOAP Message Router</display-name>
    <servlet-class>org.apache.soap.server.http.MessageRouterServlet</servlet-class>
    <init-param>
      <param-name>faultListener</param-name>
      <param-value>org.apache.soap.server.DOMFaultListener</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>rpcrouter</servlet-name>
    <url-pattern>/servlet/rpcrouter</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>messagerouter</servlet-name>
    <url-pattern>/servlet/messagerouter</url-pattern>
  </servlet-mapping>
</web-app>
-------------------------------------------------------------------------------------------------------------------------------












import javax.servlet.http.*;

import util.HTMLFilter;

public class RequestParamExample3 extends HttpServlet {
  
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException
  {
    System.out.println("doGet");
    response.setContentType("text/html");

    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");

    out.println("<title>" + "Request Parameters Example" + "</title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");


    out.println("<h3>" + "Request Parameters Example" + "</h3>");

    //From textfelds in browser post the data to the server
   out.println("<P>");
   out.print("<form action=\"http://cleaver:8080/Wins/RequestParamExample3\"");
   out.println("method=POST>");
   out.println("First Name");
   //firstname is a parameter
   out.println("<input type=text size=20 name=firstname value=Xu>");
   out.println("<br>");
   out.println("Last Name");
   out.println("<input type=text size=20 name=lastname value=Yuming>");
   out.println("<br>");
   out.println("<input type=submit>");
   out.println("</form>");

        if(request == null) System.out.println("Get request is null.");

    String firstName = request.getParameter("firstname");
    System.out.println("firstname = " + firstName);
    String lastName = request.getParameter("lastname");
    System.out.println("lastName = " + lastName);
    out.println("Parameters in this request: " + "<br>");
    //Writing the values in the webbrowser
    if (firstName != null || lastName != null) {
      out.println("First Name: ");
      out.println(" = " + firstName + "<br>");

      out.println("Last Name: ");

      out.println(" = " + lastName + "<br>");

    }
    else {
      out.println("requestparams.no-params");
    }

    out.println("</body>");
    out.println("</html>");
  }

  public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
      throws IOException, ServletException
  {
    System.out.println("doPost");
    doGet(request, response);
  }

}


Best
Feilong
 
Mime
View raw message