Passing payloads from API to ESB

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing payloads from API to ESB

Buddhimala Ranasinghe
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Dushantha Batuwita
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Piriya Sivalingam
Hi Dushantha,

Since I have GET, POST,PUT, DELETE methods in my proxy, do you say the above-suggested method will work for GET. I have tried it but could not achieve it.
And if I am correct, your example is about POST or PUT method. 
Could you please let me know whether I can use the same way for all four methods or only specific to POST method.

Thank you.


On Wed, Nov 15, 2017 at 3:10 PM, Dushantha Batuwita <[hidden email]> wrote:
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : +94 77 8462039

http://wso2.com/signature


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Dushantha Batuwita
Hi Piriya

Above approach, you can implement in the POST and PUT.
The resource type GET produces a request that does not have a body (payload), 
hence we set the required parameter as a query parameter when you set the resource GET while creating the API in publisher. (please refer to the attached image )
Then the request parameter is accessed within the payload mediator of the proxy service ( within the <args> element) in ESB as the following example.



<payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:ser="http://service.sample.oasis.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://dto.service.sample.oasis.com/xsd">
                <soapenv:Header>1</soapenv:Header>
                <soapenv:Body>
                    <ser:deleteOrderData>
                        <!--Optional:-->
                        <ser:orderNumber>$1</ser:orderNumber>
                    </ser:deleteOrderData>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="$url:order_id" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args> 
</payloadFactory> 


please refer to the following link for better understanding of the REST Parameters
https://www.soapui.org/rest-testing/understanding-rest-parameters.html

many thanks
    

On Wed, Nov 15, 2017 at 5:19 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi Dushantha,

Since I have GET, POST,PUT, DELETE methods in my proxy, do you say the above-suggested method will work for GET. I have tried it but could not achieve it.
And if I am correct, your example is about POST or PUT method. 
Could you please let me know whether I can use the same way for all four methods or only specific to POST method.

Thank you.


On Wed, Nov 15, 2017 at 3:10 PM, Dushantha Batuwita <[hidden email]> wrote:
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Dushantha Batuwita
Hi Priya

please find the attached image which I was referring in the above answer.
sorry for the mixup
Regards

On Wed, Nov 15, 2017 at 5:30 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Piriya

Above approach, you can implement in the POST and PUT.
The resource type GET produces a request that does not have a body (payload), 
hence we set the required parameter as a query parameter when you set the resource GET while creating the API in publisher. (please refer to the attached image )
Then the request parameter is accessed within the payload mediator of the proxy service ( within the <args> element) in ESB as the following example.



<payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:ser="http://service.sample.oasis.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://dto.service.sample.oasis.com/xsd">
                <soapenv:Header>1</soapenv:Header>
                <soapenv:Body>
                    <ser:deleteOrderData>
                        <!--Optional:-->
                        <ser:orderNumber>$1</ser:orderNumber>
                    </ser:deleteOrderData>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="$url:order_id" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args> 
</payloadFactory> 


please refer to the following link for better understanding of the REST Parameters
https://www.soapui.org/rest-testing/understanding-rest-parameters.html

many thanks
    

On Wed, Nov 15, 2017 at 5:19 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi Dushantha,

Since I have GET, POST,PUT, DELETE methods in my proxy, do you say the above-suggested method will work for GET. I have tried it but could not achieve it.
And if I am correct, your example is about POST or PUT method. 
Could you please let me know whether I can use the same way for all four methods or only specific to POST method.

Thank you.


On Wed, Nov 15, 2017 at 3:10 PM, Dushantha Batuwita <[hidden email]> wrote:
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev

