外部绑定文件中的XPath表达式无法定位导入到我的WSDL中的XML模式中的元素.
如果我进行内联绑定自定义,一切都会运行,但我真的想拥有外部绑定文件,这样我就不会意外地覆盖(刷新)包含我的自定义的文件.
我的绑定文件的开头:
<jaxb:bindings
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
version="2.1">
<jaxb:bindings schemaLocation="../wsdl/localhost_7001/ExampleSessionBean/ExampleSessionBeanService.wsdl#types?schema1">
<jaxb:bindings node="//xs:schema[@targetNamespace='urn:myExample']">
Run Code Online (Sandbox Code Playgroud)
我的WSDL包含:
<types>
<xsd:schema>
<xsd:import namespace="urn:myExample" schemaLocation="http://localhost:7001/ExampleSessionBean/ExampleSessionBeanService?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://ejbs/" schemaLocation="http://localhost:7001/ExampleSessionBean/ExampleSessionBeanService?xsd=2"/>
</xsd:schema>
</types>
Run Code Online (Sandbox Code Playgroud)
无论我做什么,XPath都无法在xsd:import'ed模式中找到任何内容.我得到的错误是:
[ERROR] XPath evaluation of "//xs:schema[@targetNamespace='urn:myExample']" results in empty target node
Run Code Online (Sandbox Code Playgroud)
我已经尝试通过索引号而不是命名空间访问xs:schema,但这也不起作用.看起来我的XPath表达式无法从导入的模式中获取元素...无论如何要解决这个问题?
这是在NetBean 7.2下开发的Java SE 7项目.我正在使用NetBeans来完成我所有的wsimport工作,如果这很重要,但命令输出看起来相当标准的RI/Metro.
编辑:我发现如果我使用SCD,我可以获得一个外部绑定文件.此XPath示例不起作用:
<bindings node="//xsd:schema[@targetNamespace='urn:myExample']">
<bindings node="//xs:complexType[@name='myType']">
<class name="MyClass"/>
</bindings>
</bindings>
Run Code Online (Sandbox Code Playgroud)
但这个SCD示例确实如此.
<bindings scd="x-schema::tns" xmlns:tns="urn:myExample">
<bindings scd="~tns:myType">
<class name="MyClass"/>
</bindings>
</bindings>
Run Code Online (Sandbox Code Playgroud)
这是一个众所周知的事情,当使用wsimport时,XPath在xjb文件中不起作用,但是SCD呢?
我正在尝试在https://api.sendwordnow.com/webservices/v3/users.svc?wsdl上使用 wsimport 。这是我正在使用的 wsimport。
wsimport -B-XautoNameResolution -d C:\temp -extension -J-Djavax.xml.accessExternalSchema=all -J-Djavax.xml.accessExternalDTD=all -keep -verbose -XadditionalHeaders -Xnocompile https://api.sendwordnow.com/webservices/v3/users.svc?wsdl
Run Code Online (Sandbox Code Playgroud)
这是错误。
解析 WSDL...
[WARNING] unknown extensibility element or attribute "EndpointReference"
(in namespace "http://www.w3.org/2005/08/addressing") line 1 of
https://api.sendwordnow.com/webservices/v3/users.svc?wsdl
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3
[ERROR] (Related to above error) This is the other declaration.
line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2
[ERROR] (Related to …Run Code Online (Sandbox Code Playgroud)