在 wsdl manual 中,在示例 2 的第二部分中,有一个 wsdl 文件具有 portType
,但没有 binding
block
<?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 部分,也不包含任何绑定(bind)。
当我尝试通过 cxf
的 wsdltojava
传递该文件时,它给了我一个警告
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'
请问,是什么让翻译程序需要绑定(bind)
部分? -validate 可以使 SW 注意到问题,但它不是造成问题的参数。
最佳答案
...引用外部 XSD 的正确方法是在 wsdl:types 元素中使用带有 import/include 的 XSD 模式。
详情请参阅
就您而言,您正在使用
*<import namespace="some.xsd"
location="some.xsd"/>*
在引用的链接之后,为什么不包含 <import namespace=...
<types>
中的元素元素,也如下所示:
关于java - 是什么使得带有 portType 但没有绑定(bind)的 wsdl 文件正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41961663/