问题描述
Serviceservice=newService();Callcall=(Call)service.createCall();call.setTargetEndpointAddress(newjava.net.URL("http://10.35.219.253:8081/SHSD.CS/Carinfo"));call.setOperationName(newQName("http://10.35.219.253:8081/SHSD.CS/Carinfo","getCarinfoList"));call.addParameter(starTime,org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.addParameter(endTime,org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.addParameter(maxRows,org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.setUseSOAPAction(true);call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);call.setSOAPActionURI("http://10.35.219.253:8081/SHSD.CS/Carinfo/getCarinfoList");Objectk=(Object)call.invoke(newObject[]{starTime,endTime,maxRows});return(List)k;上面是我调用的代码,返回值类型是List但是老报如下异常AxisFaultfaultCode:{http://schemas.xmlsoap.org/soap/envelope/}ServerfaultSubcode:faultString:Couldn'tparsestream..Nestedexceptioniscom.ctc.wstx.exc.WstxUnexpectedCharException:Unexpectedcharacter'2'(code50)incontentafter'<'(malformedstartelement?).at[row,col{unknown-source}]:[1,369]faultActor:faultNode:faultDetail:{http://xml.apache.org/axis/}stackTrace:Couldn'tparsestream..Nestedexceptioniscom.ctc.wstx.exc.WstxUnexpectedCharException:Unexpectedcharacter'2'(code50)incontentafter'<'(malformedstartelement?).at[row,col{unknown-source}]:[1,369]atorg.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)atorg.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)atorg.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)atorg.apache.xerces.parsers.AbstractSAXParser.endElement(UnknownSource)atorg.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(UnknownSource)atorg.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(UnknownSource)atorg.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(UnknownSource)atorg.apache.xerces.parsers.XML11Configuration.parse(UnknownSource)atorg.apache.xerces.parsers.XML11Configuration.parse(UnknownSource)atorg.apache.xerces.parsers.XMLParser.parse(UnknownSource)atorg.apache.xerces.parsers.AbstractSAXParser.parse(UnknownSource)atorg.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(UnknownSource)atorg.apache.xerces.jaxp.SAXParserImpl.parse(UnknownSource)atorg.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)atorg.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)atorg.apache.axis.Message.getSOAPEnvelope(Message.java:435)atorg.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)atorg.apache.axis.client.AxisClient.invoke(AxisClient.java:206)atorg.apache.axis.client.Call.invokeEngine(Call.java:2784)atorg.apache.axis.client.Call.invoke(Call.java:2767)atorg.apache.axis.client.Call.invoke(Call.java:2443)atorg.apache.axis.client.Call.invoke(Call.java:2366)atorg.apache.axis.client.Call.invoke(Call.java:1812)atserver.WebServiceImp.getCityData(WebServiceImp.java:29)atserver.WebServiceImp.main(WebServiceImp.java:63)
解决方案
解决方案二:
UP!
解决方案三:
查看看是不是WSDL描述文件多了一个字符'2'.
解决方案四:
解析不出来<后面的‘2’.。。。
解决方案五:
支持
解决方案六:
你的service的sever端返回的值有问题,和client无关吧。对于xml文件,其开始应该是<?xmlversion="1.0"encoding="UTF-8"?>。所以根据lz的异常,应该是返回结果的xml有问题
解决方案七:
Axis不好用还是用Xfire吧
解决方案八:
应该是编码问题吧