You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Love, Lawrence" <LL...@coh.org> on 2004/08/05 19:00:20 UTC

Need assistance with properly binding a webservice to a java clas s

Over the past year or so our group has been participating in an open-source
project that involves several healthcare and medical centers and utilizes
technologies such as OpenEMed, Pids, COAS, Shark, and HL7.  Though you may
(or may not) be familiar with these, I'm making the assumption that in the
situation the exact particulars are not necessarily important.

To make a long story short, we're writing Java Beans and JSP pages (over
Resin) that utilize classes that come from OpenEmed and other such projects.
We're currently trying to use Axis to expose some of our classes as web
services.

To do so, we used examples to write our own WSDD files and we've
successfully deployed some of our classes as web services.  Next we used
WSDL2Java to create the proxy classes needed to write JSP clients to consume
these web services and ultimately we'd like to remotely call our class
methods from Shark (our workflow engine).  In order to accomplish this,
we've looked through some of the examples (which have been few and far
bewteen) and we've written a test page that posts to a servlet (again based
on an existing code sample).  This servlet has a doGet() method that uses
the WSDL2Java created PortType and ServiceLocator files.  (See
ProtocolMgrServlet.java code below)

Our problem is that the resulting PortType return value is always null even
when it shouldn't be.  Even if we have the servlet call a simple method that
only returns "Hello, World", the PortType return value is always null.
Looking at the Resin logs, the servlet seems to be sending the appropriate
SOAP request envelope and is receiving a subsequent SOAP response envelope,
but it never returns the correct value.  It seems to us as though it's not
actually communicating with the bean/class.

We'd like to know what we can do (ie what code we'd have to show you) in
order for us to get your assistance in troubleshooting our code and figuring
out what (if any ) our binding issues may be.

For now, I'll just show you the servlet, but I'd be more than happy to send
you more, once I know what you'd be interested in seeing.

Thanks you,
Lawrence Love
Programmer
City of Hope
626-359-8111 x64415
llove@coh.org


===================================
== BEGIN ProtocolMgrServlet.java ==
===================================

package org.coh.First.Protocol;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class ProtocolMgrServlet extends HttpServlet {
  private static final String CONTENT_TYPE = "text/html";

  //Initialize global variables
  public void init() throws ServletException {
  }

  //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>ProtocolMgrServlet</title></head>");
    out.println("<body bgcolor=\"#ffffff\">");
    out.println("<p>The servlet has received a " + request.getMethod() + ".
This is the reply.</p>");

    ProtocolMgrPortType pmpt = null;
    try{
        ProtocolMgrServiceLocator pmsl = new ProtocolMgrServiceLocator();
        pmpt = pmsl.getProtocolMgr(new
java.net.URL("http://localhost:8080/axis/servlet/AxisServlet/ProtocolMgr"));

        String paramProtocol = request.getParameter("protocol");
        String paramState = request.getParameter("state");


        if (request.getParameter("version").equals("2"))
        {
          String results = pmpt.setProtocolState2(paramProtocol,
paramState);
          out.println("Result:  " + results + "<br><br>");

        }
        else
        {
            boolean results = pmpt.setProtocolState(paramProtocol,
paramState);
          out.println("Result:  " + results + "<br><br>");
        }

        out.println("paramProtocol:" + paramProtocol + "<br>");
        out.println("paramState:" + paramState + "<br>");
    }
    catch(Exception ex){
        ex.printStackTrace();
        out.println("Result: EXCEPTION!"+ex);
    }
    catch(Error e) {
        e.printStackTrace();
        out.println("Result: ERROR!"+e);

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

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
    doGet(request, response);
  }

  //Clean up resources
  public void destroy() {
  }
}

=================================
== END ProtocolMgrServlet.java ==
=================================

-----------------------------------------------------------
SECURITY/CONFIDENTIALITY WARNING:  This message and any attachments are intended solely for the individual or entity to which they are addressed. This communication may contain information that is privileged, confidential, or exempt from disclosure under applicable law (e.g., personal health information, research data, financial information). Because this e-mail has been sent without encryption, individuals other than the intended recipient may be able to view the information, forward it to others or tamper with the information without the knowledge or consent of the sender. If you are not the intended recipient, or the employee or person responsible for delivering the message to the intended recipient, any dissemination, distribution or copying of the communication is strictly prohibited. If you received the communication in error, please notify the sender immediately by replying to this message and deleting the message and any accompanying files from your system. If, due to the
security risks, you do not wish to receive further communications via e-mail, please reply to this message and inform the sender that you do not wish to receive further e-mail from the sender.
===========================================================