You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Marcus Daley <ma...@mdaley.net> on 2000/12/28 04:04:04 UTC

Help with Standard HTTP Servlets and SOAP

Let me first apologize, since I am a newbie.

I am currently building a system where there is only one single entry point.  That entry point is a single standard servlet (it does not extend RPCRouterServlet).  I would like to capture the message that is contained within the HttpServletRequest object and then respond using the HttpServletResponse object.  Again, please note, this is via a standard servlet, not RPCRouterServlet.

Does anyone have any advice?  Suggestions or examples.  I would just like to get the message, call a method specified in that message (with parameters if so), then return a response.

I have done a lot of due diligence in getting this far and my environment is setup and working.  Thanks in advance for any assistance.





SIDE NOTE:  In an effort to at least partially get there, I am simply building a plain String response and sending it back to the client.  It appears to be formatted properly and is accepted by xerces.  However, I always get a java.lang.NoSuchMethodError.  Now, if I could use SOAP4J to build the response object, then this problem would go away.  Anyhow, here is my request message:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getRecordsSince xmlns:ns1="urn:xml ContactSync" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<customerId xsi:type="xsd:int">1</customerId>
<logIndex xsi:type="xsd:int">1</logIndex>
</ns1:getRecordsSince>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is my response message:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getRecordsSinceResponse xmlns:ns1="urn:xml ContactSync" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">stuff</return>
</ns1:getRecordsSinceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

That reponse always gives me this exception:
java.lang.NoSuchMethodError
        at org.apache.soap.util.xml.QName.<init>(QName.java:80)
        at org.apache.soap.util.xml.QName.matches(QName.java:146)
        at org.apache.soap.Envelope.unmarshall(Envelope.java:210)
        at org.apache.soap.rpc.Call.invoke(Call.java:172)
        at oom.system.soap.Ocontact.main(Ocontact.java:67)

Re: Help with Standard HTTP Servlets and SOAP

Posted by Aleksander Slominski <as...@cs.indiana.edu>.
Marcus Daley wrote:

> Let me first apologize, since I am a newbie. I am currently building a system
> where there is only one single entry point.  That entry point is a single
> standard servlet (it does not extend RPCRouterServlet).  I would like to
> capture the message that is contained within the HttpServletRequest object and
> then respond using the HttpServletResponse object.  Again, please note, this
> is via a standard servlet, not RPCRouterServlet.Does anyone have any advice?
> Suggestions or examples.  I would just like to get the message, call a method
> specified in that message (with parameters if so), then return a response.I
> have done a lot of due diligence in getting this far and my environment is
> setup and working.  Thanks in advance for any assistance.

hi,

i think that probably you will need to wrap functionality of RPCRouterServlet
into some utility object and call it from your servlet. i have written
lightweight soap-rmi and we use there SoapDispatcher object therefore you can
have:

  public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws  ServletException, IOException
  {
    if(dsptr == null) initSoap(HttpUtils.getRequestURL(req).toString());

    dsptr.dispatch(req.getReader(), res.getWriter());
  }
  /* Private SOAP dispatcher - only for this servlet. */
  private static SoapDispatcher dsptr;

of course you need to register your object with dispatcher (in this example it
is is initSoap()) but this way actual an object implementing the service can be
separated from the servlet (if necessary).


> </SOAP-ENV:Envelope>That reponse always gives me this
> exception:java.lang.NoSuchMethodError
>         at org.apache.soap.util.xml.QName.<init>(QName.java:80)
>         at org.apache.soap.util.xml.QName.matches(QName.java:146)
>         at org.apache.soap.Envelope.unmarshall(Envelope.java:210)
>         at org.apache.soap.rpc.Call.invoke(Call.java:172)
>         at oom.system.soap.Ocontact.main(Ocontact.java:67)

that means probably that you  need to change xerces.jar you are using.

alek
--
Aleksander Slominski, IU, http://www.extreme.indiana.edu/~aslom
As I look afar I see neither cherry Nor tinted leaves Just a modest hut
on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)




Re: Help with Standard HTTP Servlets and SOAP

Posted by Aleksander Slominski <as...@cs.indiana.edu>.
Marcus Daley wrote:

> Let me first apologize, since I am a newbie. I am currently building a system
> where there is only one single entry point.  That entry point is a single
> standard servlet (it does not extend RPCRouterServlet).  I would like to
> capture the message that is contained within the HttpServletRequest object and
> then respond using the HttpServletResponse object.  Again, please note, this
> is via a standard servlet, not RPCRouterServlet.Does anyone have any advice?
> Suggestions or examples.  I would just like to get the message, call a method
> specified in that message (with parameters if so), then return a response.I
> have done a lot of due diligence in getting this far and my environment is
> setup and working.  Thanks in advance for any assistance.

hi,

i think that probably you will need to wrap functionality of RPCRouterServlet
into some utility object and call it from your servlet. i have written
lightweight soap-rmi and we use there SoapDispatcher object therefore you can
have:

  public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws  ServletException, IOException
  {
    if(dsptr == null) initSoap(HttpUtils.getRequestURL(req).toString());

    dsptr.dispatch(req.getReader(), res.getWriter());
  }
  /* Private SOAP dispatcher - only for this servlet. */
  private static SoapDispatcher dsptr;

of course you need to register your object with dispatcher (in this example it
is is initSoap()) but this way actual an object implementing the service can be
separated from the servlet (if necessary).


> </SOAP-ENV:Envelope>That reponse always gives me this
> exception:java.lang.NoSuchMethodError
>         at org.apache.soap.util.xml.QName.<init>(QName.java:80)
>         at org.apache.soap.util.xml.QName.matches(QName.java:146)
>         at org.apache.soap.Envelope.unmarshall(Envelope.java:210)
>         at org.apache.soap.rpc.Call.invoke(Call.java:172)
>         at oom.system.soap.Ocontact.main(Ocontact.java:67)

that means probably that you  need to change xerces.jar you are using.

alek
--
Aleksander Slominski, IU, http://www.extreme.indiana.edu/~aslom
As I look afar I see neither cherry Nor tinted leaves Just a modest hut
on the coast In the dusk of Autumn nightfall - Fujiwara no Teika (1162-1241)