| 发表于:2007-05-21 16:46:14 楼主 |
服务端: ------------------- helloworld.java public class helloworld { public string sayhello() { return "hello world! "; } } 改名为helloworld.jws,放到tomcat目录里。 用ie访问http://127.0.0.1:8080/axis/helloworld.jws?wsdl 可以看到xml文档。 客户端: ----------------------- import org.apache.axis.client.call; import org.apache.axis.client.service; import javax.xml.rpc.parametermode; public class testclient { public static void main(string[] args) throws exception { string endpoint = "http://127.0.0.1:8080/axis/helloworld.jws ";// 指明服务所在位置 service service = new service(); // 创建一个service实例,注意是必须的! call call = (call) service.createcall();// 创建call实例,也是必须的! call.settargetendpointaddress(new java.net.url(endpoint));// 为call设置服务的位置 system.out.println(endpoint);//这里可以输出 //call.setoperationname( "sayhello ");// 注意方法名与helloworld.java中一样!! string res = (string)call.invoke( "sayhello ",new object[] {});// 返回string,没有传入参数 system.out.println(res); } } 错误: ------------------- exception in thread "main " axisfault faultcode: {http://schemas.xmlsoap.org/soap/envelope/}server.userexception faultsubcode: faultstring: java.lang.nullpointerexception faultactor: faultnode: faultdetail: {http://xml.apache.org/axis/}stacktrace: java.lang.nullpointerexception at java.util.hashtable.put(hashtable.java:396) at com.sun.org.apache.xerces.internal.jaxp.saxparserimpl.setproperty(saxparserimpl.java:395) at org.apache.axis.encoding.deserializationcontextimpl.parse(deserializationcontextimpl.java:246) at org.apache.axis.soappart.getassoapenvelope(soappart.java:538) at org.apache.axis.message.getsoapenvelope(message.java:377) at org.apache.axis.client.call.invokeengine(call.java:2545) at org.apache.axis.client.call.invoke(call.java:2515) at org.apache.axis.client.call.invoke(call.java:2210) at org.apache.axis.client.call.invoke(call.java:2133) at org.apache.axis.client.call.invoke(call.java:2158) at testclient.main(testclient.java:20) java.lang.nullpointerexception at org.apache.axis.axisfault.makefault(axisfault.java:129) at org.apache.axis.client.call.invoke(call.java:2213) at org.apache.axis.client.call.invoke(call.java:2133) at org.apache.axis.client.call.invoke(call.java:2158) at testclient.main(testclient.java:20) caused by: java.lang.nullpointerexception at java.util.hashtable.put(hashtable.java:396) at com.sun.org.apache.xerces.internal.jaxp.saxparserimpl.setproperty(saxparserimpl.java:395) at org.apache.axis.encoding.deserializationcontextimpl.parse(deserializationcontextimpl.java:246) at org.apache.axis.soappart.getassoapenvelope(soappart.java:538) at org.apache.axis.message.getsoapenvelope(message.java:377) at org.apache.axis.client.call.invokeengine(call.java:2545) at org.apache.axis.client.call.invoke(call.java:2515) at org.apache.axis.client.call.invoke(call.java:2210) ... 3 more |
|
|
|
|