You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Pierre Yves Monnet <pi...@cgey.com> on 2002/10/29 09:59:10 UTC

How to integrate SOAP 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


Re: How to integrate SOAP in a Servlet ?

Posted by Scott Nichol <sn...@scottnichol.com>.
See http://xml.apache.org/soap/faq/faq_chawke.html#Q1_4.

Scott Nichol
----- Original Message -----
From: "Pierre Yves Monnet" <pi...@cgey.com>
To: <so...@xml.apache.org>
Sent: Wednesday, October 30, 2002 12:22 PM
Subject: Re: How to integrate SOAP in a Servlet ?


Thanks for your answer Scott ! I really appreciate your help !

>
> Q1 : I found two class extending HttpServlet : RPCRouterServlet and
> MessageRouterServlet : what is the difference between this two objects
?
>
> The RPCRouterServlet should be invoked when you are exposing "normal"
> methods on your service class.  The MessageRouterServlet should be
> invoked when the service class implements methods with the "messaging
> signature"
==> Ok, you confirm my supposition. I used this class because one of my
collegue, using soap directly, detect this class is used
via a PrintStackTrace in the server method.
Question closed.

> Q2 : Is myt method correct ?
>
> This I do not know.  I've never seen someone explicitly create an
> instance of a servlet class and delegate to it.  I guess if you have
all
> the config stuff for the instance to which you delegate included in
the
> config of the delegator, initialization should work.  Why do you
> delegate to doPost in the service method?  Shouldn't you delegate to
> service?
>
==> You rigth, I believe that service() wasn't declared. I change that
(but my problem is still the same, see below)
Question closed.

> Q3 : on which parameter do I need to switch ?
>
> Typically, there is no parameter on which to switch, as the URLs used
> look like http://host:port/soap/servlet/rpcrouter and
> http://host:port/soap/servlet/messagerouter.  However, you can encode
> whatever you want in the URL to determine how to switch: none of the
> SOAP code cares about the URL.
==> Super to know that ! Thanks.
Question closed.



>
> Q4 : is all the soap administration will work ?
>
> The command line admin should work.  If you deploy the Apache SOAP
> webapp, the JSP pages will work, too.
==> You right, it is working fine.
Question closed.


Q5 : error on the server :

I get an error on my client :
Generated fault: [Attributes={}] [faultCode=SOAP-ENV:Server.Exception:]
[faultString=org.w3c.dom.Node: method
getNamespaceURI()Ljava/lang/String; not found]
[faultActorURI=/servlet/uwa.maya.engine.MayaEngine] [DetailEntries=]
[FaultEntries=]

on the server, the method
org.apache.soap.transport.TransportMessage.unmarshall() fails during the
call
      return Envelope.unmarshall(doc.getDocumentElement());

This is an java.lang.NoSuchMethodError exception ( ?? ) in the XML
reader ??
Is somebody has an idea ?

I used the last version of xerces, and the version 2.3 of soap with a
JDK 1.3





--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: How to integrate SOAP in a Servlet ?

Posted by Scott Nichol <sn...@scottnichol.com>.
See http://xml.apache.org/soap/faq/faq_chawke.html#Q1_4.

Scott Nichol
----- Original Message -----
From: "Pierre Yves Monnet" <pi...@cgey.com>
To: <so...@xml.apache.org>
Sent: Wednesday, October 30, 2002 12:22 PM
Subject: Re: How to integrate SOAP in a Servlet ?


Thanks for your answer Scott ! I really appreciate your help !

>
> Q1 : I found two class extending HttpServlet : RPCRouterServlet and
> MessageRouterServlet : what is the difference between this two objects
?
>
> The RPCRouterServlet should be invoked when you are exposing "normal"
> methods on your service class.  The MessageRouterServlet should be
> invoked when the service class implements methods with the "messaging
> signature"
==> Ok, you confirm my supposition. I used this class because one of my
collegue, using soap directly, detect this class is used
via a PrintStackTrace in the server method.
Question closed.

> Q2 : Is myt method correct ?
>
> This I do not know.  I've never seen someone explicitly create an
> instance of a servlet class and delegate to it.  I guess if you have
all
> the config stuff for the instance to which you delegate included in
the
> config of the delegator, initialization should work.  Why do you
> delegate to doPost in the service method?  Shouldn't you delegate to
> service?
>
==> You rigth, I believe that service() wasn't declared. I change that
(but my problem is still the same, see below)
Question closed.

> Q3 : on which parameter do I need to switch ?
>
> Typically, there is no parameter on which to switch, as the URLs used
> look like http://host:port/soap/servlet/rpcrouter and
> http://host:port/soap/servlet/messagerouter.  However, you can encode
> whatever you want in the URL to determine how to switch: none of the
> SOAP code cares about the URL.
==> Super to know that ! Thanks.
Question closed.



