Hi Raymond, > -----Original Message----- > From: Raymond Feng [mailto:[EMAIL PROTECTED] > Sent: 10 September 2008 19:33 > To: [EMAIL PROTECTED] > Cc: tuscany-dev > Subject: Re: SDO howto and traps (or bugs?) > > 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
The "Name SDO" interface as generated by XSD2Java is just an interface without any SDO dependencies. I was suspecting that this could be the Problem. > 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. Is it necessary to supply the wsdl or the xsd, or should it work without any of them (in the first case, I dont have a bug to report)? > > 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 Will do. I was using 1.3.1. Thanks, Gerald > 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/hell > oworld-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]/msg019 > 00.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.createNewInstan > ce(SCADomain.java:276) > at > org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCA > Domain.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.ana > lyseProblems(DefaultSCADomain.java:307) > at > org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.ini > t(DefaultSCADomain.java:239) > at > org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<in > it>(DefaultSCADomain.java:120) > at > org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstan > ce(SCADomain.java:242) > ... 2 more > Caused by: java.lang.NullPointerException > at > org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenera > tor.addSchemaExtension(Interface2WSDLGenerator.java:400) > at > org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenera > tor.addSchemaExtension(Interface2WSDLGenerator.java:389) > at > org.apache.tuscany.sca.binding.ws.wsdlgen.Interface2WSDLGenera > tor.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.ComponentServiceB > indingBuilderImpl.buildServiceBindings(ComponentServiceBinding > BuilderImpl.java:66) > at > org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceB > indingBuilderImpl.build(ComponentServiceBindingBuilderImpl.java:48) > at > org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderI > mpl.build(CompositeBuilderImpl.java:150) > at > org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime.b > uildComposite(ReallySmallRuntime.java:234) > at > org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.ini > t(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(HelloWorldServiceP > ortType)" /> > 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 > >
