用axis编写webservise客户端的问题(call对象的invoke方法)
错误提示:org.apache.axis.client.Callinvoke严重:Exception:org.xml.sax.SAXException:SimpleDes...
错误提示:
org.apache.axis.client.Call invoke
严重: Exception:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:143)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1031)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1140)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:238)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:386)
at org.apache.axis.client.Call.invoke(Call.java:2402)
at org.apache.axis.client.Call.invoke(Call.java:2301)
at org.apache.axis.client.Call.invoke(Call.java:1758)
at caClient.main(caClient.java:68)
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
源代码是这样的:
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class caClient {
public static void main(String[] args) {
try {
String endpoint = "http://www.webxml.com.cn/WebServices/StockInfoWS.asmx";
System.out.println("result is ");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName(new QName("http://www.webxml.com.cn/WebServices/StockInfoWS.asmx", "getStockInfo"));
call.addParameter("theStockCode",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("userID",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://webxml.com.cn/getStockInfo");
call.invoke(new Object[] { "sh000001","WebXml.com.cn" });
}
catch (Exception e) {
System.err.println(e);
}
}
}
最好实际调试一下小弟的代码, 提供正解后会有更多赏金 ^_^ 展开
org.apache.axis.client.Call invoke
严重: Exception:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:143)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1031)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1140)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:238)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:386)
at org.apache.axis.client.Call.invoke(Call.java:2402)
at org.apache.axis.client.Call.invoke(Call.java:2301)
at org.apache.axis.client.Call.invoke(Call.java:1758)
at caClient.main(caClient.java:68)
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
源代码是这样的:
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class caClient {
public static void main(String[] args) {
try {
String endpoint = "http://www.webxml.com.cn/WebServices/StockInfoWS.asmx";
System.out.println("result is ");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName(new QName("http://www.webxml.com.cn/WebServices/StockInfoWS.asmx", "getStockInfo"));
call.addParameter("theStockCode",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("userID",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://webxml.com.cn/getStockInfo");
call.invoke(new Object[] { "sh000001","WebXml.com.cn" });
}
catch (Exception e) {
System.err.println(e);
}
}
}
最好实际调试一下小弟的代码, 提供正解后会有更多赏金 ^_^ 展开
1个回答
展开全部
看看下面这个,可能对你有帮助
参考资料: http://hi.baidu.com/shiliangshuai/blog/item/f5ad82d473b6ff00a08bb7ef.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询