You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Garry <gm...@hotmail.com> on 2007/11/09 21:31:42 UTC
How to call ws endpoint from LoanBroker
Hi,
I'm learning ServiceMix and JBI and would like to modify the ESB LoanBroker
example to call
one of the web services configured in the cxf-wsdl-first example. I've
looked around but
can't find an explanation of how to reference the web-service endpoint. Can
someone point
me in the right direction?
Thanks, Garry
--
View this message in context: http://www.nabble.com/How-to-call-ws-endpoint-from-LoanBroker-tf4779904s12049.html#a13674570
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: How to call ws endpoint from LoanBroker
Posted by Freeman Fang <fr...@gmail.com>.
Hi Garry,
Let's me explain how the client proxy configuration per as blow works
<cxfse:endpoint>
<cxfse:pojo>
<bean
class="org.apache.servicemix.cxfse.GreeterImplForClientProxy"
autowire="false">
<property name="calculator">
<cxfse:proxy service="calculator:CalculatorService"
context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
</property>
</bean>
</cxfse:pojo>
</cxfse:endpoint>
this snippet shows that a pojo GreeterImplForClientProxy has a property
calculator (as type org.apache.cxf.calculator.CalculatorPortType) ,
which is a client proxy of another cxf endpoint (I believe here "client
proxy of another cxf endpoint" == "CXF endpoint reference" in your
mail), so you can invoke another cxf endpoint from pojo
GreeterImplForClientProxy.
[1] is the code for GreeterImplForClientProxy. Also, in this class you
can see servicemix ComponentContext is also injected in, so that you can
get ServicemixClient by means of
ServiceMixClient client = new ServiceMixClientFacade(this.context);
Other comment inline
Best Regards
Freeman
[1]
http://svn.apache.org/repos/asf/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java
Garry wrote:
> Hi Freeman,
>
> My CXF service is configured as below, which looks
> about like what you show in your message:
>
> <beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0">
>
> <cxfse:endpoint>
> <cxfse:pojo>
> <bean
> class="org.apache.servicemix.samples.cxf_wsdl_first.PersonImpl" />
> </cxfse:pojo>
> </cxfse:endpoint>
>
> </beans>
>
>
Yeah, you can configure this pojo's client proxy(reference) in another
cxf endpoint as I show you how
> My CXF service deploys just fine and for testing
> purposes, I can invoke it via simple JavaScript. Of
> course, what I'm really trying to do is invoke my CXF
> service from a POJO deployed to the lightweight container
> (servicemix-lwcontainer). From the code snippet you kindly
> sent me (CxfSeClientProxyTest.java), I gather I should do
> something like this inside my POJO:
>
> client = new DefaultServiceMixClient(container);
> io = client.createInOutExchange();
> io.setService(new QName("http://apache.org/hello_world_soap_http",
> "SOAPService"));
> io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http",
> "Greeter"));
> io.setOperation(new QName("http://apache.org/hello_world_soap_http",
> "greetMe"));
>
> Have I got it right? If so, a couple more questions:
>
I don't think you need write these code your self, since client proxy
injection per the configuration already do it for you
> My POJO looks like this:
>
> public class LoanBroker extends ComponentSupport implements
> MessageExchangeListener
>
> and I'm having a hard time figuring out how to create
> a ServiceMixClient. I can't seem to get a JBI container
> reference and so the technique in your example won't work.
> Obviously, I'm still learning the API; how can I create a
> ServiceMixClient from a POJO extending ComponentSupport?
>
> While I intend to explore the ServiceMixClient approach,
> I'm wondering if I can't simply configure a CXF endpoint
> declaratively in my lightweight container configuration file
> (servicemix.xml) and inject it into my POJO. Is the
> "programmatic" ServiceMixClient approach the only way to
> go or can I configure a CXF endpoint reference? (Got an
> example for that?)
>
>
Since we support inject context into pojo as I show, you can create a
ServicemixClient from the context if you really want. But from the code
shows in GreeterImplForClientProxy, you can see it's very easy to invoke
another endpoint inside pojo without ServicemixClient.
> Thanks again, Garry
>
>
>
>
> Freeman Fang wrote:
>
>> Hi Garry,
>>
>> If you want to reference cxf web-service inside jbi container, you can
>> see how client proxy is used inside cxf-se.
>> the configuration is per as below
>>
>> <cxfse:endpoint>
>> <cxfse:pojo>
>> <bean
>> class="org.apache.servicemix.cxfse.GreeterImplForClientProxy"
>> autowire="false">
>> <property name="calculator">
>> <cxfse:proxy service="calculator:CalculatorService"
>> context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
>> </property>
>> </bean>
>> </cxfse:pojo>
>> </cxfse:endpoint>
>>
>> And [1] is a test to illustrate how client proxy is used
>> [1]
>> http://svn.apache.org/repos/asf/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
>>
>> Best Regards
>>
>> Freeman
>>
>> Garry wrote:
>>
>>> Hi,
>>>
>>> I'm learning ServiceMix and JBI and would like to modify the ESB
>>> LoanBroker
>>> example to call
>>> one of the web services configured in the cxf-wsdl-first example. I've
>>> looked around but
>>> can't find an explanation of how to reference the web-service endpoint.
>>> Can
>>> someone point
>>> me in the right direction?
>>>
>>> Thanks, Garry
>>>
>>>
>>
>
>
Re: How to call ws endpoint from LoanBroker
Posted by Garry <gm...@hotmail.com>.
Hi Freeman,
My CXF service is configured as below, which looks
about like what you show in your message:
<beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0">
<cxfse:endpoint>
<cxfse:pojo>
<bean
class="org.apache.servicemix.samples.cxf_wsdl_first.PersonImpl" />
</cxfse:pojo>
</cxfse:endpoint>
</beans>
My CXF service deploys just fine and for testing
purposes, I can invoke it via simple JavaScript. Of
course, what I'm really trying to do is invoke my CXF
service from a POJO deployed to the lightweight container
(servicemix-lwcontainer). From the code snippet you kindly
sent me (CxfSeClientProxyTest.java), I gather I should do
something like this inside my POJO:
client = new DefaultServiceMixClient(container);
io = client.createInOutExchange();
io.setService(new QName("http://apache.org/hello_world_soap_http",
"SOAPService"));
io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http",
"Greeter"));
io.setOperation(new QName("http://apache.org/hello_world_soap_http",
"greetMe"));
Have I got it right? If so, a couple more questions:
My POJO looks like this:
public class LoanBroker extends ComponentSupport implements
MessageExchangeListener
and I'm having a hard time figuring out how to create
a ServiceMixClient. I can't seem to get a JBI container
reference and so the technique in your example won't work.
Obviously, I'm still learning the API; how can I create a
ServiceMixClient from a POJO extending ComponentSupport?
While I intend to explore the ServiceMixClient approach,
I'm wondering if I can't simply configure a CXF endpoint
declaratively in my lightweight container configuration file
(servicemix.xml) and inject it into my POJO. Is the
"programmatic" ServiceMixClient approach the only way to
go or can I configure a CXF endpoint reference? (Got an
example for that?)
Thanks again, Garry
Freeman Fang wrote:
>
> Hi Garry,
>
> If you want to reference cxf web-service inside jbi container, you can
> see how client proxy is used inside cxf-se.
> the configuration is per as below
>
> <cxfse:endpoint>
> <cxfse:pojo>
> <bean
> class="org.apache.servicemix.cxfse.GreeterImplForClientProxy"
> autowire="false">
> <property name="calculator">
> <cxfse:proxy service="calculator:CalculatorService"
> context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
> </property>
> </bean>
> </cxfse:pojo>
> </cxfse:endpoint>
>
> And [1] is a test to illustrate how client proxy is used
> [1]
> http://svn.apache.org/repos/asf/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
>
> Best Regards
>
> Freeman
>
> Garry wrote:
>> Hi,
>>
>> I'm learning ServiceMix and JBI and would like to modify the ESB
>> LoanBroker
>> example to call
>> one of the web services configured in the cxf-wsdl-first example. I've
>> looked around but
>> can't find an explanation of how to reference the web-service endpoint.
>> Can
>> someone point
>> me in the right direction?
>>
>> Thanks, Garry
>>
>
>
--
View this message in context: http://www.nabble.com/How-to-call-ws-endpoint-from-LoanBroker-tf4779904s12049.html#a13706794
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: How to call ws endpoint from LoanBroker
Posted by Freeman Fang <fr...@gmail.com>.
Hi Garry,
If you want to reference cxf web-service inside jbi container, you can
see how client proxy is used inside cxf-se.
the configuration is per as below
<cxfse:endpoint>
<cxfse:pojo>
<bean
class="org.apache.servicemix.cxfse.GreeterImplForClientProxy"
autowire="false">
<property name="calculator">
<cxfse:proxy service="calculator:CalculatorService"
context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
</property>
</bean>
</cxfse:pojo>
</cxfse:endpoint>
And [1] is a test to illustrate how client proxy is used
[1]
http://svn.apache.org/repos/asf/incubator/servicemix/trunk/deployables/serviceengines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
Best Regards
Freeman
Garry wrote:
> Hi,
>
> I'm learning ServiceMix and JBI and would like to modify the ESB LoanBroker
> example to call
> one of the web services configured in the cxf-wsdl-first example. I've
> looked around but
> can't find an explanation of how to reference the web-service endpoint. Can
> someone point
> me in the right direction?
>
> Thanks, Garry
>