Hi tuscany people,

I've found in the mailinglist a nice description on how to use jaxb with
tuscany
(http://www.mail-archive.com/[EMAIL PROTECTED]/msg01900.html).
For SDO, there are some samples, but they didn't really make sense to
me, because they were using a wsdl as startingpoint. In the beginning of
a project, I normally don't start writing wsdls. In fact, I try to avoid
writing wsdls manually anyway. So, lets say, we start with a schema or
emf model  (just because we are bored by javabeanish pojos) of our
domain modell on which we want to define some operations later. To be
clear, the "domain model" shall be:
            
<complexType name="Name">
                <sequence>
                    <element name="first" type="xsd:string" />
                    <element name="last" type="xsd:string" />
                </sequence>
</complexType>

The first thing would be to generate SDOs out of this. I eventually
managed to do that with the XSD2JavaGenerator and a friend managed to
somehow do it with emf (you have to do some magical settings in emf to
make the produced SDOs accpeted by tuscany). 


package helloworld;
public interface Name extends Serializable
{
        String getFirst();
        void setFirst(String value);
        String getLast();
        void setLast(String value);

} // Name

And

package helloworld.impl;
public interface NameImpl implements Name { ... some cryptic sdo stuff
;)
}

Now that we have a java incarnation of our domainmodel which consists of
interfaces and implementations, lets define some operations on them as a
java interface. In the java interface, we want to use the Name
interface, because then the java interface definitions stay open for
other implementations (just in case we are not bored by pojos any
longer;) ):

@Remotable
public interface HelloWorldService {
    public String getGreetings(Name name);
}

And now? I thought it should be a peace of cake to use this service? But
by exposing it like:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; 
 
xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"; 
    name="helloworldws">
    
    <component name="HelloWorldServiceComponent">
        <implementation.java class="helloworld.HelloWorldImpl" />
        <service name="HelloWorldService">
            <interface.java interface="helloworld.HelloWorldService" />
            <binding.ws/>
        </service>
    </component>
</composite>

I get when instantiating the above composite:

WARNING: Exception while generating WSDL for
HelloWorldServiceComponent/HelloWorldService
Sep 9, 2008 10:58:03 PM
org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator
SEVERE: Exception thrown was: java.lang.NullPointerException
Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
org.osoa.sca.ServiceRuntimeException: java.lang.NullPointerException
        at
org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADoma
in.java:276)
        at
org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.jav
a:70)
        at helloworld.HelloWorldServer.main(HelloWorldServer.java:33)
Caused by: org.osoa.sca.ServiceRuntimeException:
java.lang.NullPointerException
        at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.analyseProble
ms(DefaultSCADomain.java:307)
        at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultS
CADomain.java:239)
        at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<init>(Defaul
tSCADomain.java:120)
        at
org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADoma
in.java:242)
        ... 2 more
Caused by: java.lang.NullPointerException
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.addSch
emaExtension(Interface2WSDLGenerator.java:400)
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.addSch
emaExtension(Interface2WSDLGenerator.java:389)
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.genera
te(Interface2WSDLGenerator.java:258)
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.createWSD
LInterfaceContract(BindingWSDLGenerator.java:307)
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.createWSD
LDocument(BindingWSDLGenerator.java:205)
        at
org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.generateW
SDL(BindingWSDLGenerator.java:163)
        at
org.apache.tuscany.sca.binding.ws.xml.BindingBuilderImpl.build(BindingBu
ilderImpl.java:48)
        at
org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuil
derImpl.buildServiceBindings(ComponentServiceBindingBuilderImpl.java:66)
        at
org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuil
derImpl.build(ComponentServiceBindingBuilderImpl.java:48)
        at
org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl.build(
CompositeBuilderImpl.java:150)
        at
org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime.buildCompos
ite(ReallySmallRuntime.java:234)
        at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultS
CADomain.java:238)
        ... 4 more

Isit a bug? Or do I expect to much? What happens behind the scene?

So, what to do? The only sample I could find used an interface.wsdl as
interface description . Why do I have to handcode a wsdl when I already
have a nice IDL in Form of a java interface? Isn't writing wsdls by hand
a pain? Yes, it is, so I found a tool which would create the wsdl for me
(do you notice the redundancy? Xsd->sdo/interfaces->java servcice
interface as a idl->wsdl (=xsd+idl)) and I created with
org.apache.ws.java2wsdl.Java2WSDL a wsdl, which I then used again in the
tuscany component as interface description:

            <interface.wsdl
interface="http://helloworld#wsdl.interface(HelloWorldServicePortType)"
/>

And it finally worked (after a trial and error procedure 2 days) . In
the client the, for whatever reason, an interface.java is sufficient.

If this was the right way to go, then I wonder:
* ...what does "note that an SCA runtime should provide command line
type tools to generate the static types..." from the "SCA Service
Component Architecture Building Your First Application - simplified
BigBank" ... exactly mean in this context? Is
org.apache.ws.java2wsdl.Java2WSDL  the tool of choice in the case of
tuscany?
* Why is the java interface not enough, why do I have to generae a wsdl
myselve. My datatypes and operations are already declared in java and I
would expect that I dont have to reformulate them myself again.

And the big question: how the heck can I write a client that uses a non
sdo-implementation of the Name Interface and run it against the same
service, preferably without writing wsdl by hand. According to the
databinding guide, this should be possible but despite lots of
experiments, I didnt succeed in that and hit all kinds of problems. Are
there any examples? Has anyone managed to do that? If not, I can see me
writing another mail like this soon...;) 

Viele Gruesse
 hixxxxx


Reply via email to