WSO2 API Manager 将 SOAP 转换为 REST [英] WSO2 API Manager convert SOAP to REST

查看:41
本文介绍了WSO2 API Manager 将 SOAP 转换为 REST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to publish a SOAP service as a REST API directly in the API manager? Is it possible to convert the call and expose REST to end user while calling the SOAP?

如果可能,怎么做?
谢谢.

If possible, how?
Thanks.

推荐答案

这可能就是您要找的.这可以按照下面提到的方法完成.

This might be what you are looking for. This has can be done as mentioned below.

如果您想以 RESTful 方式使用相同的 API 公开多个操作,您可以修改 使用以下指南发布.

If you want to expose multiple operations using the same API in a RESTful manner you can modify the sequence in the post using the following guidelines.

1) 在 API Manager 中设计 REST API 时,创建一个请求 URI 以映射到后端 SOAP 服务中的每个操作.

1) Create a request URI to map to each operation in your backend SOAP service when designing the REST API in API Manager.

2) 使用过滤器中介器(在编程中充当条件语句),您可以从请求 URI(操作)中过滤掉并相应地构建所需的负载.

2) Using the filter mediator (which acts as a conditional statement in programming) you can filter out from the request URI(operation) and construct the required payload accordingly.

对应于映射后端 Web 服务的各种操作,将重复以下块.

The below block would be repeated corresponding to your various operations mapping your backend web service.

这里的逻辑是,如果 API 的请求 URI 是到 SOAP 服务的操作 Y 的 X 路由.

The logic here would be if the request URI of the API is X route to operation Y of the SOAP service.

<!-- 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

For further information on the above use case you can you can refer this post as reference on how such a custom extension sequence has been used to map a backend SOAP web service operations. With this you would be able to directly expose it as a REST API

或者您可以简单地在 WSO2 API Cloud 或 WSO2 API Manager 中创建一个基于 SOAP 的 API,然后将请求有效负载与 SOAP Action 标头中发送的 SOAP 操作一起传递,以便您可以调用后端 Web 的不同操作服务.您可以在下图中看到这是如何使用的.

Or you can simply create an SOAP based API in the WSO2 API Cloud or WSO2 API Manager and then pass the request payload along with the SOAP operation sent in the SOAP Action header so that you can call the different operations of your backend web service. You can see how this is used in the image below.

使用单个 API 管理 WSDL 操作

希望这会有所帮助.

问候.

这篇关于WSO2 API Manager 将 SOAP 转换为 REST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