You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Chen, Donald" <dc...@nrgn.com> on 2005/08/11 17:39:47 UTC

"The AXIS engine could not find a target service to invoke! targetService is null" error

Hi, All.

I was following the instruction presented by an article written at 01
Jan 2003(is this article a bit out-of-date? Given the progress of Axis)
-- 

http://www-128.ibm.com/developerworks/webservices/library/ws-eight/#code
2

And I was trying the "EightBall" example presented in the article,
hoping to get a sense of deploying a web service via Axis.

Basically, the "EightBall" service is encapsulated in this java code:

--------8<-------------------------------
import java.util.Random;
import java.lang.Double;
import java.util.Date;

public class EightBall {
  static String answers[] = {"Yes.",
   "Outlook not so good.",
  // The other 17 answers were
  // removed for brevity.
   "Don't count on it."};
   
  public static String getAnswer() {
    return askQuestion("");
  }
  
  public static String askQuestion
    String question) {
    java.util.Random r = new Random
      (new Date().getTime());
    java.lang.Double d = new Double
      ((r.nextDouble()*20)-1);
    return new String(answers[d.intValue()]);
  }
  
  public static void main(String args[]) {
    System.out.println(getAnswer());
  }
}
--------8<-------------------------------

I "javac" this java file and copied the EightBallclass file into the
...\tomcat_direcory\webapps\axis\WEB-INF\classes.

Then I ran " java org.apache.axis.client.AdminClient
DeployEightBall.wsdd" on the DeployEightBall.wsdd file (see below):

--------8<-------------------------------
<deployment xmlns=
    "http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/
      wsdd/providers/java">
  <service name="urn:EightBall"
      provider="java:RPC">
     <parameter name="className"
        value="EightBall"/>
     <parameter name="allowedMethods"
        value="getAnswer askQuestion"/>
  </service>
</deployment>
--------8<-------------------------------

So far so good.

Then I tried to compile and then ran the EightBallClient1 code(see
below):
--------8<-------------------------------
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

public class EightBallClient1 {
  public static void main(String [] args) throws Exception {
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new
java.net.URL("http://localhost:8080/axis/servlet/AxisServlet"));
    call.setOperationName(new QName("urn:EightBall", "getAnswer"));
    try {
           System.out.println(call.invoke(new Object[] { }));
        } catch (java.rmi.RemoteException re) {
           System.out.println("Error - " + re);
         }
}
}
--------8<-------------------------------

This is the place where I got the error:

   The AXIS engine could not find a target service to invoke!
targetService is nul

Any idea?

I also restarted the Tomcat, and that did not help.

I use WinXP-Pro, Tomcat5.5, Axis1.2, JRE/JDK1.5.

Thanks in advance,

Don