>
> Q4 : is all the soap administration will work ?
>
> The command line admin should work.  If you deploy the Apache SOAP
> webapp, the JSP pages will work, too.
==> You right, it is working fine.
Question closed.


Q5 : error on the server :

I get an error on my client :
Generated fault: [Attributes={}] [faultCode=SOAP-ENV:Server.Exception:]
[faultString=org.w3c.dom.Node: method
getNamespaceURI()Ljava/lang/String; not found]
[faultActorURI=/servlet/uwa.maya.engine.MayaEngine] [DetailEntries=]
[FaultEntries=]

on the server, the method
org.apache.soap.transport.TransportMessage.unmarshall() fails during the
call
      return Envelope.unmarshall(doc.getDocumentElement());

This is an java.lang.NoSuchMethodError exception ( ?? ) in the XML
reader ??
Is somebody has an idea ?

I used the last version of xerces, and the version 2.3 of soap with a
JDK 1.3





Re: How to integrate SOAP in a Servlet ?

Posted by Pierre Yves Monnet <pi...@cgey.com>.
Thanks for your answer Scott ! I really appreciate your help !

> 
> Q1 : I found two class extending HttpServlet : RPCRouterServlet and
> MessageRouterServlet : what is the difference between this two objects ?
> 
> The RPCRouterServlet should be invoked when you are exposing "normal"
> methods on your service class.  The MessageRouterServlet should be
> invoked when the service class implements methods with the "messaging
> signature"
==> Ok, you confirm my supposition. I used this class because one of my collegue, using soap directly, detect this class is used
via a PrintStackTrace in the server method.
Question closed.

> Q2 : Is myt method correct ?
> 
> This I do not know.  I've never seen someone explicitly create an
> instance of a servlet class and delegate to it.  I guess if you have all
> the config stuff for the instance to which you delegate included in the
> config of the delegator, initialization should work.  Why do you
> delegate to doPost in the service method?  Shouldn't you delegate to
> service?
> 
==> You rigth, I believe that service() wasn't declared. I change that (but my problem is still the same, see below)
Question closed.

> Q3 : on which parameter do I need to switch ?
> 
> Typically, there is no parameter on which to switch, as the URLs used
> look like http://host:port/soap/servlet/rpcrouter and
> http://host:port/soap/servlet/messagerouter.  However, you can encode
> whatever you want in the URL to determine how to switch: none of the
> SOAP code cares about the URL.
==> Super to know that ! Thanks.
Question closed.



> 
> Q4 : is all the soap administration will work ?
> 
> The command line admin should work.  If you deploy the Apache SOAP
> webapp, the JSP pages will work, too.
==> You right, it is working fine.
Question closed.


Q5 : error on the server :

I get an error on my client :
Generated fault: [Attributes={}] [faultCode=SOAP-ENV:Server.Exception:] [faultString=org.w3c.dom.Node: method getNamespaceURI()Ljava/lang/String; not found] [faultActorURI=/servlet/uwa.maya.engine.MayaEngine] [DetailEntries=] [FaultEntries=]

on the server, the method 
org.apache.soap.transport.TransportMessage.unmarshall() fails during the call
      return Envelope.unmarshall(doc.getDocumentElement());

This is an java.lang.NoSuchMethodError exception ( ?? ) in the XML reader ??
Is somebody has an idea ?

I used the last version of xerces, and the version 2.3 of soap with a JDK 1.3



Re: How to integrate SOAP in a Servlet ?

Posted by Pierre Yves Monnet <pi...@cgey.com>.
Thanks for your answer Scott ! I really appreciate your help !

> 
> Q1 : I found two class extending HttpServlet : RPCRouterServlet and
> MessageRouterServlet : what is the difference between this two objects ?
> 
> The RPCRouterServlet should be invoked when you are exposing "normal"
> methods on your service class.  The MessageRouterServlet should be
> invoked when the service class implements methods with the "messaging
> signature"
==> Ok, you confirm my supposition. I used this class because one of my collegue, using soap directly, detect this class is used
via a PrintStackTrace in the server method.
Question closed.

> Q2 : Is myt method correct ?
> 
> This I do not know.  I've never seen someone explicitly create an
> instance of a servlet class and delegate to it.  I guess if you have all
> the config stuff for the instance to which you delegate included in the
> config of the delegator, initialization should work.  Why do you
> delegate to doPost in the service method?  Shouldn't you delegate to
> service?
> 
==> You rigth, I believe that service() wasn't declared. I change that (but my problem is still the same, see below)
Question closed.

