2013-01-24 54 views
2

是否有可能發佈一個SOAP服務的REST API直接API管理?在調用SOAP時是否可以轉換調用並將REST公開給最終用戶?WSO2 API管理SOAP轉換的休息

如果可能的話,怎麼樣?
謝謝。

回答

0

是的。你可以參考這個blog post作爲參考。請注意,這可能會有一些差異,因爲這是爲API管理器Alpha版編寫的。但它是一個很好的切入點。

1

這可能是你在找什麼。這可以如下所述完成。

如果你想使用相同的API以RESTful的方式,你可以使用以下準則修改的post序列暴露多個操作。

1)創建一個請求的URI來設計的API管理器中的REST API時映射到每個操作後端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> 

關於上述使用情況的更多信息,你可以,你可以參考這個post作爲參考如何這樣自定義擴展序列已被用來映射後端SOAP的Web服務操作。有了這個,你可以直接將它公開爲REST API。

或者您可以簡單地在WSO2 API Cloud或WSO2 API Manager中創建基於SOAP的API,然後將請求有效負載與在SOAP Action標頭,以便您可以調用後端Web服務的不同操作。你可以看到如何在下面的圖片中使用它。

Managing WSDL operations using a single API

希望這有助於。

問候。