Skip to main content



      Home
Home » Archived » Service Component Architecture (SCA) Tools » consuming a web service
consuming a web service [message #555351] Thu, 26 August 2010 08:03 Go to next message
Eclipse UserFriend
Hi

I have a sca component exposed as a webservice

I want to know how can I use this web service
details:

my calculator.composite:
****************************

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:sample="http://sample" name="Calculator" targetNamespace="http://sample">
<service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService">
<interface.java interface="calculator.CalculatorService"/>
<binding.ws uri="http://localhost:8181/CalculatorService"/>
</service>


<component name="CalculatorServiceComponent">

<implementation.java class="calculator.CalculatorServiceImpl"/>
<reference name="addService" target="AddServiceComponent"/>
<reference name="subtractService" target="SubtractServiceComponent"/>
<reference name="multiplyService" target="MultiplyServiceComponent"/>
<reference name="divideService" target="DivideServiceComponent"/>
</component>
<component name="AddServiceComponent">
<implementation.java class="calculator.AddServiceImpl"/>
</component>
<component name="SubtractServiceComponent">
<implementation.java class="calculator.SubtractServiceImpl"/>
</component>
<component name="MultiplyServiceComponent">
<implementation.java class="calculator.MultiplyServiceImpl"/>
</component>
<component name="DivideServiceComponent">
<implementation.java class="calculator.DivideServiceImpl"/>
</component>
</composite>
***********************************



My CalculatorClient.java:
*********************

public class CalculatorClient {
public static void main(String[] args) throws Exception {

SCADomain scaDomain = SCADomain.newInstance("Calculator.composite");
CalculatorService calculatorService = ???????????;

// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));

scaDomain.close();

**********************

I don't know how to remplace the ????Smile)

I need your help Smile))
Re: consuming a web service [message #555430 is a reply to message #555351] Thu, 26 August 2010 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

CalculatorService calculatorService =
scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent");

Have a look at [0] ;-)

Stephane Drapeau
Obeo

[0]:
https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/ samples/calculator-webapp/src/main/java/calculator/Calculato rClient.java



nouramin a écrit :
> Hi
> I have a sca component exposed as a webservice
> I want to know how can I use this web service
> details:
>
> my calculator.composite:
> ****************************
>
> <?xml version="1.0" encoding="UTF-8"?>
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
> xmlns:sample="http://sample" name="Calculator"
> targetNamespace="http://sample">
> <service name="CalculatorService"
> promote="CalculatorServiceComponent/CalculatorService">
> <interface.java interface="calculator.CalculatorService"/>
> <binding.ws uri="http://localhost:8181/CalculatorService"/>
> </service> <component name="CalculatorServiceComponent">
>
> <implementation.java class="calculator.CalculatorServiceImpl"/>
> <reference name="addService" target="AddServiceComponent"/>
> <reference name="subtractService" target="SubtractServiceComponent"/>
> <reference name="multiplyService" target="MultiplyServiceComponent"/>
> <reference name="divideService" target="DivideServiceComponent"/>
> </component>
> <component name="AddServiceComponent">
> <implementation.java class="calculator.AddServiceImpl"/>
> </component>
> <component name="SubtractServiceComponent">
> <implementation.java class="calculator.SubtractServiceImpl"/>
> </component>
> <component name="MultiplyServiceComponent">
> <implementation.java class="calculator.MultiplyServiceImpl"/>
> </component>
> <component name="DivideServiceComponent">
> <implementation.java class="calculator.DivideServiceImpl"/>
> </component>
> </composite>
> ***********************************
>
>
>
> My CalculatorClient.java:
> *********************
>
> public class CalculatorClient {
> public static void main(String[] args) throws Exception {
>
> SCADomain scaDomain = SCADomain.newInstance("Calculator.composite");
> CalculatorService calculatorService = ???????????;
> // Calculate
> System.out.println("3 + 2=" + calculatorService.add(3, 2));
> System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
> System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
> System.out.println("3 / 2=" + calculatorService.divide(3, 2));
>
> scaDomain.close();
>
> **********************
>
> I don't know how to remplace the ????:))
>
> I need your help :)))
>
Re: consuming a web service [message #555913 is a reply to message #555430] Mon, 30 August 2010 04:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
thanks Stephane but I mean I want to invoke the web service from an other server.
I think this work only from the same host doesn't it??
Re: consuming a web service [message #555959 is a reply to message #555913] Mon, 30 August 2010 07:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Le 30/08/2010 10:23, nouramin a écrit :
> Hi,
> thanks Stephane but I mean I want to invoke the web service from an
> other server.
> I think this work only from the same host doesn't it??

I think so, even if it might depend on the SCA runtime.
I'm not sure, but maybe Tuscany supports distributed SCA domains. You
should ask them.

Otherwise, you will have to invoke the SCA application as a service,
using the associated bindings. As an example, invoking a SCA application
exposed as a web service, can be done by creating a WS client.

Vincent.
Re: consuming a web service [message #558601 is a reply to message #555959] Mon, 13 September 2010 11:58 Go to previous messageGo to next message
Eclipse UserFriend
Hello,
Vincent my problem is how to create a ws client for a remote SCA application exposed as a web service .
If you have an idea please help me.
Re: consuming a web service [message #559003 is a reply to message #558601] Wed, 15 September 2010 05:40 Go to previous message
Eclipse UserFriend
Hi,

Le 13/09/2010 17:58, nouramin a écrit :
> Hello,
> Vincent my problem is how to create a ws client for a remote SCA
> application exposed as a web service .
> If you have an idea please help me.

The fact that your WS is implemented as a SCA application does not
matter. You only need a WSDL.

If you have not explicitely defined a WSDL, with a WSDL interface, then
you will have to deploy your application and let your runtime generate
it (provided you added a WS binding on your SCA service).

Then, you can use Apache CXF [0], Axis2 [1] or WsImport [3] to create a
Java client for your WS. The last one is probably the easiest one if you
have a JDK 6.

Regards,

Vincent.


[ 0 ] : http://www.opendocs.net/apache/cxf/2.0/developing-a-consumer .html
[ 1 ] :
http://wiki.service-now.com/index.php?title=Java_Apache_Axis 2_Web_Services_Client_Examples
[ 2 ] :
http://laurii.info/articles/2010/05/14/web-services-create-a -client-with-wsimport
Re: consuming a web service [message #577819 is a reply to message #555430] Mon, 30 August 2010 04:23 Go to previous message
Eclipse UserFriend
Hi,
thanks Stephane but I mean I want to invoke the web service from an other server.
I think this work only from the same host doesn't it??
Re: consuming a web service [message #577854 is a reply to message #577819] Mon, 30 August 2010 07:40 Go to previous message
Eclipse UserFriend
Hi,

Le 30/08/2010 10:23, nouramin a écrit :
> Hi,
> thanks Stephane but I mean I want to invoke the web service from an
> other server.
> I think this work only from the same host doesn't it??

I think so, even if it might depend on the SCA runtime.
I'm not sure, but maybe Tuscany supports distributed SCA domains. You
should ask them.

Otherwise, you will have to invoke the SCA application as a service,
using the associated bindings. As an example, invoking a SCA application
exposed as a web service, can be done by creating a WS client.

Vincent.
Re: consuming a web service [message #577898 is a reply to message #555959] Mon, 13 September 2010 11:58 Go to previous message
Eclipse UserFriend
Hello,
Vincent my problem is how to create a ws client for a remote SCA application exposed as a web service .
If you have an idea please help me.
Re: consuming a web service [message #577960 is a reply to message #577898] Wed, 15 September 2010 05:40 Go to previous message
Eclipse UserFriend
Hi,

Le 13/09/2010 17:58, nouramin a écrit :
> Hello,
> Vincent my problem is how to create a ws client for a remote SCA
> application exposed as a web service .
> If you have an idea please help me.

The fact that your WS is implemented as a SCA application does not
matter. You only need a WSDL.

If you have not explicitely defined a WSDL, with a WSDL interface, then
you will have to deploy your application and let your runtime generate
it (provided you added a WS binding on your SCA service).

Then, you can use Apache CXF [0], Axis2 [1] or WsImport [3] to create a
Java client for your WS. The last one is probably the easiest one if you
have a JDK 6.

Regards,

Vincent.


[ 0 ] : http://www.opendocs.net/apache/cxf/2.0/developing-a-consumer .html
[ 1 ] :
http://wiki.service-now.com/index.php?title=Java_Apache_Axis 2_Web_Services_Client_Examples
[ 2 ] :
http://laurii.info/articles/2010/05/14/web-services-create-a -client-with-wsimport
Previous Topic:EJB binding
Next Topic:SCADomain.newInstance stops after loading contribution
Goto Forum:
  


Current Time: Tue Apr 15 02:43:38 EDT 2025

Powered by FUDForum. Page generated in 0.27515 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top