You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Stefan Essl <es...@studi.informatik.uni-stuttgart.de> on 2011/10/03 17:55:05 UTC

Setting Message Properties in Custom HttpSoapConsumerMarshaler

Hi everybody,

I'm trying to modify the HttpSoapConsumerMarshaler to embed some of my SOAP headers of an incoming SOAP message as Message Properties into the Normalized Message dispatched to the NMR. However I just can't figure out how. I found out that the unmodified HttpSoapConsumerMarshaler embeds one property into the Normalized Message that is itself a map of properties originally associated with the SOAP message. But how can I set some of these as single Message Properties without the map in between?

Thanks,
Stefan

Re: Setting Message Properties in Custom HttpSoapConsumerMarshaler

Posted by Stefan Essl <es...@studi.informatik.uni-stuttgart.de>.
Lukasz, thanks a lot! Now I know where the errors in my approaches were and I finally got the property into the message. Thumbs up! :)

Thanks! :)
Stefan


Am 05.10.2011 um 11:31 schrieb Łukasz Dywicki:

> Initialized exchange contains message. In your case sendOut contains message sent from Http endpoint to browser or software client (to service caller). If you wish set message property sent from http endpoint to nmr you should use MessageExchange.getMessage("in") and set properties on it.
> 
> Regards,
> Lukasz
> 
>> Hi Lukasz,
>> 
>> thanks for the hint. I already did the first part (endpoint configuration) the way you described it, however the implementation is still the problem. I don't want to set properties of the exchange, I want to set properties of the normalized message that is dispatched via this marshaler. How can I achieve this?
>> 
>> I also tried the following which doesn't work either:
>> 
>> public class MyHttpSoapConsumerMarshaler extends HttpSoapConsumerMarshaler {
>> 	public void sendOut(MessageExchange ex, NormalizedMessage nMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
>> 		nMsg.setProperty("a", "b");
>> 		super.sendOut(ex, nMsg, request, response);
>> 	}
>> }
>> 
>> Thanks,
>> Stefan
>> 
>> 
>> Am 04.10.2011 um 20:06 schrieb Łukasz Dywicki:
>> 
>>> Hey Stefan,
>>> You don't have to modify HttpSoapConsumerMarshaler, you may extend this class and reffer it instance using endpoint configuration:
>>> <bean id="my-bean-id" class="org.example.soap.MyMarshaler" />
>>> 
>>> <http:consumer service="..." marshaler="#my-bean-id" /> 
>>> 
>>> Your instance will be responsible for creating new exchanges. Example implementation:
>>> 
>>> class MyMarshaler extends HttpSoapConsumerMashaler {
>>>  public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
>>>       MessageExchange ex = super.createExchange(request, context);
>>>       ex.setProperty("a", "b"); // that's magic
>>>       return ex;
>>>  }
>>> }
>>> 
>>> Best regards,
>>> Lukasz
>>> 
>>>> Hi everybody,
>>>> 
>>>> I'm trying to modify the HttpSoapConsumerMarshaler to embed some of my SOAP headers of an incoming SOAP message as Message Properties into the Normalized Message dispatched to the NMR. However I just can't figure out how. I found out that the unmodified HttpSoapConsumerMarshaler embeds one property into the Normalized Message that is itself a map of properties originally associated with the SOAP message. But how can I set some of these as single Message Properties without the map in between?
>>>> 
>>>> Thanks,
>>>> Stefan
>>> 
>> 
> 


Re: Setting Message Properties in Custom HttpSoapConsumerMarshaler

Posted by Łukasz Dywicki <lu...@code-house.org>.
Initialized exchange contains message. In your case sendOut contains message sent from Http endpoint to browser or software client (to service caller). If you wish set message property sent from http endpoint to nmr you should use MessageExchange.getMessage("in") and set properties on it.

Regards,
Lukasz

> Hi Lukasz,
> 
> thanks for the hint. I already did the first part (endpoint configuration) the way you described it, however the implementation is still the problem. I don't want to set properties of the exchange, I want to set properties of the normalized message that is dispatched via this marshaler. How can I achieve this?
> 
> I also tried the following which doesn't work either:
> 
> public class MyHttpSoapConsumerMarshaler extends HttpSoapConsumerMarshaler {
> 	public void sendOut(MessageExchange ex, NormalizedMessage nMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
> 		nMsg.setProperty("a", "b");
> 		super.sendOut(ex, nMsg, request, response);
> 	}
> }
> 
> Thanks,
> Stefan
> 
> 
> Am 04.10.2011 um 20:06 schrieb Łukasz Dywicki:
> 
>> Hey Stefan,
>> You don't have to modify HttpSoapConsumerMarshaler, you may extend this class and reffer it instance using endpoint configuration:
>> <bean id="my-bean-id" class="org.example.soap.MyMarshaler" />
>> 
>> <http:consumer service="..." marshaler="#my-bean-id" /> 
>> 
>> Your instance will be responsible for creating new exchanges. Example implementation:
>> 
>> class MyMarshaler extends HttpSoapConsumerMashaler {
>>   public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
>>        MessageExchange ex = super.createExchange(request, context);
>>        ex.setProperty("a", "b"); // that's magic
>>        return ex;
>>   }
>> }
>> 
>> Best regards,
>> Lukasz
>> 
>>> Hi everybody,
>>> 
>>> I'm trying to modify the HttpSoapConsumerMarshaler to embed some of my SOAP headers of an incoming SOAP message as Message Properties into the Normalized Message dispatched to the NMR. However I just can't figure out how. I found out that the unmodified HttpSoapConsumerMarshaler embeds one property into the Normalized Message that is itself a map of properties originally associated with the SOAP message. But how can I set some of these as single Message Properties without the map in between?
>>> 
>>> Thanks,
>>> Stefan
>> 
> 


Re: Setting Message Properties in Custom HttpSoapConsumerMarshaler

Posted by Stefan Essl <es...@studi.informatik.uni-stuttgart.de>.
Hi Lukasz,

thanks for the hint. I already did the first part (endpoint configuration) the way you described it, however the implementation is still the problem. I don't want to set properties of the exchange, I want to set properties of the normalized message that is dispatched via this marshaler. How can I achieve this?

I also tried the following which doesn't work either:

public class MyHttpSoapConsumerMarshaler extends HttpSoapConsumerMarshaler {
	public void sendOut(MessageExchange ex, NormalizedMessage nMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
		nMsg.setProperty("a", "b");
		super.sendOut(ex, nMsg, request, response);
	}
}

Thanks,
Stefan


Am 04.10.2011 um 20:06 schrieb Łukasz Dywicki:

> Hey Stefan,
> You don't have to modify HttpSoapConsumerMarshaler, you may extend this class and reffer it instance using endpoint configuration:
> <bean id="my-bean-id" class="org.example.soap.MyMarshaler" />
> 
> <http:consumer service="..." marshaler="#my-bean-id" /> 
> 
> Your instance will be responsible for creating new exchanges. Example implementation:
> 
> class MyMarshaler extends HttpSoapConsumerMashaler {
>    public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
>         MessageExchange ex = super.createExchange(request, context);
>         ex.setProperty("a", "b"); // that's magic
>         return ex;
>    }
> }
> 
> Best regards,
> Lukasz
> 
>> Hi everybody,
>> 
>> I'm trying to modify the HttpSoapConsumerMarshaler to embed some of my SOAP headers of an incoming SOAP message as Message Properties into the Normalized Message dispatched to the NMR. However I just can't figure out how. I found out that the unmodified HttpSoapConsumerMarshaler embeds one property into the Normalized Message that is itself a map of properties originally associated with the SOAP message. But how can I set some of these as single Message Properties without the map in between?
>> 
>> Thanks,
>> Stefan
> 


Re: Setting Message Properties in Custom HttpSoapConsumerMarshaler

Posted by Łukasz Dywicki <lu...@code-house.org>.
Hey Stefan,
You don't have to modify HttpSoapConsumerMarshaler, you may extend this class and reffer it instance using endpoint configuration:
<bean id="my-bean-id" class="org.example.soap.MyMarshaler" />

<http:consumer service="..." marshaler="#my-bean-id" /> 

Your instance will be responsible for creating new exchanges. Example implementation:

class MyMarshaler extends HttpSoapConsumerMashaler {
    public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
         MessageExchange ex = super.createExchange(request, context);
         ex.setProperty("a", "b"); // that's magic
         return ex;
    }
}

Best regards,
Lukasz

> Hi everybody,
> 
> I'm trying to modify the HttpSoapConsumerMarshaler to embed some of my SOAP headers of an incoming SOAP message as Message Properties into the Normalized Message dispatched to the NMR. However I just can't figure out how. I found out that the unmodified HttpSoapConsumerMarshaler embeds one property into the Normalized Message that is itself a map of properties originally associated with the SOAP message. But how can I set some of these as single Message Properties without the map in between?
> 
> Thanks,
> Stefan


Re: should service engines provide lot of logic

Posted by "Kripalani, Raul" <ra...@fusesource.com>.
A Service Engine is a component that acts solely inside the ESB domain. It
doesn't necessarily communicate with the external world (although it can if
you implement the custom logic ;)). It consumes messages from the NMR and
replies back to the NMR, whereas a Binding Component acts as a bridge with
the outer world, translating between a specific protocol and the NMR.

I would recommend using SEs to plug in additional middleware capabilities to
the ESB - i.e. BPEL (ode-jbi SE), transformation, validation, BPM,
scheduling, etc.

Regards,
Raúl.

2011/10/4 Łukasz Dywicki <lu...@code-house.org>

> In JBI spec service engines are places where logic should be implemented.
> Binding components are responsible only for protocol adoption (eg from http
> to nmr, from nmr to ftp). All other operations, including transformations,
> complex routing and message formation should be implemented as service
> engines.
>
> Pozdrawiam,
> Łukasz
>
> > Hi
> >
> >
> > I have a question regarding Service Engines role in integration process.
> > Should they just transform the message and do a simple operation or they
> may be responsible for the huge logical functionalities?
> >
> >
> >
> > regards
> >
> >
> > rafal
> >
> > --
> > <minism.gif>
> >
> > Rafał Janik
> > Software Engineer
> > Software Mind SA
> > ul. Bociana 22A
> > 31-231 Krakow
> > Polska
> >
> > Tel. +48 12 252 34 00
> > Fax: +48 12 252 34 01
> > Mobile:+48 668 48 36 13
> > rafal.janik@softwaremind.pl
> > www.softwaremind.pl
> >
> > Software Mind SA z siedzibą w Krakowie przy ul. Bociana 22A, 31-231
> Krakow
> > NIP 9452012822, kapitał zakładowy PLN 500,000.00 (w całości wpłacony),
> KRS 0000300409
> > Sąd Rejonowy dla Krakowa Śródmieścia w Krakowie, XI Wydział Gospodarczy
> KRS
> >
> > Ta wiadomość może zawierać materiały poufne i objęte tajemnicą zawodową,
> do wyłącznego użytku odbiorcy (odbiorców). Surowo wzbronione są wszelkie
> zmiany, wykorzystywanie, przechowywanie, dystrybucja lub ujawnienie przez
> inne osoby. Jeśli nie jest Pan/Pani zamierzonym odbiorcą (lub osobą
> upoważnioną do odbioru w imieniu odbiorcy), prosimy o kontakt z nadawcą
> przez wiadomość zwrotną oraz usunięcie wszelkich kopii niniejszej
> wiadomości. Poza tym poczta elektroniczna jest podatna na uszkodzenia
> danych, przechwytywanie, sabotaż, nieupoważnione zmiany i wirusy. Wysyłamy i
> odbieramy wiadomości poczty elektronicznej wyłącznie na takiej zasadzie, że
> nie ponosimy odpowiedzialności za jakiekolwiek tego typu uszkodzenia,
> przechwycenia, sabotaż, zmiany lub wirusy, ani jakichkolwiek konsekwencje
> tego typu okoliczności.
>
>

Re: should service engines provide lot of logic

Posted by "Kripalani, Raul" <ra...@fusesource.com>.
Hi Rafal,

That depends on the rules and patterns that are followed in your
organisation. It's the architect's decision. Typically, the ESB is used as
an integration engine connecting different systems together, where the
systems are responsible for implementing and encapsulating business logic as
services which are then exposed within the ESB.

That design allows for a cleaner separation of roles and governance overall.
It is also aligned with SOA Principles. I'd say that is the industry "best
practice", but should not be a rule of thumb because the scenario in your
organisation may perfectly justify a different architectural blueprint.

You can always encapsulate custom business logic within beans in the ESB,
but I recommend you take your decision holistically, considering
organisational structure, risks, technical factors, ownership, roadmap,
maintenance, etc.

Hope this helps.

Regards,
Raúl.

2011/10/5 Rafal Janik <ra...@softwaremind.pl>

> Hi
> thanks for the reply.
> I understand the differences between BC and SE.
> My question was just about "best-practises" in SMX - about including logic
> which is not an integration stuff: if it's a true we should try to avoid put
> into SE such logic?
>
> rafal
>
>
>
> W dniu 04.10.2011 20:09, Łukasz Dywicki pisze:
>
>  In JBI spec service engines are places where logic should be implemented.
>> Binding components are responsible only for protocol adoption (eg from http
>> to nmr, from nmr to ftp). All other operations, including transformations,
>> complex routing and message formation should be implemented as service
>> engines.
>>
>> Pozdrawiam,
>> Łukasz
>>
>>
>>
>>> Hi
>>>
>>>
>>> I have a question regarding Service Engines role in integration process.
>>> Should they just transform the message and do a simple operation or they
>>> may be responsible for the huge logical functionalities?
>>>
>>>
>>>
>>> regards
>>>
>>>
>>>
>>>
>>
>

Re: should service engines provide lot of logic

Posted by Rafal Janik <ra...@softwaremind.pl>.
Hi
thanks for the reply.
I understand the differences between BC and SE.
My question was just about "best-practises" in SMX - about including 
logic which is not an integration stuff: if it's a true we should try to 
avoid put into SE such logic?

rafal



W dniu 04.10.2011 20:09, Łukasz Dywicki pisze:
> In JBI spec service engines are places where logic should be implemented. Binding components are responsible only for protocol adoption (eg from http to nmr, from nmr to ftp). All other operations, including transformations, complex routing and message formation should be implemented as service engines.
>
> Pozdrawiam,
> Łukasz
>
>    
>> Hi
>>
>>
>> I have a question regarding Service Engines role in integration process.
>> Should they just transform the message and do a simple operation or they may be responsible for the huge logical functionalities?
>>
>>
>>
>> regards
>>
>>
>>      


Re: should service engines provide lot of logic

Posted by Łukasz Dywicki <lu...@code-house.org>.
In JBI spec service engines are places where logic should be implemented. Binding components are responsible only for protocol adoption (eg from http to nmr, from nmr to ftp). All other operations, including transformations, complex routing and message formation should be implemented as service engines.

Pozdrawiam,
Łukasz

> Hi 
> 
> 
> I have a question regarding Service Engines role in integration process.
> Should they just transform the message and do a simple operation or they may be responsible for the huge logical functionalities? 
> 
> 
> 
> regards
> 
> 
> rafal  
> 
> -- 
> <minism.gif>	
> 
> Rafał Janik
> Software Engineer
> Software Mind SA
> ul. Bociana 22A
> 31-231 Krakow
> Polska
> 
> Tel. +48 12 252 34 00
> Fax: +48 12 252 34 01
> Mobile:+48 668 48 36 13
> rafal.janik@softwaremind.pl
> www.softwaremind.pl
> 
> Software Mind SA z siedzibą w Krakowie przy ul. Bociana 22A, 31-231 Krakow
> NIP 9452012822, kapitał zakładowy PLN 500,000.00 (w całości wpłacony), KRS 0000300409
> Sąd Rejonowy dla Krakowa Śródmieścia w Krakowie, XI Wydział Gospodarczy KRS
>  
> Ta wiadomość może zawierać materiały poufne i objęte tajemnicą zawodową, do wyłącznego użytku odbiorcy (odbiorców). Surowo wzbronione są wszelkie zmiany, wykorzystywanie, przechowywanie, dystrybucja lub ujawnienie przez inne osoby. Jeśli nie jest Pan/Pani zamierzonym odbiorcą (lub osobą upoważnioną do odbioru w imieniu odbiorcy), prosimy o kontakt z nadawcą przez wiadomość zwrotną oraz usunięcie wszelkich kopii niniejszej wiadomości. Poza tym poczta elektroniczna jest podatna na uszkodzenia danych, przechwytywanie, sabotaż, nieupoważnione zmiany i wirusy. Wysyłamy i odbieramy wiadomości poczty elektronicznej wyłącznie na takiej zasadzie, że nie ponosimy odpowiedzialności za jakiekolwiek tego typu uszkodzenia, przechwycenia, sabotaż, zmiany lub wirusy, ani jakichkolwiek konsekwencje tego typu okoliczności.


should service engines provide lot of logic

Posted by Rafal Janik <ra...@softwaremind.pl>.
Hi


I have a question regarding Service Engines role in integration process.
Should they just transform the message and do a simple operation or they 
may be responsible for the huge logical functionalities?



regards


rafal

-- 
Software Mind 	

*Rafa? Janik*
Software Engineer
*Software Mind SA*
ul. Bociana 22A
31-231 Krakow
Polska

	Tel. +48 12 252 34 00
Fax: +48 12 252 34 01
Mobile:+48 668 48 36 13
rafal.janik@softwaremind.pl <ma...@softwaremind.pl>
www.softwaremind.pl <http://www.softwaremind.pl>

Software Mind SA z siedziba; w Krakowie przy ul. Bociana 22A, 31-231 Krakow
NIP 9452012822, kapita? zak?adowy PLN 500,000.00 (w ca?os'ci wp?acony), 
KRS 0000300409
Sa;d Rejonowy dla Krakowa S'ródmies'cia w Krakowie, XI Wydzia? 
Gospodarczy KRS
Ta wiadomos'c' moz.e zawierac' materia?y poufne i obje;te tajemnica; 
zawodowa;, do wy?a;cznego uz.ytku odbiorcy (odbiorców). Surowo 
wzbronione sa; wszelkie zmiany, wykorzystywanie, przechowywanie, 
dystrybucja lub ujawnienie przez inne osoby. Jes'li nie jest Pan/Pani 
zamierzonym odbiorca; (lub osoba; upowaz.niona; do odbioru w imieniu 
odbiorcy), prosimy o kontakt z nadawca; przez wiadomos'c' zwrotna; oraz 
usunie;cie wszelkich kopii niniejszej wiadomos'ci. Poza tym poczta 
elektroniczna jest podatna na uszkodzenia danych, przechwytywanie, 
sabotaz., nieupowaz.nione zmiany i wirusy. Wysy?amy i odbieramy 
wiadomos'ci poczty elektronicznej wy?a;cznie na takiej zasadzie, z.e nie 
ponosimy odpowiedzialnos'ci za jakiekolwiek tego typu uszkodzenia, 
przechwycenia, sabotaz., zmiany lub wirusy, ani jakichkolwiek 
konsekwencje tego typu okolicznos'ci.