首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

急java 调用.net webservice报错解决办法

2012-06-14 
急!!!java 调用.net webservice报错代码如下:Java codeService service new Service()try {Call call

急!!!java 调用.net webservice报错
代码如下:

Java code
Service service = new Service();        try {            Call call = (Call) service.createCall();            String res = "";            String nameSpace = "http://ktews.com/";            call.setTargetEndpointAddress(new java.net.URL("https://127.0.0.1/KTEWS/KTEWS.asmx"));                       call.addParameter(new QName(nameSpace, "email"),                    org.apache.axis.encoding.XMLType.XSD_STRING,                    javax.xml.rpc.ParameterMode.IN);            call.addParameter(new QName(nameSpace, "password"),                    org.apache.axis.encoding.XMLType.XSD_STRING,                       javax.xml.rpc.ParameterMode.IN);            call.addParameter(new QName(nameSpace, "serverUrl"),                       org.apache.axis.encoding.XMLType.XSD_STRING,                       javax.xml.rpc.ParameterMode.IN);            call.addParameter(new QName(nameSpace, "amount"),                       org.apache.axis.encoding.XMLType.XSD_INT,                       javax.xml.rpc.ParameterMode.IN);             call.setReturnType(org.apache.axis.Constants.XSD_STRING);            call.setSOAPActionURI(nameSpace);            call.setOperationName(new QName(nameSpace, "getUnReadEmail"));             res = (String) call.invoke(new Object[] {"test.com", "123456","https://127.0.0.1/EWS/exchange.asmx",5});            String[] results = res.split("&");            for(int i = 0 ; i <results.length;i++){                System.out.println(results[i]);            }        } catch (MalformedURLException e) {            e.printStackTrace();        } catch (RemoteException e) {            e.printStackTrace();        } catch (ServiceException e) {            e.printStackTrace();        }


错误信息如下:
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
 faultSubcode: 
 faultString: 服务器无法读取请求。 ---&gt; XML 文档(1, 582)中有错误。 ---&gt; 输入字符串的格式不正确。
 faultActor: 
 faultNode: 
 faultDetail: 
{http://xml.apache.org/axis/}stackTrace:服务器无法读取请求。 ---&gt; XML 文档(1, 582)中有错误。 ---&gt; 输入字符串的格式不正确。
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 org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
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.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)


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 com.test.Etes.main(Etes.java:52)

{http://xml.apache.org/axis/}hostname:PC-201010272334

服务器无法读取请求。 ---> XML 文档(1, 582)中有错误。 ---> 输入字符串的格式不正确。
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 org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
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.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
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 com.test.Etes.main(Etes.java:52)
请大侠们麻烦看下。
非常感谢。

[解决办法]
java 不能直接访问.net发布的webservice。要在webservice代码块中加入特殊参数。才可以
因为java里jar包识别的xml数据格式,与.net发布生成的数据格式不一样

热点排行