急问java调用webService问题

问题描述

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吧
解决方案八:
应该是编码问题吧

时间: 2024-10-28 20:56:09

急问java调用webService问题的相关文章

webservice接口-我要用java调用WebService (被调用的是一个短信接口下面给详细说明)

问题描述 我要用java调用WebService (被调用的是一个短信接口下面给详细说明) 我要用java调用WebService (被调用的是一个短信接口下面给详细说明)希望能按照这个 那边给我的文档:接口原型:sendMessage ();接口路径:http://58.53.194.80/swdx/services/APService?wsdl[参数说明]:参数名称 数据类型 说明ApName String SP帐号ApPassword String SP密码compcode String

java调用webservice接口发送xml报文

问题描述 java调用webservice接口发送xml报文 1.webservice接口是axis1发布的 2.请求报文格式如下 <?xml version="1.0" encoding="gbk"?><SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XM

java 调用 webservice接口传参出现错误java.lang.linkageerror.

问题描述 java 调用 webservice接口传参出现错误java.lang.linkageerror. when resolving method "org.apache.axis.client.Call.addParameter(Ljavax/xml/namespace/QName;Ljavax/xml/namespace/QName;Ljavax/xml/rpc/ParameterMode;)V" the class loader (instance of org/eclip

java调用webservice接口

问题描述 publicstaticvoidmain(String[]args){Stringid="123";Stringpassword="123";StringserviceEpr="http://192.168.0.8:8081/Seed/services/Sperson?wsdl";Stringrest=callWebServiceByAixs(id,password,serviceEpr);System.out.println(rest

java调用webservice问题 我在用客户端调用axis2发布的webservice时候老是出错

问题描述 在使用客户端调用axis2的webservice时候老是报出这个错误,具体操作是向sqlserver数据库中插入数据,具体错误如下:Exceptioninthread"main"org.apache.axis2.AxisFault:ExceptionoccurredwhiletryingtoinvokeservicemethodMobile_ActionBussinessatorg.apache.axis2.util.Utils.getInboundFaultFromMess

java调用webservice:php调用java webservice

header("content-type: text/html; charset=utf-8");require_once("lib/nusoap.php");// 要访问的webservice路径$nusoapwsdl="http://localhost:8080/mywebservice/services/sendmobliemsg?wsdl";// 生成客户端对象$client = new soapclient($nusoapwsdl, t

Java调用Webservice数组参数传递有问题

问题描述 String[] arr = new String[2];arr[0]="abc";arr[1]="def";String str="myteststr";Client client = new Client(new URL("http://xx.xx.xx.xx:9084/eee/infoService?wsdl"));Object[] results = client.invoke("getStuden

java 调用webservice

问题描述 请高手帮忙我引用的包:importorg.apache.cxf.endpoint.Client;importorg.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;调用方法:Stringurl="http:///192.168.0.0/sssss/ssss/nodelog";JaxWsDynamicClientFactoryclientFactory=JaxWsDynamicClientFactory.n

Java调用webservice实现电话归属地查询为例

很多时候我们需要的数据来着webservice接口,那么如何对接接口呢? 其实很简单的功能就实现了  代码如下 复制代码 package com.air.controller; import java.util.Vector;   import javax.servlet.http.HttpServletRequest; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; import javax.xml.r