You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Thibault Chollet <t_...@hotmail.com> on 2002/11/03 22:30:49 UTC

Re: How to integrate SAOP in a Servlet ?

Hi,


I hope you already find your answers.

Here are my simple thoughts about your issues.

Regarding your first question, RPCRouterServlet is used to route RPC-based SOAP messages, whereas MessageRouterServlet is used to route Message-based SOAP messages. That means that if the first servlet is used, the server on which the Apache-SOAP runtime is installed will return a SOAP response. If the second servlet is used the server can do two things: either it just returns a http response (if you use http)  telling that the message has been received successfully or not, or it can send a SOAP response back to the client. Basically, you'll use RPC-based SOAP messages to call a method on the server side, and Message-based SOAP messages to exchange one-way messages between parties.

In Apache-SOAP, you specify the servlet responsible for routing the SOAP message in your deployment descriptor. This is done by specifying the optional attribute "type" of the service element (the root element). If you want a document-oriented (Message-based SOAP message), you'll have to specify : type="message". On the contrary, if you want a RPC-based service you do not specify this attribute.

Further, in Apache-SOAP, the RPC way does not allow you to work directly on the SOAP envelope (if you want to do so you'll have to write your own provider), whereas the Message one requires that you deal directly with SOAP envelopes.

--------------------------------------------------------------------------------

Regarding your second question, I don't think you could use directly the RPCRouterServlet  object (but this is my tought). I'm not sure about the following, but, I guess that clients of your MyEngine servlet do not deal with SOAP messages and any SOAP API. So if you pass directly the HttpServletRequest request and HttpServletResponse response to mSoapRouter.doPost, will they contains the necessary SOAP information?

What I would suggest is to extend your servlet as a SOAP client and use the Apache-SOAP API to make call to your service implementation classes or EJB via the Apache-SOAP runtime. Remember that according to the SOAP specifications you have to specify a method name and a URI to correctly
route your message to the right service method. To do so, just use a Call object from the Apache-SOAP library to send an RPC-based SOAP message to the web service. The basic code to make a call is as follow (assuming you have the SOAP-runtime integrated on your server):

static String DEFAULT_ENDPOINT = "http://localhost:8080/soap/servlet/rpcrouter";

      String endPoint = DEFAULT_ENDPOINT;
      Call call = new Call();
      call.setTargetObjectURI("urn:your-service-name");
      call.setMethodName("yourMethodName");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

      // Create a URL object, which represents the endpoint
      URL url = new URL(endPoint);

      // Send the SOAP RPC request message using invoke() method
      Response resp = call.invoke(url, "");

If you want to use a mesage-based SOAP message you'll use a Message object from the Apache-SOAP library and you'll have to build the SOAP envelope yourself.

--------------------------------------------------------------------------------

Regarding your third question, as I am not an expert with Java servlet coding, I prefer not to try to answer. However, I hope what it's above will help you.

--------------------------------------------------------------------------------

About your last question, I am pretty sure that the SOAP administration will work as normal, unless you want to administrate it from your myEngine servlet. If this is the case, I don't know whether it's possible and how to do it.

--------------------------------------------------------------------------------

As, I'm quite new to Apache-SOAP, I hope i did not make too many errors and that I was able to help you.


Je me pemets a mon tour de vous poser une question:
Je voudrais commencer ma carriere dans le conseil en technologies de l'information, et plus specifiquement, dans l'integration et l'implementation des systemes. Apres avoir obtenu une Matrise d'Informatique a Paris VI (mention bien), je vais finir en decembre un Master of Science in Telecommunications a Roosevelt University a Chicago. Savez-vous si Cap Gemini Ernst & Young prevoit de recruter debut 2003? Si oui, mon profil est-il susceptible d'interesser l'entreprise?

Cordialement,


Thibault Chollet
t_chollet@hotmail.com




  ----- Original Message ----- 
  From: Pierre Yves Monnet 
  To: soap-user@xml.apache.org 
  Cc: Pierre-Yves Monnet 
  Sent: Monday, October 28, 2002 10:08 AM
  Subject: How to integrate SAOP in a Servlet ?


  Hello,

  I have a Servlet program build in Java. I want to extend this servlet to be able :
  - to run the normalservice, as know
  - to integrate the SOAP mechanism.

  So, I would like to integrate something like this in my service() method :

  public class MyEngine extends HttpServlet
  {

  RPCRouterServlet  mSoapRouter;


    public void init(ServletConfig config) throws ServletException {

      mSoapRouter = new RPCRouterServlet ;
      mSoapRouter.init( config );

    public void service( HttpServletRequest request, HttpServletResponse response )
                     throws ServletException, IOException {
      if (request..getParameter( ??? )!=null)
      {
          // this is a SOAP command
          mSoapRouter.doPost( request, response );
          return
      }

  Q1 : I found two class extending HttpServlet : RPCRouterServlet and MessageRouterServlet : what is the difference between this two objects ?
  Q2 : Is myt method correct ?
  Q3 : on which parameter do I need to switch ?
  Q4 : is all the soap administration will work ?

  Thanks for your comments.


  Pierre-Yves Monnet


------------------------------------------------------------------------------

  Pierre-Yves Monnet - Project Manager

  Cap Gemini Ernst & Young



  Tél  :   33 (0) 4 76 52 64 23
  GSM:  33 (0) 6 86 74 49 86

  FAX : 33 (0)4 76 52 62 01 

  mail : Pierre-Yves.Monnet@capgemini.fr