类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} );
出现错误
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} );
出现错误
解决方案 »
- 为什么在oracle下报错
- hibernate 插入Sql Server时报的错误信息,能告诉我这是什么地方出错了?
- JavaServer Faces
- Seek for experiences in JSF/Eclipse/JBOSS/JUNIT
- tomcat6与jre如何结合才能在没有jvm的机器上启动运行tomcat?(注:不要配置系统的环境变量jre_home来实现)
- Struts 1.3中DynaActionForm的转型问题
- [求助]spring调用oracle存储过程问题,急急急~!
- tomcat 解析 jsp 页面排版紊乱
- tomcat启动脚本中的JAVA的命令行参数问题
- 为什么我的一对多的父类总是不能更新呢??
- hibernate怎么求两列相乘之和呢
- 问一个weblogic服务器的问题!!
Object ret = call.invoke( new Object[] {symbol} );
这一句上,试了好几个例子,只要运行到call.invoke()方法,就会出现上面的问题。
这是怎么回事呢?郁闷啊!!
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()方法出错,一般都是什么原因造成的?
你invoke()之前怎么设置你的endpoint.
代码拿出来看看
* 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中是可以打开的。
java mail:mail.jar
JAF:jaf.jar
- 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)真是十分的郁闷啊... ...
重新安装了一遍TOMCAT,按照文章又重新作了一遍,就好用了。
浪费了2天的时间啊... ...
谢谢 umljsp(夜未央,天未白)