谁能帮帮我,我快要崩溃了,所以谢谢你客户端调用错误如下,错误:客户端调用错误如下,error:
- 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:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
at com.hxc.soap.Test.main(Test.java:11)
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: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:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
at com.hxc.soap.Test.main(Test.java:11)
{http://xml.apache.org/axis/}hostname:geduo_pc
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:2470)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.hxc.soap.HxcNewsServiceSoap12BindingStub.find(HxcNewsServiceSoap12BindingStub.java:254)
at com.hxc.soap.Test.main(Test.java:11)
Caused by: 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:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
... 4 more
服务器代码:(axis 2+休眠+Spring)
public class HxcNewsService implements IHxcNewsService {
private IDao dao;
public void setDao(IDao dao) {
this.dao = dao;
}
public HxcNews find(int id){
return (HxcNews) dao.find("com.ews.bean.HxcNews",id);
}
}
public class Dao<T> extends HibernateDaoSupport implements IDao<T> {
public T find(String str,int id) {
try {
T t = (T) getHibernateTemplate().get(str, id);
return t;
} catch (RuntimeException re) {
throw re;
}
}
}
客户代码:
public class Test {
public static void main(String[] args) {
try {
HxcNewsServicePortType hxcNewsServicePortType = new HxcNewsServiceLocator().getHxcNewsServiceHttpSoap12Endpoint();
HxcNews news = hxcNewsServicePortType.find(1);
System.out.println(news.getTitle());
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
1条答案
按热度按时间3zwjbxry1#
我认为这个错误是由于
HcxNewsService
类的find()
方法返回的xml输出造成的。一些XML成功返回,但它的格式不足以反序列化(* 重新构造一个对象 *)。正如堆栈跟踪中提到的......“
encountered a child element, which is NOT expected, in something it was trying to deserialize
“(SAXParser不理解XML意味着xml格式不正确)。可能的调试选项是尝试直接从DAO获取XML绑定对象...记录它...
如果这失败了,请对服务器中的调用代码执行相同的方法...
让我们知道你最后是怎么解决的。