'The client to invoke an error is as follows:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected
Who can help me, I was going to collapse, so thank you The client to invoke an error is as follows,error: The client to invoke an error is as follows,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
server code:(axis2+hibernate+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;
}
}
}
client code:
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();
}
}
}
Solution 1:[1]
I think the error is due to the xml output being returned from find() method of your HcxNewsService class. Some XML IS successfully returned, and it is not sufficiently well formed for it to deserialize (re construct an object out of it).
As mentioned in the stack trace...
"encountered a child element, which is NOT expected, in something it was trying to deserialize" (SAXParser did not understand the XML implies that xml is not correctly formed).
Possible debugging options are try to get the xml tied object directly from DAO... Log it...
public class Dao<T> extends HibernateDaoSupport implements IDao<T> {
public T find(String str,int id) {
try {
T t = (T) getHibernateTemplate().get(str, id);
System.out.println.t.toString()); // OR...
LOGGER.info(t.toString());
return t;
} cach (RuntimeException re) {
throw re;
}
}
}
If this fails, do the same approach with calling code in the server...
public class HxcNewsService implements IHxcNewsService {
private IDao dao;
public void setDao(IDao dao) {
this.dao = dao;
}
public HxcNews find(int id){
// before returning, see what is database returning...
LOGGER.log(dao.find("com.ews.bean.HxcNews",id));
return (HxcNews) dao.find("com.ews.bean.HxcNews",id);
}
}
Let us know how you solved it finally.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Siva Tumma |