> Q3 : on which parameter do I need to switch ?
> 
> Typically, there is no parameter on which to switch, as the URLs used
> look like http://host:port/soap/servlet/rpcrouter and
> http://host:port/soap/servlet/messagerouter.  However, you can encode
> whatever you want in the URL to determine how to switch: none of the
> SOAP code cares about the URL.
==> Super to know that ! Thanks.
Question closed.



> 
> Q4 : is all the soap administration will work ?
> 
> The command line admin should work.  If you deploy the Apache SOAP
> webapp, the JSP pages will work, too.
==> You right, it is working fine.
Question closed.


Q5 : error on the server :

I get an error on my client :
Generated fault: [Attributes={}] [faultCode=SOAP-ENV:Server.Exception:] [faultString=org.w3c.dom.Node: method getNamespaceURI()Ljava/lang/String; not found] [faultActorURI=/servlet/uwa.maya.engine.MayaEngine] [DetailEntries=] [FaultEntries=]

on the server, the method 
org.apache.soap.transport.TransportMessage.unmarshall() fails during the call
      return Envelope.unmarshall(doc.getDocumentElement());

This is an java.lang.NoSuchMethodError exception ( ?? ) in the XML reader ??
Is somebody has an idea ?

I used the last version of xerces, and the version 2.3 of soap with a JDK 1.3



Re: How to integrate SOAP in a Servlet ?

Posted by Scott Nichol <sn...@scottnichol.com>.
Pierre-Yves,

I passed on this posting previously because I am not sure what you are
doing with RPCRouterServlet will work.  However, I might be able to
answer some of your questions.

Q1 : I found two class extending HttpServlet : RPCRouterServlet and
MessageRouterServlet : what is the difference between this two objects ?

The RPCRouterServlet should be invoked when you are exposing "normal"
methods on your service class.  The MessageRouterServlet should be
invoked when the service class implements methods with the "messaging
signature"

    public void methodName(Envelope env, SOAPContext reqCtx, SOAPContext
resCtx)

Q2 : Is myt method correct ?

This I do not know.  I've never seen someone explicitly create an
instance of a servlet class and delegate to it.  I guess if you have all
the config stuff for the instance to which you delegate included in the
config of the delegator, initialization should work.  Why do you
delegate to doPost in the service method?  Shouldn't you delegate to
service?

Q3 : on which parameter do I need to switch ?

Typically, there is no parameter on which to switch, as the URLs used
look like http://host:port/soap/servlet/rpcrouter and
http://host:port/soap/servlet/messagerouter.  However, you can encode
whatever you want in the URL to determine how to switch: none of the
SOAP code cares about the URL.

Q4 : is all the soap administration will work ?

The command line admin should work.  If you deploy the Apache SOAP
webapp, the JSP pages will work, too.

Scott Nichol

----- Original Message -----
From: "Pierre Yves Monnet" <pi...@cgey.com>
To: <so...@xml.apache.org>
Sent: Tuesday, October 29, 2002 3:59 AM
Subject: How to integrate SOAP 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




--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>


Re: How to integrate SOAP in a Servlet ?

Posted by Scott Nichol <sn...@scottnichol.com>.
Pierre-Yves,

I passed on this posting previously because I am not sure what you are
doing with RPCRouterServlet will work.  However, I might be able to
answer some of your questions.

Q1 : I found two class extending HttpServlet : RPCRouterServlet and
MessageRouterServlet : what is the difference between this two objects ?

The RPCRouterServlet should be invoked when you are exposing "normal"
methods on your service class.  The MessageRouterServlet should be
invoked when the service class implements methods with the "messaging
signature"

    public void methodName(Envelope env, SOAPContext reqCtx, SOAPContext
resCtx)

Q2 : Is myt method correct ?

This I do not know.  I've never seen someone explicitly create an
instance of a servlet class and delegate to it.  I guess if you have all
the config stuff for the instance to which you delegate included in the
config of the delegator, initialization should work.  Why do you
delegate to doPost in the service method?  Shouldn't you delegate to
service?

Q3 : on which parameter do I need to switch ?

Typically, there is no parameter on which to switch, as the URLs used
look like http://host:port/soap/servlet/rpcrouter and
http://host:port/soap/servlet/messagerouter.  However, you can encode
whatever you want in the URL to determine how to switch: none of the
SOAP code cares about the URL.

Q4 : is all the soap administration will work ?

The command line admin should work.  If you deploy the Apache SOAP
webapp, the JSP pages will work, too.

Scott Nichol

----- Original Message -----
From: "Pierre Yves Monnet" <pi...@cgey.com>
To: <so...@xml.apache.org>
Sent: Tuesday, October 29, 2002 3:59 AM
Subject: How to integrate SOAP 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