非绑定 WSDL
当经过良好实践之后开发客户机应用程序时,可以根据仅包含端口类型定义而不包含特定绑定或端口地址的 WSDL 文档进行开发。这类 WSDL 文档又称为非绑定 WSDL 文档。
Web Service 的特定部署的详细信息、绑定和端口地址应在部署时通过绑定 WSDL 来指定,或在部署客户机应用程序时或以后进行管理时通过指定重定目标的绑定名称空间和端点地址来指定。
当前 WSDL 规范要求有绑定和端口元素从服务元素链接至端口类型,因此非绑定 WSDL 文档中存在这些元素。但是,它们没有包含展开性元素来定义服务的特定部署。
此处是一个非绑定 WSDL 文档的示例:
<definitions targetNamespace=“http://www.ibm.com/websphere/sib/webservices/Service”
xmlns:tns = “http://www.ibm.com/websphere/sib/webservices/Service”>
<message name=“GetQuoteInput”>
<part name=“symbol type=“xsd:string”/>
</message>
<message name=“GetQuoteOutput”>
<part name=“value” type=“xsd:float”/>
</message>
<portType name=“StockQuote”>
<operation name=“getQuote”>
<input message=“tns:GetQuoteInput”/>
<output message=“tns:GetQuoteOutput”/>
</operation>
</portType>
<binding name=“StockQuoteBinding” type=“StockQuote”/>
<operation name=“getQuote”/>
</binding>
<service name=“StockQuote”>
<port name=“StockQuotePort” binding=“StockQuoteBinding” />
</service>
</definitions>”
在部署时,绑定 WSDL 通常替换用于开发的 WSDL。在进行此替换之后,可对端口绑定和地址重定目标。如果要为空端口指定重定目标的绑定名称空间和端点地址,那么可保留非绑定 WSDL。
在修改入站服务配置时,可将已允许进行 Web Service 访问的总线目标的非绑定 WSDL 导出到压缩文件中。导出的非绑定 WSDL 文档然后可用于开发经过消息传递目标发送 Web Service 消息的 Web Service 请求者应用程序。
或者,可使用 java2wsdl 工具来生成非绑定 WSDL。java2wsdl 工具的 -bindingTypes 选项值为“none”。当指定此值时,该工具产生一个非绑定版本的 WSDL 文档来表示 Java 对象。