On Thu, Nov 6, 2008 at 7:28 PM, Ray Harrison <[EMAIL PROTECTED]> wrote:

> Simon Laws wrote:
>
>> On Thu, Nov 6, 2008 at 4:42 PM, Ray Harrison <[EMAIL PROTECTED]>
>> wrote:
>>
>>  Simon Laws wrote:
>>>
>>>  On Thu, Nov 6, 2008 at 1:50 PM, Ray Harrison <[EMAIL PROTECTED]>
>>>> wrote:
>>>>
>>>>  Hi folks,
>>>>
>>>>> I am apparently a bear of very little brain and I am attempting to get
>>>>> working what in my mind should be a very simple case: Have a component
>>>>> reference an external web service (implemented in this case via Spring
>>>>> Web
>>>>> Services). I've followed an example I believe posted by ant called
>>>>> Translator but I've mostly been banging my head repeatedly for several
>>>>> days
>>>>> getting nowhere.
>>>>>
>>>>> I've plowed through some of the reference docs as well as the Tuscany
>>>>> documentation I can find and any examples in the download, but I'm
>>>>> missing
>>>>> something fundamental somewhere and I am reaching out for guidance -
>>>>> apologies in advance for the newbieness of the post. But, hey, I'm very
>>>>> new
>>>>> at Tuscany and SCA in general.
>>>>>
>>>>> Here's the (I believe) simple setup:
>>>>>
>>>>> 1.) I've got a WSDL and supporting schemas:
>>>>>
>>>>> src/
>>>>>      Customer.wsdl
>>>>>      {schemas - namespace imports in WSDL}
>>>>>      Customer.composite - which has been stripped bare:
>>>>>
>>>>> <?xml version="1.0" encoding="ISO-8859-15"?>
>>>>> <sca:composite xmlns:sca="http://www.osoa.org/xmlns/sca/1.0";
>>>>> name="Customer" targetNamespace="http://customer";>
>>>>>  <sca:component name="CustomerServiceComponent">
>>>>>  <sca:implementation.java
>>>>> class="services.CustomerServiceComponentImpl"/>
>>>>>  <sca:reference name="customerWs">
>>>>>    <sca:binding.ws wsdlElement="
>>>>> http://customer/comcast/:#wsdl.port(CustomerService/CustomerPort)<http://customer/comcast/:#wsdl.port%28CustomerService/CustomerPort%29>
>>>>> <http://customer/comcast/:#wsdl.port%28CustomerService/CustomerPort%29
>>>>> >
>>>>> <http://customer/comcast/:#wsdl.port%28CustomerService/CustomerPort%29
>>>>> >
>>>>> "/>
>>>>>  </sca:reference>
>>>>>  </sca:component>
>>>>> </sca:composite>
>>>>>
>>>>>
>>>>> Compare this to the translator example (which I can get to work):
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; xmlns:tuscany="
>>>>> http://tuscany.apache.org/xmlns/sca/1.0";
>>>>>  targetNamespace="http://sample"; name="Translator">
>>>>>
>>>>>  <component name="TranslationService">
>>>>>      <implementation.java class="translate.TranslationServiceImpl" />
>>>>>      <reference name="translator">
>>>>>         <binding.ws wsdlElement="
>>>>> http://tempuri.org/#wsdl.port(Translator/TranslatorSoap)<http://tempuri.org/#wsdl.port%28Translator/TranslatorSoap%29>
>>>>> <http://tempuri.org/#wsdl.port%28Translator/TranslatorSoap%29>
>>>>> <http://tempuri.org/#wsdl.port%28Translator/TranslatorSoap%29>"
>>>>>
>>>>> />
>>>>>      </reference>
>>>>>  </component>
>>>>>
>>>>> </composite>
>>>>>
>>>>>
>>>>> Then I've got bare-bones implementation classes and interfaces.
>>>>>
>>>>> src/services:
>>>>>
>>>>>      CustomerWS - interface which represents the reference service
>>>>>
>>>>> package services;
>>>>>
>>>>> public interface CustomerWS {
>>>>>
>>>>> }
>>>>>      CustomerServiceComponent - interface for the component
>>>>>
>>>>> package services;
>>>>>
>>>>> public interface CustomerServiceComponent {
>>>>>
>>>>> }
>>>>>      CustomerServiceComponentImpl - implementation class
>>>>>
>>>>>            package services;
>>>>>
>>>>> import org.osoa.sca.annotations.Reference;
>>>>> import org.osoa.sca.annotations.Service;
>>>>>
>>>>> @Service(CustomerServiceComponent.class)
>>>>> public class CustomerServiceComponentImpl implements
>>>>> CustomerServiceComponent {
>>>>>
>>>>>      private CustomerWS customerWs;
>>>>>
>>>>>      @Reference
>>>>>  public void setCustomerWs(CustomerWS customerWs) {
>>>>>              this.customerWs = customerWs;
>>>>>      }
>>>>>
>>>>> }
>>>>>
>>>>>      CustomerServiceClient - client class
>>>>>
>>>>> Right now, this is all very, very stripped down as you can see.
>>>>> However,
>>>>> even when it has similar methods from the Translator example, it still
>>>>> can't
>>>>> past the line:
>>>>>
>>>>>      SCADomain domain = SCADomain.newInstance("Customer.composite");
>>>>>
>>>>> in the client class.
>>>>>
>>>>> I get:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> SEVERE: Interface not remotable: services.CustomerWS
>>>>> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
>>>>> org.osoa.sca.ServiceRuntimeException: Interface not remotable:
>>>>> services.CustomerWS
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADomain.java:276)
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.java:70)
>>>>>      at
>>>>> services.CustomerServiceClient.main(CustomerServiceClient.java:8)
>>>>> Caused by: org.osoa.sca.ServiceRuntimeException: Interface not
>>>>> remotable:
>>>>> services.CustomerWS
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.analyseProblems(DefaultSCADomain.java:309)
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultSCADomain.java:239)
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<init>(DefaultSCADomain.java:120)
>>>>>      at
>>>>>
>>>>>
>>>>> org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADomain.java:242)
>>>>>      ... 2 more
>>>>>
>>>>>
>>>>> And I thought I might need to add @Remotable to the service interface,
>>>>> but
>>>>> the translator example doesn't have it and that brought up all kinds
>>>>>  of
>>>>> other issues as well.
>>>>>
>>>>> So, sorry for the long post, but any guidance on actual steps for
>>>>> referencing an external service in a component would be most helpful -
>>>>> and
>>>>> if I've missed docs somewhere outlining, I'm all for going off and
>>>>> reading,
>>>>> I just haven't seen it.
>>>>>
>>>>> Thanks very much for your time!
>>>>>
>>>>> Ray
>>>>>
>>>>>
>>>>>
>>>>>  Hi Ray
>>>>>
>>>> Doesn't look like you are missing anything fundamental to me.
>>>>
>>>> As far as I know the interface CustomerWS should be marked as @Remotable
>>>> as
>>>> binding.ws is a remotable binding. I surfed up that Translator sample
>>>> that
>>>> Ant made and you are right that @Remotable doesn''t appear. Very
>>>> strange.
>>>> I
>>>> don't know how that worked (assuming it did).
>>>>
>>>> What were the issues you saw when you added @Remotable to the service
>>>> interface?
>>>>
>>>> Regards
>>>>
>>>> Simon
>>>>
>>>>
>>>>  Hi Simon,
>>>
>>> Once I put all of what I think are the right steps back in place, I get:
>>>
>>> Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
>>> org.apache.axis2.AxisFault: The system cannot infer the transport
>>> information from the / URL.
>>>
>>> I saw reference to this in the mailing lists I think sometime last year
>>> and
>>> didn't see a resolution. I'm very happy to post the entire project
>>> (either
>>> here or JIRA) - but would of course certainly rather figure it out for
>>> myself.
>>>
>>> Thanks very much
>>> Ray
>>>
>>>
>>>
>>>
>>>  Hi Ray
>>
>> What's the location in the port in the WSDL? For some reason it seems that
>> the web service binding doesn't have the correct URI for the service you
>> are
>> trying to call.
>>
>> Regards
>>
>> Simon
>>
>>
> I've included a watered down WSDL that accurately reflects what we are
> doing. The namespace of the WSDL is
> http://com.comcast/customer/v1/services. Our wsdlElement is
> http://com.comcast/customer/v1/services/#wsdl.port(Customer/CustomerPort)<http://com.comcast/customer/v1/services/#wsdl.port%28Customer/CustomerPort%29>
> .
>
> I think my disconnect is at knowing the flow when I kick off a component.
> Things like:
>
> 1.) When the infrastructure sees that I've got a reference to an external
> web service, what is the default location for any expected WSDL file (if
> using)?
>
> 2.) Once it finds that WSDL, what does it do first in relationship to the
> wsdlElement
>
> 3.) Where does PortType come into which interfaces and what specifically is
> necessary to implement.
>
> One note on the translate service referenced earlier - it definitely did
> work.
>
>
> And so on...
>
> Anyway, thanks much for your time!
>
> Cheers
> Ray
>

