參與者可要求取得「社群管理員」所提供的 Web 服務。同樣地, 「社群管理員」也可以要求取得參與者所提供的 Web 服務。參與者或「社群管理員」將呼叫 WebSphere Partner Gateway 伺服器, 以取得 Web 服務。WebSphere Partner Gateway 的角色形同 Proxy, 會將 Web 服務要求傳遞給 Web 服務提供者, 並將提供者的回應同步傳回給要求者。
本節提供下列資訊,說明如何設定 Web 服務以供參與者或「社群管理員」使用:
當「社群管理員」提供 Web 服務以供參與者使用時, WebSphere Partner Gateway 會要求參與者必須提供本身的識別資訊。 在公佈 Web 服務要求時, 請採用下列兩種方式之一來設定身分識別:
當 Web 服務由參與者提供,以供「社群管理員」使用時, 則「社群管理員」在呼叫 Web 服務時所用的公用 URL 中應含有查詢字串 ?to=<participant's_business_ID>。例如:
http://<IP_address>/bcgreceiver/Receiver?to=123456789
這是讓 WebSphere Partner Gateway 知道 Web 服務的提供者是商業 ID 為 123456789 的參與者。
若要設定文件流程定義,您可上傳定義 Web 服務的 WSDL(Web 服務定義語言)檔, 或透過「社群主控台」手動輸入同等的文件流程定義。
Web 服務的定義應放在一個副檔名為 .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 服務的 WSDL 檔案定義時,會將原始 WSDL 儲存成一項驗證對映。( WebSphere Partner Gateway 不會實際驗證 Web 服務訊息。這些訊息會使用原始的服務端點 URL 直接遞送。) 這稱為專用 WSDL。
此外, 公用 WSDL 會隨專用 URL(會換成「上傳/下載資料包」頁面中指定的目標 URL)一起儲存。 公用 WSDL 會提供給 Web 服務的使用者,因為這些使用者會在目標 URL (公用 URL)呼叫 Web 服務。然後 WebSphere Partner Gateway 將 Web 服務要求遞送到原始 Web 服務提供者之專用 URL 的閘道。 WebSphere Partner Gateway 的角色形同 Proxy, 會將 Web 服務要求轉遞給專用提供者 URL(Web 服務使用者看不到此 URL)。
在上傳 WSDL 後,專用和公用 WSDL(包括任何匯入的檔案)皆可從「社群主控台」下載。
WebSphere Partner Gateway 提供一種方法供您匯入 WSDL 檔。 如果 Web 服務是定義在單一 WSDL 檔中,您可直接上傳 WSDL 檔。如果 Web 服務是使用多個 WSDL 檔定義而成 (當主要 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/ReceiverURL 通常和定義在「目標」中的正式作業 HTTP 目標相同。
https://<target_host:port>/bcgreceiver/Receiver?to=<participant_business_ID>
WebSphere Partner Gateway 安裝媒體中提供一組 XML 綱目, 用以說明可經由主控台上傳的 XML 檔。 所上傳的檔案會和這些綱目相驗證。綱目檔是一種相當好用的參照, 有助您在檔案因不符合 XML 而無法上傳時,判斷錯誤的原因。這些檔案為 wsdl.xsd、 wsdlhttp.xsd 和 wsdlsoap.xsd, 內含說明有效「Web 服務定義語言 (WSDL)」檔的綱目。
這些檔案位於 B2BIntegrate\packagingSchemas
若要手動建立同等的文件流程定義, 請遵循本節中的程序進行。您也必須在通訊協定:Web 服務下個別建立「文件流程」、「活動」和「動作」項目, 並特別留意「動作」的需求條件,以及其和所收 SOAP 訊息間之關係的需求條件。
從文件流程定義的「資料包/通訊協定/文件流程/活動/動作」階層來看, 支援的 Web 服務的呈現方式應為:
{<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 服務要求 SOAP 訊息, 並根據所定義的參與者連線適當遞送它。在所收 SOAP 訊息的 soap:body 元素中, 第一個子 XML 元素的名稱空間和名稱, 必須和 WebSphere Partner Gateway 文件流程定義中之已知「動作」的名稱空間和名稱相符。
比方說,假設 Web 服務針對文件-文字 SOAP 連結,要求如下的 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 服務動作:
{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 服務動作:
{http://www.helloworld.com/helloRPC}:helloWorldRPC
若為 RPC 連結,在 SOAP 要求訊息的 soap:body 元素中, 第一個子元素的名稱空間和名稱, 應為適用之 Web 服務作業的名稱空間和名稱。
若為文件-文字連結,在 SOAP 要求訊息的 soap:body 元素中, 第一個子元素的名稱空間和名稱, 應為 Web 服務之輸入 message 定義的 part 元素中 XML element 屬性的名稱空間和名稱。
若要建立 Web 服務的互動,您將在來源和目標方面使用相同的 Web 服務文件流程動作。
若要建立互動,請使用下列程序。
WebSphere Partner Gateway 支援如下標準: