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

2023-12-09

我有 a.wsdl 和 b.wsdl,其中 a.wsdl 导入 b.wsdl。 现在我必须使用 wsimport 和 JAXB 自定义 b.wsdl 内的架构。但使用below定制给出的错误是“wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']”的 XPath 计算会导致目标节点为空

使用 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>

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>

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>

在浏览给定网站后,我修改了外部绑定文件以使用wsdlLocation =“b.wsdl”代替节点=“wsdl:定义/ wsdl:类型/ xsd:架构[@targetNamespace ='b']”哪个做了magic.

这将确保 WSDL 中定义的内联模式将根据需要进行自定义。

<bindings 
 xmlns="http://java.sun.com/xml/ns/jaxb"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
 version="2.0">    
  <bindings wsdlLocation="b.wsdl">
    <globalBindings>
      <javaType name="java.util.Calendar" xmlType="xsd:dateTime"
        parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
        printMethod="javax.xml.bind.DatatypeConverter.printDate"
      />
     </globalBindings>  
  </bindings>
</bindings>

http://fusesource.com/docs/framework/2.1/jaxws/JAXWSCustomTypeMappingOverview.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何自定义导入的 WSDL 中内联的模式 的相关文章

随机推荐