Hi,

I have deployed  service with scope set to 'Session'. When I invoke this
service (The service just returns me the session id) , the session id
returned is always null. I am using iPalnet web Server and Apache SOAP
2.2 on Solaris 5.8.


root[sh]@wajra# java org.apache.soap.server.ServiceManagerClient
http://wajra.india.sun.com:85/soap/rpcrouter list
Deployed Services:
        urn:Hello
root[sh]@wajra# java org.apache.soap.server.ServiceManagerClient
http://wajra.india.sun.com:85/soap/rpcrouter query urn:Hello
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment";
id="urn:Hello" checkMustUnderstands="false">
<isd:provider type="java" scope="Session" methods="sayHelloTo">
<isd:java class="com.iplanet.iabs.SOAPplugin.iabswebservice"
static="false"/>
</isd:provider>
</isd:service>


I am sending the snippet of code for Service as well as client.

service :

public class iabswebservice
{
   public String sayHelloTo(org.apache.soap.rpc.SOAPContext soapCtx,
String name)
  {
     HttpSession httpSess= (HttpSession)
soapCtx.getProperty(org.apache.soap.Constants.BAG_HTTPSESSION);
     String str = httpSess.getId();
     System.out.println("sayHelloTo(String name)");
     request.getSession(true);
     return "Hello " + name + ", How are you doing?" + "  , Your Session
ID is " +  str;
  }
}


client :

 public static void main(String[] args) throws Exception
                            {
                               if(args.length == 0)
                               {
                                  System.err.println("Usage: java
hello.Client [SOAP-router-URL] ");
                                  System.exit (1);
                               }

                               try
                               {
                                  URL url = null;
                                  String name = null;
                                  if(args.length == 2)
                                  {
                                     url = new URL(args[0]);
                                     name = args[1];
                                  }
                                  else
                                  {
                                     url = new
URL("http://wajra.india.sun.com:85/soap/rpcrouter";);
                                     name = args[0];
                                  }

                                  // Build the call.
                                  SOAPHTTPConnection shc = new
SOAPHTTPConnection ();
                                  shc.setMaintainSession (true);
                                  Call call = new Call();
                                  call.setTargetObjectURI("urn:Hello");
                                  call.setMethodName("sayHelloTo");

call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
                                  call.setSOAPTransport (shc);
                                  Vector params = new Vector();
                                  params.addElement(new
Parameter("name", String.class, name, null));
                                  call.setParams(params);

                                  // Invoke the call.
                                  Response resp = null;
                                  try
                                  {
                                     resp = call.invoke(url, "");
                                  }
                                  catch( SOAPException e )
                                  {
                                     System.err.println("Caught
SOAPException (" + e.getFaultCode() + "): " + e.getMessage());
                                     System.exit(-1);
                                  }

                                  // Check the response.
                                  if( !resp.generatedFault() )
                                  {
                                     Parameter ret =
resp.getReturnValue();
                                     Object value = ret.getValue();
                                     System.out.println(value);
                                  }
                                  else
                                  {
                                     Fault fault = resp.getFault();
                                     System.err.println("Generated
fault: ");
                                     System.out.println ("  Fault Code
= " + fault.getFaultCode());
                                     System.out.println ("  Fault String
= " + fault.getFaultString());
                                  }
                                  resp = null;
                                  Call Nextcall = new Call();

Nextcall.setTargetObjectURI("urn:Hello");
                                  Nextcall.setMethodName("sayHelloTo");

Nextcall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
                                  Nextcall.setSOAPTransport (shc);
                                  Vector nextparams = new Vector();
                                  nextparams.addElement(new
Parameter("name", String.class, name, null));
                                  Nextcall.setParams(nextparams);

                                  try
                                  {
                                     resp = Nextcall.invoke(url, "");
                                  }
                                  catch( SOAPException e )
                                  {
                                     System.err.println("Caught
SOAPException (" + e.getFaultCode() + "): "+ e.getMessage());
                                     System.exit(-1);
                                  }

                                  // Check the response.
                                  if( !resp.generatedFault() )
                                  {
                                     Parameter ret =
resp.getReturnValue();
                                     Object value = ret.getValue();
                                     System.out.println(value);
                                  }
                                  else
                                  {
                                     Fault fault = resp.getFault();
                                     System.err.println("Generated
fault: ");
                                     System.out.println ("  Fault Code
= " + fault.getFaultCode());
                                     System.out.println ("  Fault String
= " + fault.getFaultString());
                                  }

                               }
                               catch(Exception e)
                               {
                                  e.printStackTrace();
                               }
                            }
                         }


Thanks and Regards
Rajashekar



Reply via email to