You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Miyuru Wanninayaka <mi...@gmail.com> on 2013/01/16 10:19:53 UTC

Payload factory mediator to support creating full SOAPEnvelope

Hi all,

Currently Payload factory mediator only supports generating content of SOAP
body and there is no way to create full SOAP message with SOAP headers
using payload factory mediator.

How about implementing this?

option 1. We can add a attribute to payload factory mediator to define
whether result need to set as SOAP enveloper / SOAP body

         <payloadFactory target="envelope | body>
            <format>
               <soapenv:Envelope xmlns:soapenv="
http://www.w3.org/2003/05/soap-envelope">
                  <soapenv:Header>
                     <foo>
                        <bar>?</bar>
                     </foo>
                  </soapenv:Header>
                  <soapenv:Body>
                      <request>?</request>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
         </payloadFactory>

option 2. In payloadFactory, check for structure of message. If it is a
SOAP envelope, set as mc.setEnvelope(), else set as content of existing
message's body.

I prefer option#2 because, because no need to add 1 more attribute to
payloadFactory config.

WDYT?

-- 
Miyuru Wanninayaka
Senior Software Engineer - WSO2 Inc <http://wso2.com/>.

Re: Payload factory mediator to support creating full SOAPEnvelope

Posted by Udayanga Wickramasinghe <ma...@gmail.com>.
Hi,

On Fri, Jan 18, 2013 at 12:26 AM, Miyuru Wanninayaka <mi...@gmail.com>wrote:

> Hi Sadeep,
>
> Having target xpath seems too much, but creating full envelope is a common
> use case. Payload is not just content of soap body, but the full envelope.
> Especially most cloud services like salesforce heavily use headers which
> makes synapse configuration too complex with lots of header mediators. And
> without target attribute, we can make this just work by looking at content
> of format element of payload factory mediator. If it is normal XML, set
> result as body content. If is an Envelope, set it as mc.setEnvelope.
>
>
I too think "target" attribute really makes less sense.. But option 2 you
have suggested looks reasonable and usually would be a naive solution for
many usecases (including modifying SOAP  headers easily)..

Regards,
Udayanga

I have already tested this approach and working fine.
>
>
>
> On Wed, Jan 16, 2013 at 5:48 PM, Sadeep Jayasumana <ga...@gmail.com>wrote:
>
>> Hi,
>>
>> When Payload-factory mediator was initially developed, the main objective
>> was to provide an easy and intuitive way to create a new payload from a
>> well defined template. It turns out to be a very common use case, specially
>> when integrating data services. Although the same functionality can be
>> gained from Enrich mediator with somewhat less obvious configuration, we
>> thought adding a new mediator is justified given how common the use case is.
>>
>> Using Payload-factory mediator with 'target' attribute to modify a part
>> of the envelop makes less sense to me, we might as well use Enrich mediator
>> for such cases.
>>
>> Thanks,
>> Sadeep
>>
>> On Wed, Jan 16, 2013 at 10:42 PM, Senaka Fernando <se...@gmail.com>wrote:
>>
>>> Hi Miyuru,
>>>
>>> Just a question. can't we make the target an XPath expression? That way
>>> you can modify any part of the envelope AFAIU.
>>>
>>> WDYT?
>>>
>>> Thanks,
>>> Senaka.
>>>
>>>
>>> On Wed, Jan 16, 2013 at 2:49 PM, Miyuru Wanninayaka <mi...@gmail.com>wrote:
>>>
>>>> Hi all,
>>>>
>>>> Currently Payload factory mediator only supports generating content of
>>>> SOAP body and there is no way to create full SOAP message with SOAP headers
>>>> using payload factory mediator.
>>>>
>>>> How about implementing this?
>>>>
>>>> option 1. We can add a attribute to payload factory mediator to define
>>>> whether result need to set as SOAP enveloper / SOAP body
>>>>
>>>>          <payloadFactory target="envelope | body>
>>>>             <format>
>>>>                <soapenv:Envelope xmlns:soapenv="
>>>> http://www.w3.org/2003/05/soap-envelope">
>>>>                   <soapenv:Header>
>>>>                      <foo>
>>>>                         <bar>?</bar>
>>>>                      </foo>
>>>>                   </soapenv:Header>
>>>>                   <soapenv:Body>
>>>>                       <request>?</request>
>>>>                   </soapenv:Body>
>>>>                </soapenv:Envelope>
>>>>             </format>
>>>>          </payloadFactory>
>>>>
>>>> option 2. In payloadFactory, check for structure of message. If it is
>>>> a SOAP envelope, set as mc.setEnvelope(), else set as content of existing
>>>> message's body.
>>>>
>>>> I prefer option#2 because, because no need to add 1 more attribute to
>>>> payloadFactory config.
>>>>
>>>> WDYT?
>>>>
>>>> --
>>>> Miyuru Wanninayaka
>>>> Senior Software Engineer - WSO2 Inc <http://wso2.com/>.
>>>
>>>
>>>
>>
>>
>> --
>>
>> Sadeep Jayasumana
>>
>> **
>>
>> Email: gayansadeep@gmail.com****
>>
>> Mobile: +61 4 1468 8521
>>
>>
>
>
> --
> Miyuru Wanninayaka
> Senior Software Engineer - WSO2 Inc <http://wso2.com/>.
>



-- 
http://www.udayangawiki.blogspot.com

Re: Payload factory mediator to support creating full SOAPEnvelope

Posted by Miyuru Wanninayaka <mi...@gmail.com>.
Hi Sadeep,

Having target xpath seems too much, but creating full envelope is a common
use case. Payload is not just content of soap body, but the full envelope.
Especially most cloud services like salesforce heavily use headers which
makes synapse configuration too complex with lots of header mediators. And
without target attribute, we can make this just work by looking at content
of format element of payload factory mediator. If it is normal XML, set
result as body content. If is an Envelope, set it as mc.setEnvelope.

I have already tested this approach and working fine.


On Wed, Jan 16, 2013 at 5:48 PM, Sadeep Jayasumana <ga...@gmail.com>wrote:

> Hi,
>
> When Payload-factory mediator was initially developed, the main objective
> was to provide an easy and intuitive way to create a new payload from a
> well defined template. It turns out to be a very common use case, specially
> when integrating data services. Although the same functionality can be
> gained from Enrich mediator with somewhat less obvious configuration, we
> thought adding a new mediator is justified given how common the use case is.
>
> Using Payload-factory mediator with 'target' attribute to modify a part of
> the envelop makes less sense to me, we might as well use Enrich mediator
> for such cases.
>
> Thanks,
> Sadeep
>
> On Wed, Jan 16, 2013 at 10:42 PM, Senaka Fernando <se...@gmail.com>wrote:
>
>> Hi Miyuru,
>>
>> Just a question. can't we make the target an XPath expression? That way
>> you can modify any part of the envelope AFAIU.
>>
>> WDYT?
>>
>> Thanks,
>> Senaka.
>>
>>
>> On Wed, Jan 16, 2013 at 2:49 PM, Miyuru Wanninayaka <mi...@gmail.com>wrote:
>>
>>> Hi all,
>>>
>>> Currently Payload factory mediator only supports generating content of
>>> SOAP body and there is no way to create full SOAP message with SOAP headers
>>> using payload factory mediator.
>>>
>>> How about implementing this?
>>>
>>> option 1. We can add a attribute to payload factory mediator to define
>>> whether result need to set as SOAP enveloper / SOAP body
>>>
>>>          <payloadFactory target="envelope | body>
>>>             <format>
>>>                <soapenv:Envelope xmlns:soapenv="
>>> http://www.w3.org/2003/05/soap-envelope">
>>>                   <soapenv:Header>
>>>                      <foo>
>>>                         <bar>?</bar>
>>>                      </foo>
>>>                   </soapenv:Header>
>>>                   <soapenv:Body>
>>>                       <request>?</request>
>>>                   </soapenv:Body>
>>>                </soapenv:Envelope>
>>>             </format>
>>>          </payloadFactory>
>>>
>>> option 2. In payloadFactory, check for structure of message. If it is a
>>> SOAP envelope, set as mc.setEnvelope(), else set as content of existing
>>> message's body.
>>>
>>> I prefer option#2 because, because no need to add 1 more attribute to
>>> payloadFactory config.
>>>
>>> WDYT?
>>>
>>> --
>>> Miyuru Wanninayaka
>>> Senior Software Engineer - WSO2 Inc <http://wso2.com/>.
>>
>>
>>
>
>
> --
>
> Sadeep Jayasumana
>
> **
>
> Email: gayansadeep@gmail.com****
>
> Mobile: +61 4 1468 8521
>
>


