Hi,

The SDO story should be similar as JAXB as you have experimented. I assume you try to expose a SCA java component which uses SDO as a web service.

The steps will be:

1) Define a XSD to model the Name
2) Use XSD2Java (ant task or maven plugin), see build.xml and pom.xml under [1] to generate SDO java classes
3) Define HelloWorldService interface that uses the Name SDO
4) Create a java class that implement the HelloWorldService
5) Define a composite that contains the HelloWorldService component and configure the service with binding.ws. You don't have to configure the interface as it will be introspected from the java class.

   <component name="HelloWorldServiceComponent">
       <implementation.java class="helloworld.HelloWorldImpl" />
       <service name="HelloWorldService">
           <binding.ws/>
       </service>
   </component>

Since the component is exposed as a Web Service, the runtime needs to generate the WSDL for Axis2. If you have the XSD in the SCA contribution, Tuscany Interface2WSDL tries to match the SDO type to the XSD and reuse it.

Can you open a JIRA and attach your test case there? We can investigate why NPE. From your stack trace, I don't see a line number match in the latest trunk code. Which level of Tuscany are you using?

There are a few samples:

[1] https://svn.apache.org/repos/asf/tuscany/java/sca/samples/helloworld-ws-sdo
[2] https://svn.apache.org/repos/asf/tuscany/java/sca/itest/databindings/

Thanks,
Raymond

From: KLESER, Gerald
Sent: Wednesday, September 10, 2008 1:17 AM
To: [EMAIL PROTECTED]
Subject: SDO howto and traps (or bugs?)


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(SCADomain.java:276) at org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.java: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.analyseProblems(DefaultSCADomain.java:307) 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
Caused by: java.lang.NullPointerException
at org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.addSchemaExtension(Interface2WSDLGenerator.java:400) at org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.addSchemaExtension(Interface2WSDLGenerator.java:389) at org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenerator.generate(Interface2WSDLGenerator.java:258) at org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.createWSDLInterfaceContract(BindingWSDLGenerator.java:307) at org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.createWSDLDocument(BindingWSDLGenerator.java:205) at org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator.generateWSDL(BindingWSDLGenerator.java:163) at org.apache.tuscany.sca.binding.ws.xml.BindingBuilderImpl.build(BindingBuilderImpl.java:48) at org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuilderImpl.buildServiceBindings(ComponentServiceBindingBuilderImpl.java:66) at org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuilderImpl.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.buildComposite(ReallySmallRuntime.java:234) at org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultSCADomain.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