Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Service Component Architecture (SCA) Tools » consuming a web service
consuming a web service [message #577798] Thu, 26 August 2010 12:03 Go to next message
nouramin  is currently offline nouramin Friend
Messages: 13
Registered: August 2010
Junior Member
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 #577809 is a reply to message #577798] Thu, 26 August 2010 14:43 Go to previous message
Stephane Drapeau is currently offline Stephane DrapeauFriend
Messages: 199
Registered: July 2009
Senior Member
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 :)))
>
Previous Topic:SCA Testing plug-in
Next Topic:Calling a remote SCA Component
Goto Forum:
  


Current Time: Wed Oct 09 06:05:48 GMT 2024

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

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

Back to the top