-- 
Miyuru Wanninayaka
Senior Software Engineer - WSO2 Inc <http://wso2.com/>.

Re: Payload factory mediator to support creating full SOAPEnvelope

Posted by Sadeep Jayasumana <ga...@gmail.com>.
Hi,

When Payload-factory mediator was initially developed, the main objective
was to provide an easy and intuitive way to create a new payload from a
well defined template. It turns out to be a very common use case, specially
when integrating data services. Although the same functionality can be
gained from Enrich mediator with somewhat less obvious configuration, we
thought adding a new mediator is justified given how common the use case is.

Using Payload-factory mediator with 'target' attribute to modify a part of
the envelop makes less sense to me, we might as well use Enrich mediator
for such cases.

Thanks,
Sadeep

On Wed, Jan 16, 2013 at 10:42 PM, Senaka Fernando <se...@gmail.com>wrote:

> Hi Miyuru,
>
> Just a question. can't we make the target an XPath expression? That way
> you can modify any part of the envelope AFAIU.
>
> WDYT?
>
> Thanks,
> Senaka.
>
>
> On Wed, Jan 16, 2013 at 2:49 PM, Miyuru Wanninayaka <mi...@gmail.com>wrote:
>
>> Hi all,
>>
>> Currently Payload factory mediator only supports generating content of
>> SOAP body and there is no way to create full SOAP message with SOAP headers
>> using payload factory mediator.
>>
>> How about implementing this?
>>
>> option 1. We can add a attribute to payload factory mediator to define
>> whether result need to set as SOAP enveloper / SOAP body
>>
>>          <payloadFactory target="envelope | body>
>>             <format>
>>                <soapenv:Envelope xmlns:soapenv="
>> http://www.w3.org/2003/05/soap-envelope">
>>                   <soapenv:Header>
>>                      <foo>
>>                         <bar>?</bar>
>>                      </foo>
>>                   </soapenv:Header>
>>                   <soapenv:Body>
>>                       <request>?</request>
>>                   </soapenv:Body>
>>                </soapenv:Envelope>
>>             </format>
>>          </payloadFactory>
>>
>> option 2. In payloadFactory, check for structure of message. If it is a
>> SOAP envelope, set as mc.setEnvelope(), else set as content of existing
>> message's body.
>>
>> I prefer option#2 because, because no need to add 1 more attribute to
>> payloadFactory config.
>>
>> WDYT?
>>
>> --
>> Miyuru Wanninayaka
>> Senior Software Engineer - WSO2 Inc <http://wso2.com/>.
>
>
>


-- 

Sadeep Jayasumana

**

Email: gayansadeep@gmail.com****

Mobile: +61 4 1468 8521

Re: Payload factory mediator to support creating full SOAPEnvelope

Posted by Senaka Fernando <se...@gmail.com>.
Hi Miyuru,

Just a question. can't we make the target an XPath expression? That way you
can modify any part of the envelope AFAIU.

WDYT?

Thanks,
Senaka.

On Wed, Jan 16, 2013 at 2:49 PM, Miyuru Wanninayaka <mi...@gmail.com>wrote:

> Hi all,
>
> Currently Payload factory mediator only supports generating content of
> SOAP body and there is no way to create full SOAP message with SOAP headers
> using payload factory mediator.
>
> How about implementing this?
>
> option 1. We can add a attribute to payload factory mediator to define
> whether result need to set as SOAP enveloper / SOAP body
>
>          <payloadFactory target="envelope | body>
>             <format>
>                <soapenv:Envelope xmlns:soapenv="
> http://www.w3.org/2003/05/soap-envelope">
>                   <soapenv:Header>
>                      <foo>
>                         <bar>?</bar>
>                      </foo>
>                   </soapenv:Header>
>                   <soapenv:Body>
>                       <request>?</request>
>                   </soapenv:Body>
>                </soapenv:Envelope>
>             </format>
>          </payloadFactory>
>
> option 2. In payloadFactory, check for structure of message. If it is a
> SOAP envelope, set as mc.setEnvelope(), else set as content of existing
> message's body.
>
> I prefer option#2 because, because no need to add 1 more attribute to
> payloadFactory config.
>
> WDYT?
>
> --
> Miyuru Wanninayaka
> Senior Software Engineer - WSO2 Inc <http://wso2.com/>.