SoapUI 或 WSDL2Java 无法读取 Axis2 服务生成的 WSDL
我正在将一些服务从 Apache SOAP 转换为 Axis2,因此 Java 服务类已经存在。我在 Eclipse 中创建了一个新项目,导入了源代码,确保安装了 Axis2 项目构面,并且 Axis2 发射器属性正确。然后,在 Eclipse 中,我选择了服务类并选择了“创建 Web 服务”,并选择了 Axis2 运行时。该服务已在我的 PC 上启动并运行,当我将“?wsdl”附加到服务的路径时,我确实获得了本地保存的 WSDL。尝试将其导入到 SoapUI 中以构建客户端时会出现错误:
ERROR:org.apache.xmlbeans.XmlException: C:\projects\soapUI\Axis2\DALService.wsdl:0: error: src-resolve: type 'SOAPException@http://www.w3.org/2001/XMLSchema' not found.
它所引用的类型 (SOAPException) 是 Apache SOAP 服务的保留,并且在服务代码中,我更改了服务代码中的所有“导入”引用(不是WSDL)从 org.apache.soap.SOAPException(旧的 Apache SOAP 包名称)到 javax.xml.soap.SOAPException(Axis2 位置)。一旦我可以访问它,代码就会编译并运行,但如果不生成客户端,我就无法访问它。对于为什么更改对象的名称空间会阻止生成的 WSDL 具有正确的名称空间引用,有什么想法吗?
I'm converting some services from Apache SOAP to Axis2, so the Java service classes already exist. I created a new project in Eclipse, imported the source, made sure that the Axis2 project facets were installed, and Axis2 emitter properties are correct. Then, in Eclipse, I selected the service class and chose "Create Web Service," choosing the Axis2 runtime. The service is up and running on my PC, and when I append "?wsdl" to the service's path, I do indeed get a WSDL that I save locally. Attempting to import this into SoapUI to build a client gives the error:
ERROR:org.apache.xmlbeans.XmlException: C:\projects\soapUI\Axis2\DALService.wsdl:0: error: src-resolve: type 'SOAPException@http://www.w3.org/2001/XMLSchema' not found.
The type it's referring to (SOAPException) is a holdover from the Apache SOAP services, and in the service code, I changed all "import" references in the service code (not the WSDL) from org.apache.soap.SOAPException
(the old Apache SOAP package name) to javax.xml.soap.SOAPException
(the Axis2 location). The code compiles and works, once I can access it, but I can't access it without generating a client. Any thoughts as to why changing the namespace of an object would keep the generated WSDLs from having the proper namespace references?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需使用直接在 SOAP UI 中显示 WSDL 的“xxx?wsdl”URL,看起来 WSDL 中引用的一些 XSD 模式没有被 SOAP UI 工具找到,通常这些工具在同一文件夹中搜索模式,也由于您有 org.apache.soap.SOAPException 到 javax.xml.soap.SOAPException,这可能会更改名称空间。
只需尝试使用完整的 URL 并查看结果即可。
Just use the "xxx?wsdl" URL which showed up the WSDL directly in SOAP UI, looks like some XSD schemas referred in the WSDL are not being found by the SOAP UI tool, generally these tools search the schema's in the same folder, also as you have org.apache.soap.SOAPException to javax.xml.soap.SOAPException, this might have changed the namespace.
Just try using the complete URL and see the result.
让我第一个说我不知道为什么会出现这种情况,但我的猜测是命名空间的确切内容可能并不重要,只要它们都是相同的。我们甚至没有使用 SOAPException 的任何特殊功能,因为它只是盲目地扩展常规 Exception。不管怎样,我通过做三件事让 SoapUI 从 XML 构建客户端。
首先,我添加了一个部分来表示 SOAPException 本身,如下所示:
其次,我将以下命名空间添加到 wsdl:definitions 块:
第三,我更改了引用 SOAPException 基类型的命名空间(来自
ns 到
im
此处)无论之前引用过什么:XML 文件在 XMLSpy 中仍然无法完全验证,但这只是因为一个更深奥的原因,不会直接影响我(操作,其中为 Soap11 和 Soap12 绑定定义了错误,没有为原始 HTTP 绑定定义了错误)。
尽管它有效,但我仍然对以下内容感到有点困惑:
类型(确实如此,因为它
提到它作为基类
其他例外),为什么没有呢
在
xs:schema
块中定义它?从不正确的类中引用该类
使用命名空间作为基础时
另一种类型的类?
此类型为
DEPARTMENT.COMPANY.com
不是 Axis2 包或
使用它的服务对象的包?
Let me be the first to say I have no idea WHY any of this is the case, but my guess is the exact content of the namespace may not matter so long as they're all the same. We're not even using any special features of SOAPException, because it only blindly extends the regular Exception. Anyhow, I was able to get SoapUI to build clients from the XML by doing three things.
First, I added a section to represent the SOAPException itself, as so:
Second, I added the following namespace to the wsdl:definitions block:
Third, I changed the namespace referenced to the SOAPException base type (fron
ns
toim
here) wherever it was previously referenced:The XML file still doesn't validate cleanly in XMLSpy, but only because of a more esoteric reason that doesn't affect me directly (the operations, which have faults defined for the Soap11 and Soap12 bindings, don't have faults defined for the raw HTTP bindings).
Even though it works, I'm still a bit confused about the following:
type (and it did, because it
mentioned it as the base class of the
other exceptions), why didn't it
define it in an
xs:schema
block?reference the class from an incorrect
namespace when using it as the base
class for another type?
this type as
DEPARTMENT.COMPANY.com
and not either an Axis2 package or
the package of the service object that uses it?