apiscrenshot.png (48K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Dushantha Batuwita
Hi Buddhimala:

my pleasure

regards

On Thu, Nov 16, 2017 at 10:40 AM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi Dushantha,

Thank you for the explanation and the solution. It is working for me now.

Regards,
Buddhimala

On Wed, Nov 15, 2017 at 5:32 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Priya

please find the attached image which I was referring in the above answer.
sorry for the mixup
Regards

On Wed, Nov 15, 2017 at 5:30 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Piriya

Above approach, you can implement in the POST and PUT.
The resource type GET produces a request that does not have a body (payload), 
hence we set the required parameter as a query parameter when you set the resource GET while creating the API in publisher. (please refer to the attached image )
Then the request parameter is accessed within the payload mediator of the proxy service ( within the <args> element) in ESB as the following example.



<payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:ser="http://service.sample.oasis.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://dto.service.sample.oasis.com/xsd">
                <soapenv:Header>1</soapenv:Header>
                <soapenv:Body>
                    <ser:deleteOrderData>
                        <!--Optional:-->
                        <ser:orderNumber>$1</ser:orderNumber>
                    </ser:deleteOrderData>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="$url:order_id" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args> 
</payloadFactory> 


please refer to the following link for better understanding of the REST Parameters
https://www.soapui.org/rest-testing/understanding-rest-parameters.html

many thanks
    

On Wed, Nov 15, 2017 at 5:19 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi Dushantha,

Since I have GET, POST,PUT, DELETE methods in my proxy, do you say the above-suggested method will work for GET. I have tried it but could not achieve it.
And if I am correct, your example is about POST or PUT method. 
Could you please let me know whether I can use the same way for all four methods or only specific to POST method.

Thank you.


On Wed, Nov 15, 2017 at 3:10 PM, Dushantha Batuwita <[hidden email]> wrote:
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Passing payloads from API to ESB

Senuwan Withana
Thank you Dushantha, It also works for me.

Senuwan Withana
Software Engineer - Support Team | WSO2

Email : [hidden email]
Mobile: 94773212853
Web: http://www.wso2.com



On Thu, Nov 16, 2017 at 11:21 AM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala:

my pleasure

regards

On Thu, Nov 16, 2017 at 10:40 AM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi Dushantha,

Thank you for the explanation and the solution. It is working for me now.

Regards,
Buddhimala

On Wed, Nov 15, 2017 at 5:32 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Priya

please find the attached image which I was referring in the above answer.
sorry for the mixup
Regards

On Wed, Nov 15, 2017 at 5:30 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Piriya

Above approach, you can implement in the POST and PUT.
The resource type GET produces a request that does not have a body (payload), 
hence we set the required parameter as a query parameter when you set the resource GET while creating the API in publisher. (please refer to the attached image )
Then the request parameter is accessed within the payload mediator of the proxy service ( within the <args> element) in ESB as the following example.



<payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:ser="http://service.sample.oasis.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://dto.service.sample.oasis.com/xsd">
                <soapenv:Header>1</soapenv:Header>
                <soapenv:Body>
                    <ser:deleteOrderData>
                        <!--Optional:-->
                        <ser:orderNumber>$1</ser:orderNumber>
                    </ser:deleteOrderData>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="$url:order_id" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args> 
</payloadFactory> 


please refer to the following link for better understanding of the REST Parameters
https://www.soapui.org/rest-testing/understanding-rest-parameters.html

many thanks
    

On Wed, Nov 15, 2017 at 5:19 PM, Piriya Sivalingam <[hidden email]> wrote:
Hi Dushantha,

Since I have GET, POST,PUT, DELETE methods in my proxy, do you say the above-suggested method will work for GET. I have tried it but could not achieve it.
And if I am correct, your example is about POST or PUT method. 
Could you please let me know whether I can use the same way for all four methods or only specific to POST method.

Thank you.


On Wed, Nov 15, 2017 at 3:10 PM, Dushantha Batuwita <[hidden email]> wrote:
please refer to the above answers

Regards

On Wed, Nov 15, 2017 at 2:35 PM, Dushantha Batuwita <[hidden email]> wrote:
Hi Buddhimala
Accessing the JSON payload parameters and retrieving those within the proxy service can be achieved with the <args> element of the Payload factory mediator according to your scenario.  
Setting already retrieved parameters to the predefined soap structure is accomplished within the <format> element.

suppose that we need to access the following JSON structure 

{
    "orderLine": {

        "ordername": "Cooking Item",
        "orderid": "123456",
        "product": {

            "productname": "coconutoil",
            "productgrade": "drade1",
            "productcolour": "white"

        }
    }
}


and retrieve the values in order to set to the soap structure given bellow within the payload factory is as follows refer to document[1] for further details
<payloadFactory media-type="xml">
        <format>             
            <soapenv:Envelope
                <soapenv:Header/>
                 <soapenv:Body>
                    <ser:addOrderLineRecord>
                        <ser:orderLine>
                            <xsd:product>
                                <xsd:productname>$1</xsd:ordername>
                                <xsd:productgrade>$2</xsd:orderid>
                                <xsd:productcolour>$3</xsd:productcolour>
                            </xsd:product>                            
                            <xsd:ordername>$4</xsd:ordername>
                            <xsd:orderid>$5</xsd:orderid>                            
                        </ser:orderLine>
                    </ser:addOrderLineRecord>
                </soapenv:Body>
            </soapenv:Envelope>
</format>
<args>
            <arg evaluator="json" expression="$.orderLine.product.productname"/>
            <arg evaluator="json" expression="$.orderLine.product.productgrade"/>
            <arg evaluator="json" expression="$.orderLine.product.productcolour"/>
            <arg evaluator="json" expression="$.orderLine.ordername"/>
            <arg evaluator="json" expression="$.orderLine.orderid"/>
</args>
</payloadFactory>

NOTE: when you set the $n parameter to be couches to follow the order in which the args are defined. i.e. the first line of the arg refer to $1.. and etc

Regards

On Wed, Nov 15, 2017 at 2:32 PM, Buddhimala Ranasinghe <[hidden email]> wrote:
Hi All,

I need to pass a json payload from an API to ESB proxy service. In ESB, I'm using parameters in the passed JSON payload inside payloadFactory mediator in my ESB which will be sent towards a secured SOAP BE. Can you please guide me on this? I need to know how could those parameters can be addressed inside my proxy service.

Regards,
Buddhimala

--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Regards,
Piriya Sivalingam
Software Engineer - Support Team
WSO2
Mobile : <a href="tel:+94%2077%20846%202039" value="+94778462039" target="_blank">+94 77 8462039

http://wso2.com/signature




--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Buddhimala Ranasinghe

Software Engineer-Support Team | WSO2
Mobile:<a href="tel:+94%2077%20156%203138" value="+94771563138" target="_blank">+94771563138
https://wso2.com/signature



--
Dushantha Nayanajith Chandima Batuwita
Software Engineer Support | WSO2
[hidden email]
mobile : 0094777453010

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev



_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev