我非常感谢任何帮助,我对 Java 和 Web 服务还是新手。
问题是:我将 WSDL 导入到我的项目中,当我有时使用它时它工作正常,而在另一种情况下,我在使用 wsdl 时遇到错误:
ERROR [org.apache.axis.encoding.ser.BeanPropertyTarget] - Could not convert [B to bean field 'texto', type java.lang.String
ERROR [org.apache.axis.client.Call] - Exception: org.xml.sax.SAXException: java.lang.ClassCastException@a39be8
. (stuff)
. (more stuff)
. (more stuff)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@a39be8
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org. apache.axis.utils.BeanPropertyDescriptor.set(BeanPropertyDescriptor.java:142)
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:75)
... 73 more
知道如何解决这个问题吗?
我读到了here
使用 -w 参数创建客户端 stub 时可以解决此问题。
java org.apache.axis.wsdl.WSDL2Java -w name.wsdl
错误将不再发生。
这适用于我的情况吗?如果是,我该怎么做?我正在使用 apache-ant 进行部署。
最佳答案
curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:(your action url)" -d@(request input file path) (webservices url) > (response output file path)
通过适当的输入使用此命令。如果你得到正确的输出,那么在解析响应时就会出错。
关于java - 如何使用 BeanPropertyTarget 解决此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8645507/