You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by legolas wood <le...@gmail.com> on 2007/06/13 10:31:36 UTC

A question about SCA descriptor file structure and meaning.

Hi
Thank you for reading my post
Can you please explain following snippet for me?

<reference name="StockQuoteReference1">

    <interface.wsdl interface="http://www.stockquote.org/StockQuoteService#wsdl.interface(StockQuote)"/>

    <binding.ws wsdlElement="http://www.stockquote.org/StockQuoteService#wsdl.service(StockQuoteService)"
        wsdli:wsdlLocation="http://www.stockquote.org/StockQuoteService
            http://www.stockquote.org/StockQuoteService.wsdl" />

</reference>


Imagine that i have a java class named Calculate, it has one method 
which takes two numbers and return an integer as result. something like :





@WebService()

public class Calculate {

    /**

     * Web service operation

     */

    @WebMethod

    public int addThem(@WebParam(name = "a")

    int a, @WebParam(name = "b")

    int b) {

        // TODO write your implementation code here:

        return a+b;

    }

    

}



URL to wsdl of this web service is like: 
http://localhost:8080/sample/CalculateService?wsdl

Now how the above code snippet which is an SCA code snippet should 
change to use my web service and its addThem method?


Thanks


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


Re: A question about SCA descriptor file structure and meaning.

Posted by Jean-Sebastien Delfino <js...@apache.org>.
legolas wood wrote:
> Hi
> Thank you for reading my post
> Can you please explain following snippet for me?
>
> <reference name="StockQuoteReference1">
>
>    <interface.wsdl 
> interface="http://www.stockquote.org/StockQuoteService#wsdl.interface(StockQuote)"/> 
>
>
>    <binding.ws 
> wsdlElement="http://www.stockquote.org/StockQuoteService#wsdl.service(StockQuoteService)" 
>
>        wsdli:wsdlLocation="http://www.stockquote.org/StockQuoteService
>            http://www.stockquote.org/StockQuoteService.wsdl" />
>
> </reference>
>
>
> Imagine that i have a java class named Calculate, it has one method 
> which takes two numbers and return an integer as result. something like :
>
>
>
>
>
> @WebService()
>
> public class Calculate {
>
>    /**
>
>     * Web service operation
>
>     */
>
>    @WebMethod
>
>    public int addThem(@WebParam(name = "a")
>
>    int a, @WebParam(name = "b")
>
>    int b) {
>
>        // TODO write your implementation code here:
>
>        return a+b;
>
>    }
>
>   
> }
>
>
>
> URL to wsdl of this web service is like: 
> http://localhost:8080/sample/CalculateService?wsdl
>
> Now how the above code snippet which is an SCA code snippet should 
> change to use my web service and its addThem method?
>
>
> Thanks
>
>

Hi,

If I understand correctly you're trying to use an SCA reference with an 
SCA Web Service binding to talk to a CalculateService Web service, for 
which you already have a WSDL?

If this is your scenario then it's pretty simple.

You simply need to change the SCA reference to name the WSDL <portType> 
and <service> (or <port>) representing the CalculateService in the WSDL 
returned at http://localhost:8080/sample/CalculateService?wsdl.

It's probably best to have a local copy of the CalculateService WSDL 
instead of relying on http://localhost:8080/sample/CalculateService?wsdl 
to be online all the time, so I'd recommend to save it to 
CalculateService.wsdl, store that WSDL locally with your other SCA 
artifacts, then change your SCA <reference> like this:

<composite ...>

  <component name="SampleComponent">

    <reference name="CalculateReference">
       <interface.wsdl 
interface="http://calculate-namespace#wsdl.interface(Calculate)"/>
       <binding.ws 
wsdlElement="http://calculate-namespace#wsdl.service(CalculateService)"/>
    </reference>

    ... other configuration of your component

  </component>

</composite>

A few comments:

- An SCA reference usually lives inside a component (representing the 
code that's going to talk to the reference), inside an SCA composite. I 
just added them here to put the <reference/> in context.

- I have to guess what's in your WSDL, so in my example 
http://calculate-namespace would be the namespace of your WSDL definition

- Calculate would be the name of your WSDL <portType/>

- CalculateService would be the name of your WSDL <service/>

- I recommend to avoid using wsdlLocation in general as I doubt that 
your application will always run on localhost:8080 :) and when you 
install it somewhere else you probably don't want to go back to your SCA 
reference and change that location. What we usually do instead is we 
place a local copy of the WSDL file in the client application, and the 
Tuscany runtime will automatically find it 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