类sample.stock.GetQuote如下:public class GetQuote {
    public  String symbol ;
    
  // helper function; does all the real work
    public float getQuote (String args[]) throws Exception {
      Options opts = new Options( args );      args = opts.getRemainingArgs();      if ( args == null ) {
        System.err.println( "Usage: GetQuote <symbol>" );
        System.exit(1);
      }      symbol = args[0] ;      // useful option for profiling - perhaps we should remove before
      // shipping?
      String countOption = opts.isValueSet('c');
      int count=1;
      if ( countOption != null) {
          count=Integer.valueOf(countOption).intValue();
          System.out.println("Iterating " + count + " times");
      }      URL url = new URL(opts.getURL());
      String user = opts.getUser();
      String passwd = opts.getPassword();      Service  service = new Service();      Float res = new Float(0.0F);
      for (int i=0; i<count; i++) {
          Call     call    = (Call) service.createCall();          call.setTargetEndpointAddress( url );
          call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") );
          call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
          call.setReturnType( XMLType.XSD_FLOAT );          // TESTING HACK BY ROBJ
          if (symbol.equals("XXX_noaction")) {
              symbol = "XXX";
          }          call.setUsername( user );
          call.setPassword( passwd );          Object ret = call.invoke( new Object[] {symbol} );
          if (ret instanceof String) {
              System.out.println("Received problem response from server: "+ret);
              throw new AxisFault("", (String)ret, null, null);
          }
        res = (Float) ret;
      }        return res.floatValue();
    }  public static void main(String args[]) {
    try {
        GetQuote gq = new GetQuote();
        float val = gq.getQuote(args);
        // args array gets side-effected
        System.out.println(gq.symbol + ": " + val);
    }
    catch( Exception e ) {
       e.printStackTrace();
    }
  }
  
  public GetQuote () {
  };};错误信息中的提示就是main方法中的:
float val = gq.getQuote(args);
和getQuote方法中的:
Object ret = call.invoke( new Object[] {symbol} );
出现错误

