首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSO2EI集成hello

WSO2EI集成hello
EN

Stack Overflow用户
提问于 2017-04-26 08:04:28
回答 1查看 250关注 0票数 0

我刚从云技术开始,我正在尝试实现一个简单的hello world示例。我正在使用新的wso2企业集成服务器。我正在尝试设置一个简单的API。

我实现了一个端点:

代码语言:javascript
复制
<endpoint xmlns="http://ws.apache.org/ns/synapse">
   <address uri="http://192.168.1.100:9191/v1/hello">
      <suspendOnFailure>
         <progressionFactor>1.0</progressionFactor>
       </suspendOnFailure>
       <markForSuspension>
         <retriesBeforeSuspension>0</retriesBeforeSuspension>
          <retryDelay>0</retryDelay>
      </markForSuspension>
   </address>
</endpoint>

我实现了两个序列:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="HelloWorldIN" xmlns="http://ws.apache.org/ns/synapse">
    <send>
        <endpoint key="gov:/HelloWorld"/>
    </send>
</sequence>

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="HelloWorldOUT" xmlns="http://ws.apache.org/ns/synapse">
    <send/>
</sequence>

最后,API本身

代码语言:javascript
复制
<api xmlns="http://ws.apache.org/ns/synapse" name="HelloWorld" context="/helloworld" hostname="192.168.1.100" port="9191">
   <resource methods="GET" uri-template="/v1/hello" inSequence="HelloWorldIN" outSequence="HelloWorldOUT"/>
</api>

当我对这个API执行GET (http://192.168.1.162:8280/helloworld/v1/hello )请求时,我得到了202个接受的响应,没有数据。任何帮助都将不胜感激。

编辑:这是完整的配置:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
        <parameter name="cachableDuration">15000</parameter>
    </registry>
    <taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"/>
    <sequence name="HelloWorldOUT">
        <send buildmessage="true"/>
    </sequence>
     <sequence name="fault">
         <!-- Log the message at the full log level with the ERROR_MESSAGE and the ERROR_CODE-->
        <log level="full">
             <property name="MESSAGE" value="Executing default 'fault' sequence"/>
             <property expression="get-property('ERROR_CODE')" name="ERROR_CODE"/>
             <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE"/>
          </log>
         <!-- Drops the messages by default if there is a fault -->
         <drop/>
     </sequence>
     <sequence name="main">
         <in>
             <!-- Log all messages passing through -->
             <log level="full"/>
             <!-- ensure that the default configuration only sends if it is one of samples -->
             <!-- Otherwise Synapse would be an open proxy by default (BAD!)               -->
             <filter regex="http://localhost:9000.*" source="get-property('To')">
                 <!-- Send the messages where they have been sent (i.e. implicit "To" EPR) -->
                 <send/>
             </filter>
         </in>
         <out>
             <send/>
         </out>
         <description>The main sequence for the message mediation</description>
     </sequence>
     <sequence name="HelloWorldIN">
         <send>
             <endpoint name="gov//HelloWorld">
                 <address uri="http://192.168.1.100:9191/v1/hello"/>
             </endpoint>
         </send>
     </sequence>
     <api context="/helloworld" hostname="192.168.1.100"
    name="HelloWorld" port="9191" statistics="enable" trace="enable">
         <resource inSequence="HelloWorldIN" methods="GET"
        outSequence="HelloWorldOUT" uri-template="*"/>
     </api>
     <!-- You can add any flat sequences, endpoints, etc.. to this synapse.xml file if you do
*not* want to keep the artifacts in several files -->
EN

回答 1

Stack Overflow用户

发布于 2017-04-27 06:38:45

首先要做的是改变主要的顺序。我已经把它按顺序排列好了:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="main" xmlns="http://ws.apache.org/ns/synapse">
    <in>
        <!-- Log all messages passing through -->
        <log level="full"/>
        <!-- ensure that the default configuration only sends if it is one of samples -->
        <!-- Otherwise Synapse would be an open proxy by default (BAD!)               -->
        <filter regex="http://localhost:9000.*"
        source="get-property('To')" xmlns:ns="http://org.apache.synapse/xsd">
            <then>
                <!-- Send the messages where they have been sent (i.e. implicit "To" EPR) -->
                <send/>
            </then>
            <else>
                <log/>
                <sequence key="gov:/HelloWorldIN"/>
            </else>
        </filter>
    </in>
    <out>
        <send/>
    </out>
    <description>The main sequence for the message mediation</description>
</sequence>

确保您的api使用有意义的名称。这使得配置esb变得更容易。如果您的api位于同一个子域上,则不需要URL重写中介器。为此,我更改了API的上下文。

代码语言:javascript
复制
<api xmlns="http://ws.apache.org/ns/synapse" name="HelloWorld" context="/hello" hostname="192.168.1.100" port="9191">
   <resource methods="GET" inSequence="HelloWorldIN" outSequence="HelloWorldOUT"/>
</api>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43628313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档