This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes Can you please  help me out .... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Can you please  help me out ...." Watch "Can you please  help me out ...." New topic
Author

Can you please help me out ....

Anjana Chowdary
Greenhorn

Joined: Oct 25, 2005
Posts: 8
Hi,

I am facing this error from couple of days.

//This is the Exception i am getting while running client class.

Generated fault:
Fault Code = SOAP-ENV:Server.BadTargetObjectURI
Fault String = Unable to resolve target object:

Simply I am listing out the things i have done to run this WS.

// Service prg
package hello;
public class HelloWorld{

String getMessage(){
return "Hello world";
}
}
//client prg

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.net.URL;

public class Client
{
public static void main(String[] args) throws Exception
{

try
{
URL url = null;
String name = null;
// Build the call.

url = new URL("http://localhost:8085/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("urn:HelloWorldService");
call.setMethodName("getMessage");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

// 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() )
{
Object value = resp.getReturnValue();
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();
}
}
}

-> I set up class path with all these info..
%SOAP_HOME%\lib\soap.jar;
%TOMCAT_HOME%\common\lib\xerces.jar;
%TOMCAT_HOME%\common\lib\mail.jar;
%TOMCAT_HOME%\common\lib\activation.jar; and

-> I created service prg as jar file with the name of helloworld.jar and placed in class path.
%TOMCAT_HOME%\common\lib\helloworld.jar;
-> I am using the Apache SOAP Admin to deploy the service.
If run the following commands, working fine..

1) http://localhost:8085/soap/servlet/rpcrouter.
2) java orgapache.soap.server.ServiceManagerClient http://localhost:8085/soap/servlet/rpcrouter list.

-> I am using the same machine as a client and server.

if any one know about the solution, could u please reply me..
waiting for reply...

Thanks in advance,
Anjana

[ July 26, 2006: Message edited by: Anjana Chowdary ]
[ July 26, 2006: Message edited by: Anjana Chowdary ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can you please help me out ....