You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Albert Rainer <al...@ec3.at> on 2008/03/21 13:53:39 UTC

WS outside of control

I'm giving a lecture in "Web Service Composition" at the Vienna University of Technology and I want to use tuscany as an advances technique for system configuration. But first of all I've to understand the technology befor annoying my students. I've gone through the examples but didn't find any solution for my problem.
: 
I have a composite that defines a component and binds it to a Web Service outside of my control, somewhere on the Web.
The service is axis2 and generated from a Java class. 
package at.move;
public class MathService {
	public double addiere(double a,double b){
		return a+b;
	}
	public int aufrunden(double a){
		return (int)Math.ceil(a);
	}
}
The Calculaor.composite looks like that:
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
           targetNamespace="http://sample"
           xmlns:sample="http://sample"
           name="Calculator">           

    <component name="CalculatorServiceComponent">
		<implementation.java class="calculator.CalculatorServiceImpl"/>       
		<reference name="addService">         
            <binding.ws uri="http://localhost:8080/zong/services/MathService" />        
        </reference>
        <reference name="subtractService" target="SubtractServiceComponent"></reference>
        <reference name="multiplyService" target="MultiplyServiceComponent"></reference>
        <reference name="divideService" target="DivideServiceComponent"></reference>
    </component>

    <component name="SubtractServiceComponent">
        <implementation.java class="calculator.SubtractServiceImpl"/>
    </component>
    ...    
</composite>

The idea is: For the addService and method add() I want to use the The Web Service with the method: addiere()
 I need to map the AddService to the MathService and the add method from the Calculator to the addiere method from MathService 
 @Reference
    public void setAddService(AddService addService) {
        this.addService = addService;
    }
   public double add(double n1, double n2) {
        return addService.add(n1, n2);
    }

What steps are required in order to achieve such a mapping? Or is this not in the intetntion of tuscany and it is not possible?

Many thanks in advance.

 
----------------------------------------------------------------
Dr. Albert Rainer
EC3 - Electronic Commerce Competence Center
www.ec3.at
Donau-City Strasse 1
A-1220 Wien
Tel: +43 1 522 71 71 - 33
Fax: +43 1 522 71 71 - 71


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: WS outside of control

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Raymond Feng wrote:
> Hi,
> 
> Welcome to Tuscany!
> 
> Let me first make sure that I understand your scenario correctly.
> 
> 1) You have an external web service "MathService" developed with Axis2 
> and the endpoint address is 
> http://localhost:8080/zong/services/MathService.
> 2) In the Calculator composite, you want to wire to the "MathService" to 
> provide the "add" function
> 3) There is an interface AddService with "add" operation
> 
> Since the MathService has different operations than AddService, the 
> Calculator component needs to wire to the MathService using an interface 
> compatible with MathService, for example, you can define an interface 
> for the MathService as:
> 
> @Remotable
> public interface RemoteMatchService {
>    public double addiere(double a,double b);
>    public int aufrunden(double a);
> }
> 
> And change the Calculator impl to be:
> 
> private RemoteMatchService addService;
> 
> @Reference
> public void setAddService(RemoteMathService addService) {
> ...
> }
> 
> public double add(double n1, double n2) {
>      return addService.addiere(n1, n2);
> }
> 

Hmmm, that will work but requires changes to CalculatorServiceImpl.java.

The neat thing with SCA is that you can also support your scenario 
without a code change (but a little more assembly), as follows:

1. Create a 'mediation' component that mediates between the AddService 
and the MathService interfaces.

class AddMediationImpl implements AddService {

   private MathService mathService;

   @Reference
   public setMathService(MathService service) {
     this.mathService = service;
   }

   public double add(double a, double b) {
     return mathService.addiere(a, b);
   }
}

2. Put that mediation component on the path to your remote math service 
in your .composite.

<composite ...>

  <component name="CalculatorServiceComponent">
   <implementation.java class="calculator.CalculatorServiceImpl"/>
   <reference name="addService" target="MediationServiceComponent"/>
    ...
  </component>

  <component name="MediationServiceComponent">
   <implementation.java class="calculator.AddMediationImpl"/>
   <reference name="mathService">
    <binding.ws uri="http://localhost:8080/zong/services/MathService" /> 

   </reference>
  </component>
  ...
</composite>

Mediation components like that allow you to compose an application out 
of services that were not initially designed to fit together, by 
adapting their interfaces and/or behavior.

They are usually simple to write by hand, or if you have many interface 
mappings like that one, you can just write a simple tool that generates 
them for you.

Hope this helps.
-- 
Jean-Sebastien

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: WS outside of control

Posted by Raymond Feng <en...@gmail.com>.
Hi,

Welcome to Tuscany!

Let me first make sure that I understand your scenario correctly.

1) You have an external web service "MathService" developed with Axis2 and 
the endpoint address is http://localhost:8080/zong/services/MathService.
2) In the Calculator composite, you want to wire to the "MathService" to 
provide the "add" function
3) There is an interface AddService with "add" operation

Since the MathService has different operations than AddService, the 
Calculator component needs to wire to the MathService using an interface 
compatible with MathService, for example, you can define an interface for 
the MathService as:

@Remotable
public interface RemoteMatchService {
    public double addiere(double a,double b);
    public int aufrunden(double a);
}

And change the Calculator impl to be:

private RemoteMatchService addService;

@Reference
public void setAddService(RemoteMathService addService) {
...
}

public double add(double n1, double n2) {
      return addService.addiere(n1, n2);
}

