如何解决SAXException:in中的元素无效 [英] How to solve SAXException: Invalid element in

查看:284
本文介绍了如何解决SAXException:in中的元素无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过以下方式从Web服务获取结果。

I try to get results from a webservice in the following way.

List result = new Vector();
LibrarySearchRequest request = new LibrarySearchRequest(queryString);
LibrarySearchServicePortTypeProxy proxy = 
                                new LibrarySearchServicePortTypeProxy();
LibrarySearchServicePortType port = proxy.getLibrarySearchServicePortType();
LibrarySearchResponse response = port.process(request);
librarysearch.soft.Book[] books = response.getBooks();

当我这样做时,我得到以下异常(stacktrace):

When I do this I get the following exception (stacktrace) :

org.xml.sax.SAXException: Invalid element in librarysearch.soft.Book - book
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
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 librarysearch.soft.LibrarySearchServiceSOAP11BindingStub.process(LibrarySearchServiceSOAP11BindingStub.java:180)
at softarch.portal.db.ws.WS_RegularDatabase.findRecords(WS_RegularDatabase.java:44)
at softarch.portal.db.test.TestWSRegularDatabase.main(TestWSRegularDatabase.java:39)

The regular database has caught an unexpected exception: ; nested exception is: 
org.xml.sax.SAXException: Invalid element in librarysearch.soft.Book - book

我读到的问题可能是由webservice返回的结果与wsdl生成的类不匹配引起的。我重新生成了我的webservice客户端但没有成功。还有什么可能是问题?

I read the problem could be caused by the result returned from the webservice not matching with the classes generated from the wsdl. I regenerated my webservice client but no succes. What else could be the problem?

推荐答案

这可能与此错误有关( AXIS-2758 ),未解决Axis 1.x。

This could be related to this bug (AXIS-2758), unresolved with Axis 1.x.

如果客户端存根与服务器端(WSDL文件)不是最新的,则会出现此问题。你可能不得不重新生成它。
axistools:wsdl2java 一样。

This problem can appear if your client stub is not up to date with the server side (the WSDL file). You could have to re-generate it. Like with axistools:wsdl2java.

现在最好的,只要你至少使用Java 6,就可以在客户端使用JAX-WS( JAX-WS Maven插件)。但它无法使用RPC / Encoded旧的SOAP服务...更喜欢Document / Literal样式。

The best nowadays, provided you use at least Java 6, is maybe to use JAX-WS on the client side (JAX-WS Maven Plugin). But it could not work with old SOAP Services using RPC/Encoded... Prefer the Document/Literal style.

这篇关于如何解决SAXException:in中的元素无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