1

I have developed some APIs flow in WSO2 developer studio and host it on WSO2 EI Server.

And then i published those URLs to WSO2 API Publisher and implemented the oAuth2 security over there.

At last the client/consumer have access to the URLs from API Publisher.

Now what i want that every request and response of the service should be stored in MySQL external table.

Any idea what to do in WSO2 EI flow. or any other alternate.

Community
  • 1
  • 1
Chris Ryan
  • 11
  • 6

1 Answers1

0

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. You need to create a data service wherein you need to mention the query of MySQL else you can use a 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. For DB Mediator refer below link. 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>
amg_amit
  • 495
  • 1
  • 3
  • 9
  • any source code you can provide for this as i am new to wso2. Thanks for your response. – Chris Ryan Oct 01 '18 at 08:20
  • Thanks so much. Can you tell me one more issue i am consuming a service that required ws security username token and i have implemented policy but it showed me an error about "password call back class not found" i don't need to write the callback class as the username and password is fixed. – Chris Ryan Oct 02 '18 at 06:36
  • Have you followed the link https://docs.wso2.com/display/ESB500/Applying+Security+to+a+Proxy+Service – amg_amit Oct 02 '18 at 09:16
  • i tried through rampart username token but it showed me below error: Missing wsse:Security header in request {org.apache.axis2.engine.AxisEngine} I am not sure why it is not auto inserting in my request. – Chris Ryan Oct 03 '18 at 09:31