简体   繁体   English

WSO2将每个请求和响应以及请求者IP保存在MYSQL数据库中

[英]WSO2 Save each request and response with requester IP in MYSQL Database

I have developed some APIs flow in WSO2 developer studio and host it on WSO2 EI Server. 我在WSO2开发人员工作室中开发了一些API流程,并将其托管在WSO2 EI服务器上。

And then i published those URLs to WSO2 API Publisher and implemented the oAuth2 security over there. 然后,我将这些URL发布到WSO2 API Publisher,并在那里实现了oAuth2安全。

At last the client/consumer have access to the URLs from API Publisher. 最终,客户端/消费者可以从API Publisher访问URL。

Now what i want that every request and response of the service should be stored in MySQL external table. 现在我希望服务的每个请求和响应都应该存储在MySQL外部表中。

Any idea what to do in WSO2 EI flow. 知道在WSO2 EI流程中该做什么。 or any other alternate. 或其他任何替代方法。

You need to store the request when it comes to the sequence in a property mediator and the same has to be done for response . 当涉及序列时,您需要将request存储在property mediator并且必须对response You need to create a data service wherein you need to mention the query of MySQL else you can use a DB mediator . 您需要创建一个data service其中需要提及MySQL的查询,否则您可以使用DB mediator Next before ending the out sequence with a send or loopback or respond mediator you need to use clone mediator and call either the data service or DB mediator . 接下来,在使用send or loopback or respond mediator程序结束out序列之前,您需要使用clone mediator并调用data serviceDB mediator For DB Mediator refer below link. 对于DB Mediator,请参考下面的链接。 https://docs.wso2.com/display/ESB500/Sample+361%3A+Introduction+to+DBReport+Mediator https://docs.wso2.com/display/ESB500/Sample+361%3A+Introduction+to+DBReport+Mediator

Below is the code snippet 下面是代码片段

<sequence name="cloneTest" xmlns="http://ws.apache.org/ns/synapse">

    <in>
     <property expression="." name="requestBody" scope="default" type="STRING"/>

     <call>
     <endpoint key="conf:/custom/TestEP/BennerERPEndpoint.xml"/>
     </call>
     <property expression="." name="responseBody" scope="default" type="STRING"/>
        <clone sequential="false">
            <target>
                <sequence>
                    <log level="custom">
                        <property name="Into DB Mediator Sequence" value="DBMediator"/>
                    </log>
                    <sequence key="DBMediator"/>

                </sequence>
            </target>
            <target>
                <sequence>
                    <log level="custom">
                        <property name="Exiting" value="Exit"/>
                    </log>
                   <send/>
                </sequence>
            </target>
        </clone>
    </in>
</sequence>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM