• Post Reply Bookmark Topic Watch Topic
  • New Topic

execution error in SOAP client-server

 
kavitha Nash
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am trying to access a SOAP service from the WAS3.5 server.
i have a server program as follows
-------------------------------------------------------------
public class HelloServer
{
public String sayHelloTo(String name)
{
return ( name + new String("hello"));
}
}
}
-------------------------------------------------------------
i deployed the service tru Apache SOAP-Admins ... sucessfully. these is the deployed service info :
-------------------------------------------------------------
ID 'urn:Hello'
scope Apllication
Provider Type java
Provider Class hello.HelloServer
Use Static Class no
MethodssayHelloTo
Type Mappings--
Default Mapping Registry Class--
-------------------------------------------------------------
The client programe-------------------------------------------------------------
package hello;
import java.net.URL;
import java.util.Vector;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;

import java.util.Iterator;public class 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://localhost/soap/servlet/rpcrouter");
name = args[0];
}
System.out.println("b4 constructing the soap file");
// Build the call.
Call call = new Call();
call.setTargetObjectURI("urn:Hello");

call.setMethodName("sayHelloTo");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement(new Parameter("name", String.class, name, null));
call.setParams(params);
System.out.println("constructed soap xml request hello");
// 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.
System.out.println("b4 response");
if( !resp.generatedFault() )
{
System.out.println("if block");
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());

Vector entries = fault.getDetailEntries( );
for (Iterator i = entries.iterator(); i.hasNext( ); ) {
org.w3c.dom.Element entry = (org.w3c.dom.Element)i.next( );
System.out.println(entry.getFirstChild().getNodeValue( ));
}


}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
-------------------------------------------------------------
when i run the client i get the following error

Generated fault:
Fault Code = SOAP-ENV:Server.BadTargetObjectURI
Fault String = Unable to resolve target object: hello.HelloServer
java.lang.NullPointerException
java.lang.Throwable()
java.lang.Exception()
java.lang.RuntimeException()
java.lang.NullPointerException()
void hello.Client.main(java.lang.String [])
void hello.Client.main(java.lang.String [])
can anyone tell me why client is uable to acess the HelloServer class..
thanx,
kavitha
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!