【问题标题】:What makes wsdl file with portType but without binding correct?是什么让 wsdl 文件带有 portType 但没有正确绑定?
【发布时间】:2023-03-02 23:12:01
【问题描述】:

在wsdlmanual中,在示例2的第二部分,有一个wsdl文件有portType,但没有binding

<?xml version="1.0"?>
<definitions

             targetNamespace="http://example.com/stockquote/definitions"
             xmlns:tns="http://example.com/stockquote/definitions"
             xmlns="http://schemas.xmlsoap.org/wsdl/">


    <import namespace="some.xsd"
            location="some.xsd"/>

    <message name="GetLastTradePriceInput">
        <part name="body"/>
    </message>

    <message name="GetLastTradePriceOutput">
        <part name="body"/>
    </message>

    <portType name="StockQuotePortType">
        <operation name="GetLastTradePrice">
            <input message="tns:GetLastTradePriceInput"/>
            <output message="tns:GetLastTradePriceOutput"/>
        </operation>
    </portType>
</definitions>

some.xsd 是同一示例的第 1 部分,也不包含任何绑定。

当我尝试通过cxfwsdltojava 传递该文件时,它会给我一个警告

 WARNING: WSDL document file:/C:/IdeaProjects/sss/webservices/src/main/schema/BundleAdmin/Atry.wsdl does not define any services

还有一个错误:

WSI-BP-1.0 R2718 violation: A wsdl:binding in a DESCRIPTION MUST have the same set of wsdl:operations as the wsdl:portType to which it refers. GetLastTradePrice not found in wsdl:binding.

这些是wsdltojava 的使用参数:

                List<String> prepareArgs = ['-fe', 'jaxws',
                                            '-autoNameResolution',
                                            '-db', 'jaxb',
                                            '-xjc-extension',
                                            '-impl', '-server', '-client', '-validate',
                                            '-d', ext.genDirName,
                                            /* change package name for types already generated with XmlBeans */
                                            '-p', 'http://messaging.ei.tmobile.net/datatypes=net.tmobile.ei.messaging.jaxb'

请问,是什么让翻译程序需要binding 部分? -validate 可以让 SW 注意到问题,但不是 arg 造成问题。

【问题讨论】:

    标签: java web-services soap wsdl cxf


    【解决方案1】:

    哦,这完全是我的错误。 wsdl手册示例2的第二部分确实只有portType没有绑定。它正在导入的 xsd 文件也没有绑定(自然)。但第二部分不是服务!该服务是第三部分,它具有绑定和导入部分 2。因此,该服务同时具有 portType 和绑定。 它们不是需要binding 部分的参数,它总是需要的。

    我应该注意警告 - 提到的文件还不是服务,应该存在另一个文件,这将是一个服务,并将包含该文件的包含和绑定部分。或者,当然,它可以在一个文件中同时包含 portTypebinding

    【讨论】:

      【解决方案2】:

      ...引用外部 XSD 的正确方法是在 wsdl:types 元素中使用带有 import/include 的 XSD 模式。

      详情请参考

      Importing xsd into wsdl

      在你的情况下,你正在使用

       *<import namespace="some.xsd"
                  location="some.xsd"/>*
      

      按照引用的链接,为什么不在&lt;types&gt; 元素中包含&lt;import namespace=... 元素,如下所示:

      https://stackoverflow.com/a/12125913/1925356

      【讨论】:

      • 那么,如果我在 PortType 中有一个 GetLastTradePrice 操作,我必须从包含操作描述的 xsd 文件中导入?
      • 您的参考资料讲述了元素。我说的是操作。我们不能说没有区别,因为它们的整体语法不同。
      • 我们引用的xsd,包含类型和元素,但没有绑定和操作。
      猜你喜欢
      • 2011-05-29
      • 1970-01-01
      • 2013-09-16
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 2016-01-16
      相关资源
      最近更新 更多