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

发布于 2024-11-18 04:04:28 字数 2486 浏览 3 评论 0原文

我有一个.wsdl & b.wsdl,其中 a.wsdl 导入 b.wsdl。 现在我必须使用 wsimport 和 JAXB 自定义 b.wsdl 内的架构。但使用下面自定义会产生错误,““wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']”的 XPath 评估会导致空目标节点< /strong>

生成客户端代码时,我无法找到在导入的 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>

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

I have a.wsdl & b.wsdl where a.wsdl imports b.wsdl.
Now I have to customize the schema inside b.wsdl using wsimport and JAXB. but using below customization is giving error that "XPath evaluation of "wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']" results in an empty target node

I am not able to find a way to customize the inlined schema in imported b.wsdl when generating the client code using wsimport.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

池木 2024-11-25 04:04:28

在浏览给定网站后,我修改了外部绑定文件以使用 wsdlLocation="b.wsdl" 而不是 node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace= 'b']" 发挥了魔法

这将确保 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

After going through given website I modified the external binding file to use wsdlLocation="b.wsdl" instead of node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='b']" which did the magic.

This will make sure that the inline schema defined in WSDL will customized as required.

<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

和我恋爱吧 2024-11-25 04:04:28

您是否尝试过将以下属性添加到 元素?

 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

并且

 xmlns:xsd="http://www.w3.org/2001/XMLSchema"

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

Have you tried adding the following attributes to the <jaxws:bindings> element?

 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

and

 xmlns:xsd="http://www.w3.org/2001/XMLSchema"

You're referencing the xsd and wsdl namespaces in your xpath expression, but until you define the URI's for them, they won't match up with the URI's in the target documents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文