参与者可以请求由社区管理者提供的 Web Service。同样,社区管理者可以请求由参与者提供的 Web Service。参与者或社区管理者调用 WebSphere Partner Gateway 服务器以获取 Web Service。WebSphere Partner Gateway 充当代理,它把 Web Service 请求传递给 Web Service 提供者,将提供者的响应同步返回给请求者。
本部分介绍如何设置供参与者或社区管理者使用的 Web Service,其主要内容如下:
当 Web Service 由社区管理者提供给参与者使用时,WebSphere Partner Gateway 要求参与者标识自己。 当发布 Web Service 请求时,用下列两种方式之一来设置标识:
当 Web Service 由参与者提供给社区管理者使用时,社区管理者用来调用 Web Service 的公共 URL 应包含查询字符串 ?to=<participant's_business_ID>。例如:
http://<IP_address>/bcgreceiver/Receiver?to=123456789
这告诉 WebSphere Partner Gateway,Web Service 的提供者是企业标识为 123456789 的参与者。
要设置文档流定义,请上载用于定义 Web Service 的 WSDL(Web Service 定义语言)文件,或者通过“社区控制台”手工输入等效的文档流定义。
Web Service 的定义应包含在一个主 WSDL 文件(扩展名为 .wsdl)中,该文件可能通过 import 元素 导入其它 WSDL 文件。如果具有导入的文件,可以通过下列方法之一将这些文件与主文件一起上载:
例如,假设主 WSDL 文件 helloworldRPC.wsdl 包含下列 import 元素:
<import namespace="http://www.helloworld.com/wsdl/helloRPC.wsdl" location= "bindingRPC.wsdl"/>
并假设已导入的 WSDL 文件 bindingRPC.wsdl 包含下列 import 元素:
<import namespace="http://www.helloworld.com/wsdl/helloRPC.wsdl" location= "port/porttypeRPC.wsdl"/>
该文件应包含以下内容:
名称 路径 helloworldRPC.wsdl bindingRPC.wsdl porttypeRPC.wsdl port\
当上载 Web Service 的 WSDL 文件定义时,原始的 WSDL 将保存为验证映射。(WebSphere Partner Gateway 并不真正验证 Web service 消息。 它们直接通过 WebSphere Business Integration Connect,仍使用原来的服务端点 URL。)这称为专用 WSDL。
另外,会用由在“上载/下载包”页面上指定的目标 URL 替换的专用 URL 来保存公共 WSDL。公共 WSDL 将被提供给 Web Service 的用户,用户将在目标 URL(公共 URL)调用 Web Service。WebSphere Partner Gateway 将把 Web Service 请求路由到网关,该网关具有原始 Web Service 提供者的专用 URL。WebSphere Partner Gateway 充当代理,将 Web Service 请求转发到专用的提供者 URL,该 URL 对于 Web Service 用户是隐藏的。
在上载 WSDL 之后,可以从“社区控制台”下载专用和公共的 WSDL(包括任何导入的文件)。
WebSphere Partner Gateway 提供了导入 WSDL 文件的方法。如果在一个 WSDL 文件中定义 Web Service,则您可以直接上载该 WSDL 文件。如果使用多个 WSDL 文件定义 Web Service(当您将多个 WSDL 文件导入一个主 WSDL 文件时会发生这种情况),这些文件应该上载到压缩归档中。
<import namespace="http://www.helloworld.com/wsdl/helloRPC.wsdl" location="path1/bindingRPC.wsdl"/>压缩归档中的目录结构是:path1/bindingRPC.wsdl。
现在,请考虑以下示例:
<import namespace="http://www.helloworld.com/wsdl/helloRPC.wsdl" location="bindingRPC.wsdl"/>.
bindingRPC.wsdl 文件应该位于压缩归档的根级别。
要上载单个 WSDL 文件或压缩归档,请使用下列过程。
https://<target_host:port>/bcgreceiver/Receiver该 URL 通常与在“目标”中定义的生产 HTTP 目标相同。
https://<target_host:port>/bcgreceiver/Receiver?to=<participant_business_ID>
在 WebSphere Partner Gateway 安装介质上提供了一组 XML 模式,它们描述了可以通过控制台 上载的 XML 文件。将根据这些模式验证上载文件。当不符合标准的 XML 导致不能上载文件时,这些模式文件是确定错误源的有效 参考。这些文件是:wsdl.xsd、wsdlhttp.xsd 和 wsdlsoap.xsd,它们包含描述有效 Web Service 定义语言(WSDL)文件的模式。
这些文件位于:B2BIntegrate\packagingSchemas
要手工输入等效的文档流定义,请遵循本部分中的步骤。 您还必须在协议:Web Service 下逐一创建文档流、活动和操作各项,并要特别注意,对操作的需求,及其与收到的 SOAP 消息的关系。
根据文档流定义的包/协议/文档流/活动/操作的层次结构,一个受支持的 Web Service 如下表示:
{<operation_namespace>}:<operation_name>
{<namespace_of_identifying_xml_element = first_child_of_soap:body>}: <name_of _identifying_xml_element = first_child_of_soap:body>
“操作”是关键的定 义,因为 WebSphere Partner Gateway 将使用“操作”的名称空间和名称来识别入站 Web Service 请求 SOAP 消息,并根据已定义的参与者连接来正确地路由该消息。 收到的 SOAP 消息 soap:body 元素的第一个 XML 子元素的名称空间和名称必须与 WebSphere Partner Gateway 的文档流定义中某个已知“操作”的名称空间和名称相匹配。
例如,假设 document-literal SOAP 绑定的 Web service 请求 SOAP 消息是:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance"> <soapenv:Body> <nameAndAddressElt xmlns="http://www.helloworld.com/xsd/helloDocLitSchema"> <titleElt xmlns="">Mr</titleElt> <nameElt xmlns="">Joe Smith</nameElt> <addressElt xmlns=""> <numberElt>123</numberElt> <streetElt>Elm St</streetElt> <cityElt>Peoria</cityElt> </addressElt> </nameAndAddressElt> </soapenv:Body> </soapenv:Envelope>
WebSphere Partner Gateway 应该用下列代码来查找已定义的 Web Service 操作:
{http://www.helloworld.com/xsd/helloDocLitSchema}:nameAndAddressElt
对于 RPC 绑定样式的 SOAP 请求消息,例如:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd= "http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance"> <soapenv:Body> <ns1:helloWorldRPC soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/ xmlns:ns1="http://www.helloworld.com/helloRPC"> <name xsi:type="xsd:string">Joe Smith</name> </ns1:helloWorldRPC> </soapenv:Body> </soapenv:Envelope>
WebSphere Partner Gateway 应该用下列代码来查找已定义的 Web Service 操作:
{http://www.helloworld.com/helloRPC}:helloWorldRPC
对于 RPC 绑定,SOAP 请求消息的 soap:body 元素的第一个子元素的名称空间和名称 应该是适用的 Web Service 操作的名称空间和名称。
对于 Document-Literal 绑定,SOAP 请求消息的 soap:body 元素的第一个子元素的名称空间和名称 应该是 Web Service 的输入 message 定义的 part 元素中 XML element 属性的名称空间和名称。
要创建 Web service 的交互,请对源和目标使用相同的 Web service 文档流操作。
要创建交互,请使用下列过程。
WebSphere Partner Gateway 支持下列标准: