簡體   English   中英

WSO2 API Manager將SOAP轉換為REST

[英]WSO2 API Manager convert SOAP to REST

是否可以直接在API管理器中將SOAP服務作為REST API發布? 是否可以在調用SOAP時轉換調用並將REST公開給最終用戶?

如果可能,怎么樣?
謝謝。

這可能就是你要找的東西。 這可以如下所述完成。

如果要以RESTful方式使用相同的API公開多個操作,可以使用以下准則修改帖子中的序列。

1)在API Manager中設計REST API時,創建一個請求URI以映射到后端SOAP服務中的每個操作。

2)使用過濾器中介(在編程中充當條件語句),您可以從請求URI(操作)中過濾掉並相應地構造所需的有效負載。

對應於映射后端Web服務的各種操作,將重復以下塊。

這里的邏輯是,如果API的請求URI是到SOAP服務的操作Y的X路由。

<!-- this filters out the operations of your API -->

<property expression="json-eval($.operation)" name="operation" />
<filter regex="menu" source="$ctx:operation">

   <header description="SOAPAction" name="SOAPAction" scope="transport" value="http://ws.cdyne.com/PhoneVerify/query/CheckPhoneNumber"/>

<!-- We are storing the input values which the end users input for these values into properties -->

<property name="uri.var.phoneNumber" expression="$url:PhoneNumber"/>
<property name="uri.var.licenseKey" expression="$url:LicenseKey"/>

<!-- Since we do not want the URL pattern we mentioned to be sent to the backend we need to add the below property to remove it -->

<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>

<!-- Now we need to create the actual payload which the backend requires. For that we use the payload factory mediator -->

<payloadFactory description="transform" media-type="xml">
  <format>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://ws.cdyne.com/PhoneVerify/query">
  <soapenv:Header/>
  <soapenv:Body>
  <quer:CheckPhoneNumber>
    <quer:PhoneNumber>$1</quer:PhoneNumber>
    <quer:LicenseKey>$2</quer:LicenseKey>
  </quer:CheckPhoneNumber></soapenv:Body>
  </soapenv:Envelope>
  </format>
  <args>
    <arg expression="get-property(‘uri.var.phoneNumber’)"/>
    <arg expression="get-property(‘uri.var.licenseKey’)"/>
  </args>
</payloadFactory>

有關上述用例的更多信息,您可以參考此文章作為參考,了解如何使用此類自定義擴展序列來映射后端SOAP Web服務操作。 有了這個,您就可以直接將其公開為REST API

或者,您只需在WSO2 API Cloud或WSO2 API Manager中創建基於SOAP的API,然后將請求有效負載與SOAP Action標頭中發送的SOAP操作一起傳遞,以便您可以調用后端Web服務的不同操作。 您可以在下圖中看到如何使用它。

使用單個API管理WSDL操作

希望這可以幫助。

問候。

是。 您可以參考此博客文章作為參考。 請注意,可能存在一些差異,因為這是為API管理器Alpha版本編寫的。 然而,這是一個很好的切入點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM