PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label wso2. Show all posts
Showing posts with label wso2. Show all posts

Sunday, August 28, 2022

[FIXED] How do I skip headers in CSV file in wso2 Integration Studio?

 August 28, 2022     csv, smooks, wso2, wso2-esb, wso2-integration-studio     No comments   

Issue

I am using smooks mediator to convert csv file to json using VFS. We have an option to skip header row while using the CSV connector/module. How do I skip the first row of headers while processing the file in WSO2 Integration studio using smooks?


Solution

In your Smooks configurtion add the following option.

skiplines="1"

Full Smooks Config

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.5.xsd">
<csv:reader fields="name,age,address" separator="," quote="'" skipLines="1" />
</smooks-resource-list>


Answered By - ycr
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, August 6, 2022

[FIXED] how use wso2 OAuth mediator in micro integrator 4.1

 August 06, 2022     oauth, wso2, wso2-identity-server, wso2-micro-integrator     No comments   

Issue

I can not figure out how to use the wso2 OAuth mediator. I use the wso2 micro integrator 4.1, identity server 5.11, and wso2 IntegrationStudio 8.1.

  1. Is this true: OAuth mediator gets an access token and sends it to the identity server and gets the answer if the access token is valid or not?

  2. We should add an OAuth mediator at the beginning of an inSequence?

  3. What should come after the OAuth mediator?

  4. What does the curl message look like when using the OAuth mediator?

I have an API like this (without an OAuth mediator):

<api context="/user-service3" name="Soap2Rest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
    <inSequence>
        <send>
            <endpoint>
                <http method="post" uri-template="http://localhost:9090/user-service" />
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence>
        <send/>
    </faultSequence>
</resource>

I send a curl message like this:

curl -X 'POST' -k 'https://localhost:8253/user-service3' \
-H 'Content-Type: application/soap+xml' \
-H 'accept: */*' \
-d '
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
   <soap:Header/>
   <soap:Body>
      <user:createUser>
         <arg0>abc</arg0>
       </user:createUser>
    </soap:Body>
 </soap:Envelope>'

what should I change in the curl command after adding the OAuth mediator at the beginning of the inSequence?

<oauthService remoteServiceUrl="https://testdomain.org:9444/services/" username="admin" password="admin"/> -->

I tried different ways but get errors from the wso2 identity server. I add the Authorization header to curl.

-H 'Authorization : Bearer 8aa447a9-b929-355c-a885-1b92c5266051' \

But Micro Integrator shows this log:

INFO {LogMediator} - Direction: request, MESSAGE = Executing default 'fault' sequence, 
ERROR_CODE = 0, ERROR_MESSAGE = Error occured while validating oauth 2.0 access token, 
Envelope: 
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
<soap:Body>
  <user:createUser>
     <arg0>abc</arg0>
  </user:createUser>
 </soap:Body></soap:Envelope>

Solution

  1. Yes
  2. It can be anywhere
  3. Anything
  4. Add the Authorization header to curl.

The curl command is correct. Based on this answer I found out some of the wso2 product's org.wso2.carbon.identity.oauth.stub jar files are not compatible with each other. I thought maybe my problem is that.

I copied the org.wso2.carbon.identity.oauth.stub_6.4.111.jar file from the WSO2 Identity Server to the wso2/components/plugins directory of the WSO2 micro integrator.

cp wso2is-5.11.0/repository/components/plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar wso2mi-4.1.0/wso2/components/plugins

Then updated the bundles.info file of the micro integrator:

vi wso2mi-4.1.0/wso2/components/micro-integrator-default/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

modified this line:

org.wso2.carbon.identity.oauth.stub,6.1.0,../plugins/org.wso2.carbon.identity.oauth.stub_6.1.0.jar,4,true

to this:

org.wso2.carbon.identity.oauth.stub,6.4.111,../plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar,4,true

After restarting the micro integrator server, my curl command works fine.



Answered By - ZGC
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, July 25, 2022

[FIXED] How can I read csv data from a file and convert into json using CSV-connector in wso2 Integration studio?

 July 25, 2022     csv, json, wso2, wso2-enterprise-integrator, wso2-integration-studio     No comments   

Issue

I am trying to read csv data from a file and convert it into json data by using the CSV-Connector in WSO2 Integration studio. The data is converted to json when I pass it as payload, but how do I do it when I want to read csv data from a file by using the Connector? What extra connectors or mediators might be required for the same?


Solution

First, you need to read the file using the File Connector or using the VFS transport. (Either use a VFS Listener proxy or a File Inbound Endpoint). There is a File Inbound sample on the getting started page in the Integration Studio.

After reading the file youcan use the CSV-Connector, Datamapper Mediator or use the Smooks Mediator to convert the CSV into a XML and then to a JSON.



Answered By - ycr
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing