I quickly set up my notebook (downloaded soap 2.2 and tomcat 4.0.3) to run
the bytecode you sent.  My notebook is Windows 98 and JDK 1.3.1.  Your byte
code works fine for me.  The only thing I do that sounds different is that I
do not copy HellowWorldService.class to $CATALINA_HOME/common/classes.  I
copy it to $CATALINA_HOME/webapps/soap/WEB-INF/classes;
$CATALINA_HOME/webapps/soap is the directory into which I un-jar soap.war.
I'll give it a quick whirl using your method.

Scott

----- Original Message -----
From: "Andrew Trieger" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 13:15
Subject: Re: using SOAPContext as first argument in RPC SOAP messages class
notworking


> sure, i'm sending this just to you since the list probably doesnt want to
see bytecode...
> Drew
>
> Scott Nichol wrote:
>
>   Andrew,
>   Could you send me byte code for the service, i.e.
HelloWorldService.class?
>   If you can, I'll run it from my rig at home tonight to see how it works
for
>   me.
>
>   Scott
>
>   ----- Original Message -----
>   From: "Andrew Trieger" <[EMAIL PROTECTED]>
>   To: <[EMAIL PROTECTED]>
>   Sent: Monday, April 22, 2002 12:48
>   Subject: Re: using SOAPContext as first argument in RPC SOAP messages
class
>   notworking
>
>   > Scott,
>   >     OK.  I now reproduced the error on my win2k (professional) box as
>   well.  To reiterate from the previous email response from me, I took
your
>   server class, put it in tomcat/classes and compiled it on my OSX box
(java
>   1.3.1_02, soap2.2, tomcat 4.0.1).
>   >     I deployed the service using the /soap/admin gui with the same
names,
>   parameters as is listed below.
>   >     I created the class for the client cut/paste from below (was
missing a
>   "("'s, but fixed that) into a separate directory on this same box,
compiled
>   it, ran it.
>   >
>   >     Got the same error.
>   >
>   >     Copied the tomcat server to my win2k box where java 1.3.1_02 JRE
from
>   javasoft already is installed.  ran tomcat without recompiles or
>   redeployments, started ok.
>   >
>   >     used the same client back on the OSX box to message the helloworld
>   service on the win2k box and got the same error.
>   >
>   >
>   >     ?????
>   >
>   > Drew
>   >
>   >
>   >
>   > Scott Nichol wrote:
>   >
>   >   Drew,
>   >   I thought that maybe if you had a bad definition for
HttpServletRequest
>   that the
>   >   JIT might throw an exception when it compiles the method.
>   >
>   >   Anyway, I wrote the following service and client and was able to
>   successfully
>   >   run it.  My environment is Win2k, JDK 1.3.1, SOAP 2.2, Tomcat 4.0.1.
If
>   you
>   >   cannot get it to run, I could send you my bytecode to test.
>   >
>   >   Scott
>   >
>   >   import javax.servlet.http.*;
>   >   public class HelloWorldService {
>   >    public String hello(org.apache.soap.rpc.SOAPContext ctx) {
>   >     HttpServletRequest req =
>   >
>
(HttpServletRequest)ctx.getProperty(org.apache.soap.Constants.BAG_HTTPSERVLE
>   TREQ
>   >   UEST);
>   >     return req != null ? req.getQueryString() : "null";
>   >    }
>   >   }
>   >
>   >   <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment";
>   >                id="urn:helloworld">
>   >     <isd:provider type="java"
>   >                   scope="Application"
>   >                   methods="hello">
>   >       <isd:java class="HelloWorldService"/>
>   >     </isd:provider>
>   >
>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
>   r>
>   >   </isd:service>
>   >
>   >   import java.net.*;
>   >   import java.util.*;
>   >   import org.apache.soap.*;
>   >   import org.apache.soap.rpc.*;
>   >
>   >   public class HelloWorldClient {
>   >    public static void main(String[] args) throws Exception {
>   >        if (args.length != 1
>   >            && (args.length != 2 || !args[0].startsWith ("-"))) {
>   >          System.err.println ("Usage: java " +
>   HelloWorldClient.class.getName () +
>   >                              " [-encodingStyleURI] SOAP-router-URL");
>   >          System.exit (1);
>   >        }
>   >
>   >        // Process the arguments.
>   >        int offset = 2 - args.length;
>   >        String encodingStyleURI = args.length == 2
>   >                                  ? args[0].substring(1)
>   >                                  : Constants.NS_URI_SOAP_ENC;
>   >        URL url = new URL (args[1 - offset]);
>   >
>   >        // Build the call.
>   >        Call call = new Call ();
>   >        call.setTargetObjectURI ("urn:helloworld");
>   >        call.setMethodName ("hello");
>   >        call.setEncodingStyleURI(encodingStyleURI);
>   >        Vector params = new Vector ();
>   >        Response resp = call.invoke url, "" );
>   >
>   >        // Check the response.
>   >        if (resp.generatedFault ()) {
>   >          Fault fault = resp.getFault ();
>   >          System.out.println ("Ouch, the call failed: ");
>   >          System.out.println ("  Fault Code   = " + fault.getFaultCode
());
>   >          System.out.println ("  Fault String = " +
fault.getFaultString
>   ());
>   >        } else {
>   >          Parameter result = resp.getReturnValue ();
>   >          System.out.println (result.getValue ());
>   >        }
>   >    }
>   >   }
>   >
>   >   ----- Original Message -----
>   >   From: "Andrew Trieger" <[EMAIL PROTECTED]>
>   >   To: <[EMAIL PROTECTED]>
>   >   Sent: Friday, April 19, 2002 1:20 PM
>   >   Subject: Re: using SOAPContext as first argument in RPC SOAP
messages
>   class not
>   >   working
>   >
>   >   > Good idea, but I *think* its not even executing my method as my
first
>   >   > line println isnt coming out, so I'm screwed, but i might be able
to
>   >   > subclass rpcrouter servlet, use mine instead of theirs, catch
>   throwable
>   >   > and dump any info to stderr...
>   >   >
>   >   > Any idea if defining my own custom fault-handler would be helpful?
>   I'm
>   >   > not sure how that would help, but possibly it would be called by
the
>   >   > local soap stuff and given more error message info than is
returned in
>   >   > the soap response?  eh...  long shot.
>   >   >
>   >   > I might just have to call this feature "Too new to work" and wait
6mos
>   >   > and get along without it.  I could define a different soap router
url
>   >   > for EVERY method and then control access in iplanet... hassle.
>   >   >
>   >   > Drew
>   >   >
>   >
>   > --
>   > ---
>   >
>   >
>
> --
> ---
>
>


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


> import javax.servlet.http.*;
>
> public class HelloWorldService {
>  public String hello(org.apache.soap.rpc.SOAPContext ctx) {
>   HttpServletRequest req =
>
(HttpServletRequest)ctx.getProperty(org.apache.soap.Constants.BAG_HTTPSERVLE
TREQUEST);
>   return req != null ? req.getQueryString() : "null";
>  }
> }
>

Reply via email to