"JAXWS wsimport" 表示 XPath 在 "jaxb file binding" 中为空

"JAXWS wsimport" says XPath is null in a "jaxb file binding"

我正在尝试使用 jaxws wsimport 生成存根文件。 在 WSDL 中有两种相互冲突的类型: 第 68 行:<s:element minOccurs="0" maxOccurs="1" name="DAGSBROTTFELLT" type="s:string" />

和第 119 行:<s:element minOccurs="0" maxOccurs="1" name="DAGS_BROTTFELLT" type="s:string" />

原因是wsimport没有保留下划线字符“_”,认为两者名称相同

我创建了一个 jaxb 绑定文件来显式命名结果 Java class.

但是 wsimport 说:

[ERROR] XPath error: null
line 11 of file:/C:/Users/deyan/ss_workspace/MVS%20Services/src/is/mvs/services/ws/xjb/companyInfo.xjb

我测试了 xpath 字符串 http://www.freeformatter.com/xpath-tester.html#ad-output 它确实 returns 元素。

请帮忙弄清楚为什么 wsimport 说 xpath 是空的。

提前致谢!

这是我的 WSDL: https://gognxml.uh.is/xml_service.asmx?WSDL

这是 jaxb 绑定文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  wsdlLocation="https://gognxml.uh.is/xml_service.asmx?WSDL">

  <enableWrapperStyle>true</enableWrapperStyle>
  <enableAsyncMapping>false</enableAsyncMapping>
  <jaxws:bindings          node="wsdl:definitions/wsdl:types/s:schema/s:complexType[@name='Faersla']/s:sequence/s:element[@name='DAGS_BROTTFELLT']">
    <jaxb:class name="Dags_Brottfellt"/>
  </jaxws:bindings>
</jaxws:bindings>

我注意到的一件事是 XPath 表达式使用 s 命名空间前缀(例如 s:schema),但我没有在任何地方看到该命名空间前缀。它应该在 <jaxws:bindings> 元素之一上声明吗?或者这些前缀应该在哪里声明?通常,在输入 XML 中声明它们是不够的。但是我对wsimport一无所知。

P.S。看起来没有使用 xs 前缀,所以它可能应该是 s。正如您已经在评论中确认的那样。 :-)