webservice 常见错误及解决方法

时间:2021-02-09 10:52:25
1、调用别人的webservice 方法
 
Service service =new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://WebXml.com.cn/","getWeatherbyCityName"));
call.addParameter(new QName("http://WebXml.com.cn/","theCityName"),org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_VECTOR);//返回参数的类型(不能用Array,否则报错)Yaw平坦软件园
call.setSOAPActionURI(http://WebXml.com.cn/getWeatherbyCityName);  SOAPService soap = new SOAPService();
soap.setName("WeatherWebService");
call.setSOAPService(soap);
Vector ret = (Vector) call.invoke(new Object[]{"北京"});
System.out.println("--------"+ret);
 
 
 
 
2、axis
   
19:25:21,250 DEBUGConfigurationException:110 - Exception:
org.apache.axis.ConfigurationException: No service named http://WebXml.com.cn/ is available
org.apache.axis.ConfigurationException: No service named http://WebXml.com.cn/ is available
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:233)
at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
at org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
at org.apache.axis.client.Call.invoke(Call.java:2708)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Test5.main(Test5.java:109)
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:233)
at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
at org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
at org.apache.axis.client.Call.invoke(Call.java:2708)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Test5.main(Test5.java:109)
19:25:21,265 DEBUG MessageContext:793 - MessageContext: setServiceHandler(null)
19:25:21,265 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(targetService)
19:25:21,265 DEBUG Call:2715 - Target service: http://WebXml.com.cn/
19:25:21,265 DEBUG MessageContext:749 - MessageContext: setTargetService(http://WebXml.com.cn/getWeatherbyCityName)
19:25:21,265 DEBUG ProjectResourceBundle:72 - org.apache.axis.i18n.resource::handleGetObject(noService10)
19:25:21,265 DEBUGConfigurationException:110 - Exception:
org.apache.axis.ConfigurationException: No service named http://WebXml.com.cn/getWeatherbyCityName is available
org.apache.axis.ConfigurationException: No service named http://WebXml.com.cn/getWeatherbyCityName is available
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:233)
at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
at org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
at org.apache.axis.transport.http.HTTPTransport.setupMessageContextImpl(HTTPTransport.java:89)
at org.apache.axis.client.Transport.setupMessageContext(Transport.java:46)
at org.apache.axis.client.Call.invoke(Call.java:2738)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Test5.main(Test5.java:109)
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:233)
at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
at org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
at org.apache.axis.transport.http.HTTPTransport.setupMessageContextImpl(HTTPTransport.java:89)
at org.apache.axis.client.Transport.setupMessageContext(Transport.java:46)
at org.apache.axis.client.Call.invoke(Call.java:2738)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at Test5.main(Test5.java:109)
 
 
SOAPService soap = new SOAPService();
soap.setName("WeatherWebService");  //此处webservice的名字
call.setSOAPService(soap);
 
 
3、axis
faultString: 服务器未能识别HTTP 头SOAPAction 的值: 。
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:服务器未能识别HTTP 头SOAPAction 的值: 。
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)