You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by venkata akella <ve...@yahoo.com> on 2001/12/05 02:44:18 UTC

Getting Server.BadTargetObjectURI

HI
  Can someone help me out here.
This is what I did.
Installed tomcat 4.0
Using soap2.2
and xerces2.0.0-beta3  

I did this setup on Win 2000 prof machine. 
I wrote a service with two methods. I have pasted that
class(TaxCalculator.java) here. I am able to deploy
this service using apache soap admin page. I can see
this in the list of deployed services on the admin
page. I wrote a client to access this service. I have
pasted that class(TaxCalClient.java) also at the end.
But when I tried to execute this class in my command
window its giving the following messages.

***** cut and pasted message displayed begin***

E:\Sastry\webservices\wsdemo>java TaxCalClient
invoke service
  URL= http://localhost:8080/soap/servlet/rpcrouter
  URN =urn:demo:taxcalculator
Fault= SOAP-ENV:Server.BadTargetObjectURI, Unable to
resolve target object: TaxCalculator

****** message end ***************

Here its giving Server.BadTargetObjectURI.. Can
someone help me why its giving this exception.
Please find the pasted service class and client class.



***Service class ***********

public class TaxCalculator  implements ITaxCalculator 
  {

  public double getStateTax(float totalSalary, String
stateCode) {

	// Get the percentage based on the statecode and
other factors

	System.out.println("State tax for the state" +
stateCode + " is"
 		+ totalSalary*0.3);
	return totalSalary * 0.3;

	}


  public double getFederalTax(float totalSalary, int
category) {

	System.out.println("fedefal tax for the salary " +
totalSalary 
		+ " is " + totalSalary * 0.2 );

	return totalSalary * 0.2;

    }

  }


****Client class************

import java.net.*; 
 import java.util.*; 
 import wsdemo.*;
 import org.apache.soap.*;  
 import org.apache.soap.rpc.*; 

 public class TaxCalClient
   { 
   public static void main( String[] args ) throws
Exception 
     { 
     URL url = new URL(
"http://localhost:8080/soap/servlet/rpcrouter" ); 
     String urn = "urn:demo:taxcalculator"; 

     Call call = new Call(); // prepare the service
invocation 
     call.setTargetObjectURI( urn ); 
     call.setMethodName( "getStateTax" ); 
     call.setEncodingStyleURI(
Constants.NS_URI_SOAP_ENC ); 

     Vector params = new Vector(); 
     params.addElement( new Parameter( "totalSalary",
Float.class, new Float(5000), null ) ); 
     params.addElement( new Parameter( "totalSalary",
String.class, "CA", null ) ); 
     call.setParams( params );
 
     try 
       { 
       System.out.println( "invoke service\n" + " 
URL= " + url + "\n  URN =" + 
          urn ); 
       Response response = call.invoke( url, "" ); //
invoke the service 
       if( !response.generatedFault() ) 
         { 
         Parameter result = response.getReturnValue();
// response was OK 
         System.out.println( "Result= " +
result.getValue() ); 
         } 
       else 
         { 
         Fault f = response.getFault(); // an error
occurred 
         System.err.println( "Fault= " +
f.getFaultCode() + ", " + 
           f.getFaultString() ); 
         } 
       } 
     catch( SOAPException e ) // call could not be
sent properly 
       { 
       System.err.println( "SOAPException= " +
e.getFaultCode() + ", " +  
         e.getMessage() ); 
       } 
     } 
   } 


Thanks in advance for your great help.
Sastry



__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com