Hi Ray

Let me see if I can give you a summary of what happens. I'll use one of our
samples to do that (
http://svn.apache.org/repos/asf/tuscany/java/sca/samples/helloworld-ws-reference/).
This is a sample from trunk but it has worked like this for a while. What
Tuscany version are you wokring with?
There is a helloworld-ws-service that provides a service for this reference
sample to talk to. In the reference there is a client application that looks
like this.

public class HelloWorldClient {

    public  final static void main(String[] args) throws Exception {
        SCADomain scaDomain =
SCADomain.newInstance("helloworldwsclient.composite");
        HelloWorldService helloWorldService =
scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent");

        String value = helloWorldService.getGreetings("World");
        System.out.println(value);

        scaDomain.close();
    }
}

SCA has the concept of a contribution. A contribution can be pretty much any
hierarchical collection of files. We support things like jar and filesystem
directory at the moment. A contribution wraps up all of the things that you
need to run and SCA composite application. That could be a composite file, a
wsdl file, the java component implementations and any other artifacts you
need for you application to run. The Tuscany runtime works by reading
contributions and reading the deployable composite files it finds.

The line SCADomain scaDomain =
SCADomain.newInstance("helloworldwsclient.composite"); is line that sets up
the runtime in the client application above. So why have I spent time
talking about contributions? Well this SCADomain interface is very
missleading. What this actually does is use the name of the ".composite"
file provided. Locate this file on the file system and them use the
directory that contains this file as the SCA contribution. In this was the
runtime is able to read the composite file, the WSDL file, the java class
files etc. The SCADomain interace has caused lots of problems so we are
changing it to SCANode. We haven't go round to fixing this sample yet though

The runtime looks at the contribution and indexes all the files it finds. It
knows how to deal with wsdl, xsdl, class, composite etc files.

Once it's done this is looks at the specified composite file. In this case
helloworldwsclient.composite looks like.

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
    targetNamespace="http://helloworld";
    xmlns:hw="http://helloworld";
    name="helloworldwsclient">

    <!-- A component with an embedded reference definition connecting to an
external webservice
         The wsdl interface for the reference is derived from the
information specified by the 'wsdlElement'
     -->
    <component name="HelloTuscanyServiceComponent">
      <implementation.java class="helloworld.HelloWorldServiceComponent"/>
      <reference name="helloWorldService">
        <binding.ws wsdlElement="
http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
      </reference>
    </component>

  etc

The runtime parses this xml and creates a component called
HelloTuscanyServiceCompoent. It configures the references and services on
the component ready for when a component instance is created (when this
happens depends in what the scope of the component is). The reference
configuration is specified by the binding.ws element in this case. The
binding.ws element refers to a wsdl port. The runtime is able to find this
based on it's QName because it indexed all the files in the first place when
the contribution was read.  It uses the WSDL to configure a binding
interface for this reference. This interface effectively configures the
Axis2 web service engine that sits uderneath the web serivce binding
implementation so that the reference is able to call the remote web service.


Next the client gets a proxy to the component using the line

HelloWorldService helloWorldService =
scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent");

This asks the tuscany runtime to create an instance of the named component
(if one is not already available) and return a proxy to it. During instance
creation the runtime will ensure that the reference proxies are injected
based on the configuration the runtime will have dertermined.

Next the client calls the component with the line.

String value = helloWorldService.getGreetings("World");

So this makes a call on our local SCA component which is implemented as
follows

public class HelloWorldServiceComponent implements HelloWorldService {

    HelloWorldService helloWorldService;

    public String getGreetings(String name) {
        System.out.println("Called getGreetings");
        return helloWorldService.getGreetings(name);
    }
etc.

This component instance is running in the tuscany runtime that we started in
the same JVM that is running the client so our call to it is just a local
java call to its getGreetings() method. The helloWorldService reference
proxy will have been injected when the component instance was created so the
getGreetings() method is free to make a call to it.

return helloWorldService.getGreetings(name);

This has the effect of making the remote web services using the
configuration specified by the binding.ws element.

So that's a quick run through what is happening with a client side
reference. Hope that makes sense.

Re, the use of WSDL. With a configuration such as

<binding.ws wsdlElement="
http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>

The web service binding should be able to find the port in question and
retrieve both the location information and, working from the port, find the
binding, portType, message and schema information. So you should be set to
go.

Re. the attached WSDL, the targetNamespace and service name don't match your
original example.

 <sca:binding.ws wsdlElement="
http://customer/comcast/:#wsdl.port(CustomerService/CustomerPort)<http://customer/comcast/:#wsdl.port%28CustomerService/CustomerPort%29>
"/>

Is this just a product of you cutting down the WSDL? I also note that you
have a header mapping in the wsdl binding. I'm pretty sure Tuscany is going
to ignore that at the moment. I'll defer to someone who knows more about the
guts of binding.ws for confirmation though. I'd be surprised though if this
causes the org.apache.axis2.AxisFault you reported.

Are there any other errors or warnings that get reported when the runtime
starts?

If none of this helps you may have to post a sample that demonstrates the
problem and we'll take a look at it.

Regards

Simon

Reply via email to