WSO2 API管理器将SOAP转换为REST

WSO2 API管理器将SOAP转换为REST,rest,soap,wso2,wso2-am,Rest,Soap,Wso2,Wso2 Am,是否可以在API管理器中直接将SOAP服务发布为REST API?调用SOAP时是否可以转换调用并向最终用户公开REST 如果可能,如何进行? 谢谢。是的。您可以将此作为参考。请注意,可能存在一些差异,因为这是为API manager Alpha版本编写的。然而,这是一个很好的切入点。这可能是您正在寻找的。这可以按如下所述进行 如果希望以RESTful方式使用同一API公开多个操作,可以使用以下准则在中修改序列 1) 在API管理器中设计REST API时,创建一个请求URI以映射到后端SOAP

是否可以在API管理器中直接将SOAP服务发布为REST API?调用SOAP时是否可以转换调用并向最终用户公开REST

如果可能,如何进行?

谢谢。

是的。您可以将此作为参考。请注意,可能存在一些差异,因为这是为API manager Alpha版本编写的。然而,这是一个很好的切入点。

这可能是您正在寻找的。这可以按如下所述进行

如果希望以RESTful方式使用同一API公开多个操作,可以使用以下准则在中修改序列

1) 在API管理器中设计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>

$1
$2
作为关于如何使用此类自定义扩展序列映射后端SOAP web服务操作的参考。有了它,您就可以直接将其作为RESTAPI公开

或者,您可以简单地在WSO2 API云或WSO2 API管理器中创建基于SOAP的API,然后将请求负载与SOAP操作头中发送的SOAP操作一起传递,以便可以调用后端web服务的不同操作。您可以在下图中看到这是如何使用的

希望这有帮助

问候