如何自定义导入的WSDL内嵌的模式

kir*_*iri 5 xpath jax-ws jaxb wsimport

我有a.wsdl&b.wsdl,其中a.wsdl导入b.wsdl.现在我必须使用wsimport和JAXB自定义b.wsdl中的模式.但使用下面的自定义会给出"XPath评估"wsdl:definitions/wsdl:types/xsd:schema [@ targetNamespace ='b']"导致空目标节点的错误

在使用wsimport生成客户端代码时,我无法找到在导入的b.wsdl中自定义内联架构的方法.

    <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']"
               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"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                   <jaxb:globalBindings>
                    <jaxb:javaType name="java.util.Calendar" xmlType="xsd:dateTime" 
                    parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" 
                    printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
               </jaxb:globalBindings>
   </jaxws:bindings>
Run Code Online (Sandbox Code Playgroud)

A.wsdl

<definitions targetNamespace="a"
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:interface="b">
 <import location="b.wsdl" namespace="b"/>
  <service name="Service">
   <port binding="interface:Binding" name="Port">
      <soap:address location="https://localhost/sdk/vpxdService" />
   </port>
  </service>
</definitions>
Run Code Online (Sandbox Code Playgroud)

B.wsdl

<definitions targetNamespace="b"
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:b="b"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <types>
   <schema
     targetNamespace="b"
     xmlns="http://www.w3.org/2001/XMLSchema"
     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:b="b"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified">
     <complexType name="XYZ">
        <sequence>
           <element name="dynamicType" type="xsd:string" minOccurs="0" />
           <element name="val" type="xsd:anyType" maxOccurs="unbounded" />
        </sequence>
     </complexType>
  </types>
 </schema>
</definitions>
Run Code Online (Sandbox Code Playgroud)

Dav*_*ter 0

您是否尝试过向元素添加以下属性<jaxws:bindings>

 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
Run Code Online (Sandbox Code Playgroud)

 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Run Code Online (Sandbox Code Playgroud)

您在 xpath 表达式中引用 xsd 和 wsdl 命名空间,但在您为它们定义 URI 之前,它们不会与目标文档中的 URI 匹配。