解决方案 »

  1.   

    我为什么看不到我的帖子呢?只有通过点击“我的问题”才能看到,而在“Java Web Services/XML(未解决问题)”的帖子列表中看不到呢?
      

  2.   

    我发现问题总是出现在:
    Object ret = call.invoke( new Object[] {symbol} );
    这一句上,试了好几个例子,只要运行到call.invoke()方法,就会出现上面的问题。
    这是怎么回事呢?郁闷啊!!
      

  3.   

    500错误的意思是找不到文件,仔细检查一下你的axis配置
      

  4.   

    我也觉着像是配置问题,我运行:
    http://localhost:8080/axis/happyaxis.jsp
    是不是就是用来检测axis的配置的?
    其中必须的组件如下:
    Examining webapp configurationNeeded Components
    Found SAAJ API (javax.xml.soap.SOAPMessage) at D:\Program Files\Tomcat4.1.31\common\lib\saaj.jar
    Found JAX-RPC API (javax.xml.rpc.Service) at D:\Program Files\Tomcat4.1.31\common\lib\jaxrpc.jar
    Found Apache-Axis (org.apache.axis.transport.http.AxisServlet) at D:\Program%20Files\Tomcat4.1.31\webapps\axis\WEB-INF\lib\axis.jar
    Found Jakarta-Commons Discovery (org.apache.commons.discovery.Resource) at D:\Program%20Files\Tomcat4.1.31\webapps\axis\WEB-INF\lib\commons-discovery.jar
    Found Jakarta-Commons Logging (org.apache.commons.logging.Log) at D:\Program%20Files\Tomcat4.1.31\webapps\axis\WEB-INF\lib\commons-logging.jar
    Found Log4j (org.apache.log4j.Layout) at D:\Program%20Files\Tomcat4.1.31\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar
    Found IBM's WSDL4Java (com.ibm.wsdl.factory.WSDLFactoryImpl) at D:\Program%20Files\Tomcat4.1.31\webapps\axis\WEB-INF\lib\wsdl4j.jar
    Found JAXP implementation (javax.xml.parsers.SAXParserFactory) at an unknown location
    Found Activation API (javax.activation.DataHandler) at D:\Program Files\Tomcat4.1.31\common\lib\activation.jar这里面说JAXP implementation found "at an unknown location" 这算是找到了还是没找到呢...
    call.invoke()方法出错,一般都是什么原因造成的?
      

  5.   

    JAXP implementation found "at an unknown location"这当然算是找到了.
    你invoke()之前怎么设置你的endpoint.
    代码拿出来看看
      

  6.   

    /*
     * Copyright 2001-2004 The Apache Software Foundation.
     * 
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     * 
     *      http://www.apache.org/licenses/LICENSE-2.0
     * 
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */package samples.userguide.example2 ;import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    import org.apache.axis.utils.Options;import javax.xml.rpc.ParameterMode;public class CalcClient
    {
       public static void main(String [] args) throws Exception {
           Options options = new Options(args);
           
           String endpoint = "http://localhost:" + options.getPort() +
                             "/axis/Calculator.jws";
           
           args = options.getRemainingArgs();
           
           if (args == null || args.length != 3) {
               System.err.println("Usage: CalcClient <add|subtract> arg1 arg2");
               return;
           }
           
           String method = args[0];
           if (!(method.equals("add") || method.equals("subtract"))) {
               System.err.println("Usage: CalcClient <add|subtract> arg1 arg2");
               return;
           }
           
           Integer i1 = new Integer(args[1]);
           Integer i2 = new Integer(args[2]);       Service  service = new Service();
           Call     call    = (Call) service.createCall();       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName( method );
           call.addParameter( "op1", XMLType.XSD_INT, ParameterMode.IN );
           call.addParameter( "op2", XMLType.XSD_INT, ParameterMode.IN );
           call.setReturnType( XMLType.XSD_INT );       Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });
           
           System.out.println("Got result : " + ret);
       }
    }运行命令:
    >java -cp .;%AXISCLASSPATH% samples.userguide.example2.CalcClient -p8080 add 2 5异常:
    - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
    Exception in thread "main" AxisFault
     faultCode: {http://xml.apache.org/axis/}HTTP
     faultSubcode:
     faultString: (500)Internal Server Error
     faultActor:
     faultNode:
     faultDetail:
            {}:return code:  500
      
      (500)Internal Server Error
            at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:663)
            at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:94)
            at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
            at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
            at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
            at org.apache.axis.client.AxisClient.invoke(AxisClient.java:147)
            at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
            at org.apache.axis.client.Call.invoke(Call.java:2702)
            at org.apache.axis.client.Call.invoke(Call.java:2378)
            at org.apache.axis.client.Call.invoke(Call.java:2301)
            at org.apache.axis.client.Call.invoke(Call.java:1758)
            at samples.userguide.example2.CalcClient.main(CalcClient.java:59)提示信息里说的59行就是程序中的:
    Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });还有,http://localhost:8080/axis/Calculator.jws 在IE中是可以打开的。
      

  7.   

    还少了两个jar包
    java mail:mail.jar
    JAF:jaf.jar
      

  8.   

    我把mail.jar和jaf.jar添加到%AXISCLASSPATH%中,现在没有
    - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
    这句话了,但是异常照常。D:\Program Files\Tomcat4.1.31\webapps\axis\WEB-INF\classes>java -cp .;%AXISCLASSPATH% samples.userguide.example2.CalcClient -p8080 add 2 5
    Exception in thread "main" AxisFault
     faultCode: {http://xml.apache.org/axis/}HTTP
     faultSubcode:
     faultString: (500)Internal Server Error
     faultActor:
     faultNode:
     faultDetail:
            {}:return code:  500
      
      
      (500)Internal Server Error
            at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:663)
            at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:94)
            at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
            at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
            at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
            at org.apache.axis.client.AxisClient.invoke(AxisClient.java:147)
            at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
            at org.apache.axis.client.Call.invoke(Call.java:2702)
            at org.apache.axis.client.Call.invoke(Call.java:2378)
            at org.apache.axis.client.Call.invoke(Call.java:2301)
            at org.apache.axis.client.Call.invoke(Call.java:1758)
            at samples.userguide.example2.CalcClient.main(CalcClient.java:59)真是十分的郁闷啊... ...
      

  9.   

    解决了。
    重新安装了一遍TOMCAT,按照文章又重新作了一遍,就好用了。
    浪费了2天的时间啊... ...
    谢谢 umljsp(夜未央,天未白)