Thanks,
Raymond

--------------------------------------------------
From: "Albert Rainer" <al...@ec3.at>
Sent: Friday, March 21, 2008 5:53 AM
To: <tu...@ws.apache.org>
Subject: WS outside of control

> I'm giving a lecture in "Web Service Composition" at the Vienna University 
> of Technology and I want to use tuscany as an advances technique for 
> system configuration. But first of all I've to understand the technology 
> befor annoying my students. I've gone through the examples but didn't find 
> any solution for my problem.
> :
> I have a composite that defines a component and binds it to a Web Service 
> outside of my control, somewhere on the Web.
> The service is axis2 and generated from a Java class.
> package at.move;
> public class MathService {
> public double addiere(double a,double b){
> return a+b;
> }
> public int aufrunden(double a){
> return (int)Math.ceil(a);
> }
> }
> The Calculaor.composite looks like that:
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>           targetNamespace="http://sample"
>           xmlns:sample="http://sample"
>           name="Calculator">
>
>    <component name="CalculatorServiceComponent">
> <implementation.java class="calculator.CalculatorServiceImpl"/>
> <reference name="addService">
>            <binding.ws 
> uri="http://localhost:8080/zong/services/MathService" />
>        </reference>
>        <reference name="subtractService" 
> target="SubtractServiceComponent"></reference>
>        <reference name="multiplyService" 
> target="MultiplyServiceComponent"></reference>
>        <reference name="divideService" 
> target="DivideServiceComponent"></reference>
>    </component>
>
>    <component name="SubtractServiceComponent">
>        <implementation.java class="calculator.SubtractServiceImpl"/>
>    </component>
>    ...
> </composite>
>
> The idea is: For the addService and method add() I want to use the The Web 
> Service with the method: addiere()
> I need to map the AddService to the MathService and the add method from 
> the Calculator to the addiere method from MathService
> @Reference
>    public void setAddService(AddService addService) {
>        this.addService = addService;
>    }
>   public double add(double n1, double n2) {
>        return addService.add(n1, n2);
>    }
>
> What steps are required in order to achieve such a mapping? Or is this not 
> in the intetntion of tuscany and it is not possible?
>
> Many thanks in advance.
>
>
> ----------------------------------------------------------------
> Dr. Albert Rainer
> EC3 - Electronic Commerce Competence Center
> www.ec3.at
> Donau-City Strasse 1
> A-1220 Wien
> Tel: +43 1 522 71 71 - 33
> Fax: +43 1 522 71 71 - 71
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: WS outside of control

Posted by Jean-Jacques Dubray <jd...@gmail.com>.
Albert:

my understanding is that SCA is based on an "automatic" (semantic) mapping.
The method signatures had to be the same. This is not a severe limitation
because at some point 2 interfaces have to match to communicate. The pattern
to compose arbitrary interfaces is to use a mediator component that bridges
the two interfaces. Again, this is not a big limitation, because when you
need to compose arbitrary interfaces, you could have a lot going on in the
mediator (transformation, even some state management...)

JJ-

On Fri, Mar 21, 2008 at 5:53 AM, Albert Rainer <al...@ec3.at> wrote:

> I'm giving a lecture in "Web Service Composition" at the Vienna University
> of Technology and I want to use tuscany as an advances technique for system
> configuration. But first of all I've to understand the technology befor
> annoying my students. I've gone through the examples but didn't find any
> solution for my problem.
> :
> I have a composite that defines a component and binds it to a Web Service
> outside of my control, somewhere on the Web.
> The service is axis2 and generated from a Java class.
> package at.move;
> public class MathService {
>        public double addiere(double a,double b){
>                return a+b;
>        }
>        public int aufrunden(double a){
>                return (int)Math.ceil(a);
>        }
> }
> The Calculaor.composite looks like that:
> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
>           targetNamespace="http://sample"
>           xmlns:sample="http://sample"
>           name="Calculator">
>
>    <component name="CalculatorServiceComponent">
>                <implementation.java class="
> calculator.CalculatorServiceImpl"/>
>                <reference name="addService">
>            <binding.ws uri="
> http://localhost:8080/zong/services/MathService" />
>        </reference>
>        <reference name="subtractService"
> target="SubtractServiceComponent"></reference>
>        <reference name="multiplyService"
> target="MultiplyServiceComponent"></reference>
>        <reference name="divideService"
> target="DivideServiceComponent"></reference>
>    </component>
>
>    <component name="SubtractServiceComponent">
>        <implementation.java class="calculator.SubtractServiceImpl"/>
>    </component>
>    ...
> </composite>
>
> The idea is: For the addService and method add() I want to use the The Web
> Service with the method: addiere()
>  I need to map the AddService to the MathService and the add method from
> the Calculator to the addiere method from MathService
>  @Reference
>    public void setAddService(AddService addService) {
>        this.addService = addService;
>    }
>   public double add(double n1, double n2) {
>        return addService.add(n1, n2);
>    }
>
> What steps are required in order to achieve such a mapping? Or is this not
> in the intetntion of tuscany and it is not possible?
>
> Many thanks in advance.
>
>
> ----------------------------------------------------------------
> Dr. Albert Rainer
> EC3 - Electronic Commerce Competence Center
> www.ec3.at
> Donau-City Strasse 1
> A-1220 Wien
> Tel: +43 1 522 71 71 - 33
> Fax: +43 1 522 71 71 - 71
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>


-- 
Jean-Jacques Dubray
425-445-4467