You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Charles Souillard <Ch...@ext.bull.net> on 2006/03/24 09:30:51 UTC

ServiceMix API Client

Hi all,

I am trying to create a simple java client which sends an exchange to an 
installed component.
I am using SM embeded in a web app.
My problem is all examples I can find in the svn head are based on a 
spring xml file which defines the jbi container and at least one component.
This is not conforming to my case as my container is already started and 
my components were deployed using SU method.

I tried creating a client by doing :

ServiceMixClient client = new RemoteServiceMixClient();
or
ServiceMixClient = new DefaultServiceMixClient()

but I get a NPE :
java.lang.NullPointerException
at 
org.apache.servicemix.client.DefaultServiceMixClient.createInOutExchange(DefaultServiceMixClient.java:96)

This line is corresponding to
InOut exchange = getExchangeFactory().createInOutExchange();
It means getExchangeFactory() returned a null value.
I think this is due to the context value which is null in my case.
I know there is another way to create a client which is :
ServiceMixClient client = new ServiceMixClientFacade(ComponentContext);

but how can I get a ComponentContext ?

Thanks,
Charles


Re: ServiceMix API Client

Posted by Sandra Schweighart <Sa...@Innovations.de>.
Hi Charles

> but how can I get a ComponentContext ?

I don't use the servicemix classes but in my jbi-components I get the
ComponentContext as an argument of the init-method of my component. This
method gets invoked by the esb ... so you get the context from the esb.

Maybe it helps you...
Sandra

Re: ServiceMix API Client

Posted by Peter Klotz <pe...@blue-elephant-systems.com>.
Hi,

I have a similar problem, I have components that are not running inside the SM
container but in Avalon Phoenix already. Using a RemoteServiceMixClient seems to
be the easiest solution in order to avoid the JMS asynchronous problems.

You said, that one has to enable the JMS-flow, question how is this done really?
If I understood the RemoteServiceMixClient correctly one can participate in a SM
flow with components that do not run inside the SM/Spring/JBI container?
The RemoteServiceMixClientTest test case is not really remote because it
obviously runs inside the JBI container and has access to this, how to create
and use this component if I'm not inside the JBI container?


Thanks, Peter

Guillaume Nodet wrote:
> Use commons-httpclient (or any other client side http lib) to send an
> http request.
> 
> Guillaume Nodet
> 
> On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
>> Guillaume,
>>
>> In fact I want to use sm-http.
>> The problem is that the client.html given in soap-binding example only
>> works with IE I think...
>> So I was trying to do the same thing in java...
>>
>> Have you a bypass ?
>>
>> Thanks
>> Charles
>>
>> Guillaume Nodet wrote:
>>
>>> How to use the client api really depends on your location.  If you can
>>> access the jbi container, you should use the DefaultServiceMixClient.
>>> If you are inside a component, you can use the ServiceMixClientFacade.
>>> Else you have to use the remote client and enable the jms flow (you
>>> can now have both seda and jms flow).
>>> Note that activating the jms flow will cluster ServiceMix.
>>> If this is not what you want, well, use a binding component ;)
>>>
>>> Cheers,
>>> Guillaume Nodet
>>>
>>> On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
>>>
>>>
>>>> Hi all,
>>>>
>>>> I am trying to create a simple java client which sends an exchange to an
>>>> installed component.
>>>> I am using SM embeded in a web app.
>>>> My problem is all examples I can find in the svn head are based on a
>>>> spring xml file which defines the jbi container and at least one component.
>>>> This is not conforming to my case as my container is already started and
>>>> my components were deployed using SU method.
>>>>
>>>> I tried creating a client by doing :
>>>>
>>>> ServiceMixClient client = new RemoteServiceMixClient();
>>>> or
>>>> ServiceMixClient = new DefaultServiceMixClient()
>>>>
>>>> but I get a NPE :
>>>> java.lang.NullPointerException
>>>> at
>>>> org.apache.servicemix.client.DefaultServiceMixClient.createInOutExchange(DefaultServiceMixClient.java:96)
>>>>
>>>> This line is corresponding to
>>>> InOut exchange = getExchangeFactory().createInOutExchange();
>>>> It means getExchangeFactory() returned a null value.
>>>> I think this is due to the context value which is null in my case.
>>>> I know there is another way to create a client which is :
>>>> ServiceMixClient client = new ServiceMixClientFacade(ComponentContext);
>>>>
>>>> but how can I get a ComponentContext ?

Re: ServiceMix API Client

Posted by Guillaume Nodet <gn...@gmail.com>.
Use commons-httpclient (or any other client side http lib) to send an
http request.

Guillaume Nodet

On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
> Guillaume,
>
> In fact I want to use sm-http.
> The problem is that the client.html given in soap-binding example only
> works with IE I think...
> So I was trying to do the same thing in java...
>
> Have you a bypass ?
>
> Thanks
> Charles
>
> Guillaume Nodet wrote:
>
> >How to use the client api really depends on your location.  If you can
> >access the jbi container, you should use the DefaultServiceMixClient.
> >If you are inside a component, you can use the ServiceMixClientFacade.
> > Else you have to use the remote client and enable the jms flow (you
> >can now have both seda and jms flow).
> >Note that activating the jms flow will cluster ServiceMix.
> >If this is not what you want, well, use a binding component ;)
> >
> >Cheers,
> >Guillaume Nodet
> >
> >On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
> >
> >
> >>Hi all,
> >>
> >>I am trying to create a simple java client which sends an exchange to an
> >>installed component.
> >>I am using SM embeded in a web app.
> >>My problem is all examples I can find in the svn head are based on a
> >>spring xml file which defines the jbi container and at least one component.
> >>This is not conforming to my case as my container is already started and
> >>my components were deployed using SU method.
> >>
> >>I tried creating a client by doing :
> >>
> >>ServiceMixClient client = new RemoteServiceMixClient();
> >>or
> >>ServiceMixClient = new DefaultServiceMixClient()
> >>
> >>but I get a NPE :
> >>java.lang.NullPointerException
> >>at
> >>org.apache.servicemix.client.DefaultServiceMixClient.createInOutExchange(DefaultServiceMixClient.java:96)
> >>
> >>This line is corresponding to
> >>InOut exchange = getExchangeFactory().createInOutExchange();
> >>It means getExchangeFactory() returned a null value.
> >>I think this is due to the context value which is null in my case.
> >>I know there is another way to create a client which is :
> >>ServiceMixClient client = new ServiceMixClientFacade(ComponentContext);
> >>
> >>but how can I get a ComponentContext ?
> >>
> >>Thanks,
> >>Charles
> >>
> >>
> >>
> >>
> >
> >
> >
>

Re: ServiceMix API Client

Posted by Charles Souillard <Ch...@ext.bull.net>.
Guillaume,

In fact I want to use sm-http.
The problem is that the client.html given in soap-binding example only 
works with IE I think...
So I was trying to do the same thing in java...

Have you a bypass ?

Thanks
Charles

Guillaume Nodet wrote:

>How to use the client api really depends on your location.  If you can
>access the jbi container, you should use the DefaultServiceMixClient. 
>If you are inside a component, you can use the ServiceMixClientFacade.
> Else you have to use the remote client and enable the jms flow (you
>can now have both seda and jms flow).
>Note that activating the jms flow will cluster ServiceMix.
>If this is not what you want, well, use a binding component ;)
>
>Cheers,
>Guillaume Nodet
>
>On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
>  
>
>>Hi all,
>>
>>I am trying to create a simple java client which sends an exchange to an
>>installed component.
>>I am using SM embeded in a web app.
>>My problem is all examples I can find in the svn head are based on a
>>spring xml file which defines the jbi container and at least one component.
>>This is not conforming to my case as my container is already started and
>>my components were deployed using SU method.
>>
>>I tried creating a client by doing :
>>
>>ServiceMixClient client = new RemoteServiceMixClient();
>>or
>>ServiceMixClient = new DefaultServiceMixClient()
>>
>>but I get a NPE :
>>java.lang.NullPointerException
>>at
>>org.apache.servicemix.client.DefaultServiceMixClient.createInOutExchange(DefaultServiceMixClient.java:96)
>>
>>This line is corresponding to
>>InOut exchange = getExchangeFactory().createInOutExchange();
>>It means getExchangeFactory() returned a null value.
>>I think this is due to the context value which is null in my case.
>>I know there is another way to create a client which is :
>>ServiceMixClient client = new ServiceMixClientFacade(ComponentContext);
>>
>>but how can I get a ComponentContext ?
>>
>>Thanks,
>>Charles
>>
>>
>>    
>>
>
>  
>

Re: ServiceMix API Client

Posted by Guillaume Nodet <gn...@gmail.com>.
How to use the client api really depends on your location.  If you can
access the jbi container, you should use the DefaultServiceMixClient. 
If you are inside a component, you can use the ServiceMixClientFacade.
 Else you have to use the remote client and enable the jms flow (you
can now have both seda and jms flow).
Note that activating the jms flow will cluster ServiceMix.
If this is not what you want, well, use a binding component ;)

Cheers,
Guillaume Nodet

On 3/24/06, Charles Souillard <Ch...@ext.bull.net> wrote:
> Hi all,
>
> I am trying to create a simple java client which sends an exchange to an
> installed component.
> I am using SM embeded in a web app.
> My problem is all examples I can find in the svn head are based on a
> spring xml file which defines the jbi container and at least one component.
> This is not conforming to my case as my container is already started and
> my components were deployed using SU method.
>
> I tried creating a client by doing :
>
> ServiceMixClient client = new RemoteServiceMixClient();
> or
> ServiceMixClient = new DefaultServiceMixClient()
>
> but I get a NPE :
> java.lang.NullPointerException
> at
> org.apache.servicemix.client.DefaultServiceMixClient.createInOutExchange(DefaultServiceMixClient.java:96)
>
> This line is corresponding to
> InOut exchange = getExchangeFactory().createInOutExchange();
> It means getExchangeFactory() returned a null value.
> I think this is due to the context value which is null in my case.
> I know there is another way to create a client which is :
> ServiceMixClient client = new ServiceMixClientFacade(ComponentContext);
>
> but how can I get a ComponentContext ?
>
> Thanks,
> Charles
>
>