下面是调试web service时,不同种种类的异常情况,以供调试参考
缺少的jar文件请加在classpath中,注意检查,classpath文件前面不要有空格。
缺少axis.jar
javax.xml.rpc.ServiceException: java.lang.ClassNotFoundException: org.apache.axis.client.ServiceFactory
at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:69)
at com.company.project.remote.WebServiceClient.main(WebServiceClient.java:24)
缺少saaj.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException
at org.apache.axis.configuration.FileProvider.configureEngine(FileProvider.java:179)
at org.apache.axis.AxisEngine.init(AxisEngine.java:172)
at org.apache.axis.AxisEngine.(AxisEngine.java:156)
at org.apache.axis.client.AxisClient.(AxisClient.java:52)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.(Service.java:157)
at org.apache.axis.client.ServiceFactory.createService(ServiceFactory.java:198)
at com.company.project.remote.WebServiceClient.main(WebServiceClient.java:26)
缺少wsdl4j.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/wsdl/extensions/mime/MIMEContent
at org.apache.axis.wsdl.gen.Parser.run(Parser.java:297)
at org.apache.axis.client.Service.initService(Service.java:243)
at org.apache.axis.client.Service.(Service.java:165)
at org.apache.axis.client.ServiceFactory.createService(ServiceFactory.java:198)
at com.company.project.remote.WebServiceClient.main(WebServiceClient.java:26)
错误的URL
javax.xml.rpc.ServiceException: Error processing WSDL document:
java.net.UnknownHostException: www.xmethods.com
at org.apache.axis.client.Service.initService(Service.java:250)
at org.apache.axis.client.Service.(Service.java:165)
at org.apache.axis.client.ServiceFactory.createService(ServiceFactory.java:198)
at com.company.project.remote.WebServiceClient.main(WebServiceClient.java:26)
缺少用户名、密码
javax.xml.rpc.ServiceException: Error processing WSDL document:
java.net.ProtocolException: Server redirected too many times (20)
at org.apache.axis.client.Service.initService(Service.java:250)
at org.apache.axis.client.Service.(Service.java:165)
at org.apache.axis.client.ServiceFactory.createService(ServiceFactory.java:198)
at com.company.project.remote.WebServiceClient.main(WebServiceClient.java:26)