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_HTTPSERVLETREQ
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:faultListener>
</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
>

Reply via email to