-----Original Message----- From: Simon Laws [mailto:simonsl...@googlemail.com] Sent: 20 May 2010 14:57 To: user@tuscany.apache.org Subject: Re: Problem calling to an external web service.
On Thu, May 20, 2010 at 2:42 PM, Gregor Kiddie <gregor.kid...@channeladvisor.com> wrote: > > > -----Original Message----- > From: Mike Edwards [mailto:mike.edwards.inglen...@gmail.com] > Sent: 20 May 2010 14:31 > To: user@tuscany.apache.org > Subject: Re: Problem calling to an external web service. > > Gregor Kiddie wrote: >> >> -----Original Message----- >> From: Simon Laws [mailto:simonsl...@googlemail.com] >> Sent: 18 May 2010 14:13 >> To: user@tuscany.apache.org >> Subject: Re: Problem calling to an external web service. >> >> On Tue, May 18, 2010 at 1:55 PM, Gregor Kiddie >> <gregor.kid...@channeladvisor.com> wrote: >>> >>> -----Original Message----- >>> From: Simon Laws [mailto:simonsl...@googlemail.com] >>> Sent: 18 May 2010 13:42 >>> To: user@tuscany.apache.org >>> Subject: Re: Problem calling to an external web service. >>> >>> On Tue, May 18, 2010 at 1:04 PM, Gregor Kiddie >>> <gregor.kid...@channeladvisor.com> wrote: >>>> >>>> -----Original Message----- >>>> From: Simon Laws [mailto:simonsl...@googlemail.com] >>>> Sent: 18 May 2010 12:56 >>>> To: user@tuscany.apache.org >>>> Subject: Re: Problem calling to an external web service. >>>> >>>> On Tue, May 18, 2010 at 12:25 PM, Gregor Kiddie >>>> <gregor.kid...@channeladvisor.com> wrote: >>>>> I'm trying to make a call from Tuscany to an external webservice. I > think I >>>>> have it set up correctly, but it gives the same error each time. > It's >>>>> running in a Tomcat Container. >>>>> >>>>> >>>>> >>>>> The error I'm getting is >>>>> >>>>> >>>>> >>>>> Caused by: org.osoa.sca.ServiceRuntimeException: No runtime wire is >>>>> available >>>>> >>>>> at >>>>> > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKIn > vocationHandler.java:186) >>>>> >>>>> and my composite looks like this >>>>> >>>>> >>>>> >>>>> <?xml version="1.0" encoding="UTF-8"?> >>>>> >>>>> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" >>>>> >>>>> targetNamespace="com.mycompany.myproduct.mymodule" >>>>> >>>>> name="mymodule"> >>>>> >>>>> >>>>> >>>>> <component name="MyModule"> >>>>> >>>>> <implementation.spring >>>>> location="WEB-INF/classes/applicationContext.xml" /> >>>>> >>>>> <service name="MyService"> >>>>> >>>>> <binding.ws /> >>>>> >>>>> </service> >>>>> >>>>> </component> >>>>> >>>>> >>>>> >>>>> <reference name="myServiceProvider"> >>>>> >>>>> <interface.java >>>>> > interface="com.mycompany.soa.webservices.SuperServiceSkeletonInterface" > /> >>>>> >>>>> <binding.ws >>>>> > uri="http://soa.0002.dev.mycompany.com/SuperFacility/SuperService.asmx" > /> >>>>> >>>>> </reference> >>>>> >>>>> </composite> >>>>> >>>>> >>>>> >>>>> Any suggestions? >>>> Hi >>>> >>>> Try putting the reference inside the component, for example, >>>> >>>> <component name="MyModule"> >>>> <implementation.spring >>>> location="WEB-INF/classes/applicationContext.xml" /> >>>> <service name="MyService"> >>>> <binding.ws /> >>>> </service> >>>> <reference name="myServiceProvider"> >>>> <interface.java >>>> > interface="com.mycompany.soa.webservices.SuperServiceSkeletonInterface" >>>> /> >>>> <binding.ws >>>> > uri="http://soa.0002.dev.mycompany.com/SuperFacility/SuperService.asmx" >>>> /> >>>> </reference> >>>> </component> >>>> >>>> I'm assuming that you're Spring context defines a reference property >>>> called "myServiceProvider". You can of course put references at the >>>> composite level but they should refer to a component reference that >>>> they promote using the the "promote" attribute. >>>> >>>> Regards >>>> >>>> Simon >>>> >>>> Yeah, the applicationContext looks like this >>>> >>>> <?xml version="1.0" encoding="UTF-8"?> >>>> <beans xmlns="http://www.springframework.org/schema/beans" >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>> xmlns:sca="http://www.springframework.org/schema/sca" >>>> xsi:schemaLocation=" >>>> http://www.springframework.org/schema/beans >>>> > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd >>>> http://www.springframework.org/schema/sca >>>> http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd"> >>>> >>>> <bean id="MyModuleBean" > class="com.mycompany.myproduct.mymodule.impl.DefaultImplementation"> >>>> <property name="myServiceProvider" > ref="myServiceProvider" /> >>>> </bean> >>>> </beans> >>>> >>>> Putting the reference in the component and removing the property set > in the applicationContext throws an error on start up >>>> >>>> Caused by: org.apache.tuscany.sca.monitor.MonitorRuntimeException: > Reference not found for component reference: Component = MyModule > Reference = myServiceProvider >>>> >>>> >>>> -- >>>> Apache Tuscany committer: tuscany.apache.org >>>> Co-author of a book about Tuscany and SCA: tuscanyinaction.com >>>> >>> It's because SCA it looking for a property that it can map to the SCA >>> reference. In doing this it looks for Spring properties that >>> themselves don't have references. Can you try taking the >>> ref="myServiceProvider" annotation off the Spring property and see >>> what happens. >>> >>> Regards >>> >>> Simon >>> >>> No annotations other than SCA ones. Spring is purely XML driven. >>> >>> Taking the <property... /> out of the bean definition gives the same > error. >>> >>> -- >>> Apache Tuscany committer: tuscany.apache.org >>> Co-author of a book about Tuscany and SCA: tuscanyinaction.com >>> >> >> Oops sorry I used the word annotation when I meant to say attribute. >> Can you change >> >> <property name="myServiceProvider" ref="myServiceProvider" /> >> >> to be >> >> <property name="myServiceProvider" /> >> >> Simon >> >> Same error. I'm deleting the web app, rebuilding and redeploying each > time as well to make sure it's starting correctly. >> >> > Gregor, > > What is the type of the "myServiceProvider" property in the > com.mycompany.myproduct.mymodule.impl.DefaultImplementation class? > > For the bean property to be recognised as an SCA reference, the type > must be an interface class. > > If the type is not an interface class, you will need to add an > <sca:reference/> element into your > application context, along these lines: > > <beans> > > <!-- An explicit reference, which is used by bean "Y" --> > <sca:reference name="SCAReference" type="com.xyz.SomeType"/> > > <bean name="X"> > <property name="foo" ref="Y"/> > </bean> > > <bean name="Y"> > <property name="bar" ref="SCAReference"/> > <property name="goo" ref="sca-property-name"/> > </bean> > > <!-- expose an SCA property named "sca-property-name" --> > <sca:property name="sca-property-name" type="java.lang.String"/> > > <!-- Expose the bean "X" as an SCA service named "SCAService" --> > <sca:service name="SCAService" type="org.xyz.someapp.SomeInterface" > target="X"/> > > </beans> > > > Yours, Mike. > > > I'm not sure what you mean by interface class! > > The type of the property is the SkeletonInterface interface created by > the wsdl2java tool from axis. That's the interface I refer to in the > <interface.java ... /> in the reference. > > Is that not the right way to do it? > Hi Gregor, I forgot to ask, what version of Tuscany are you using? I've been looking at the test/samples to make sure I was giving you the right info. The implementation in 1.x and 2.x is pretty much the same IIRC. There are no samples enabled in 2.x just at the moment but there is an itest (itest/implementation-spring) and this has examples of implicit and explicit reference definition in a Spring context [1].... Implicit ===== composite --------------- <component name="ClientComponent"> <implementation.spring location="META-INF/spring/SpringImplicitReference-context.xml"/> <reference name="testReference" target="ImplicitReferenceComponent"/> </component> <component name="ImplicitReferenceComponent"> <implementation.java class="helloworld.HelloWorldImpl"/> </component> Spring context --------------------- <bean id="testBean" class="mock.TestReferenceBean"> <!-- Here is the implicit reference - a property with a ref not satisifed within the * Spring application context. --> <property name="bean" ref="testReference"/> </bean> Beans -------- public class TestReferenceBean implements HelloWorld { // The reference private HelloWorld bean; // Classic "Hello xxx" response to any input message public String sayHello(String message) { System.out.println("TestReferenceBean - sayHello called"); return (bean.sayHello(message)); } /** * Setter for the bean reference * @param theBean */ public void setBean(HelloWorld theBean) { this.bean = theBean; } /** * Getter for the reference * @return */ public HelloWorld getBean() { return this.bean; } } // end class TestReferenceBean } @Remotable public interface HelloWorld { String sayHello(String s); } Looking at this I was wrong in suggesting that the ref attribute MUST be removed but it shouldn't point to anything in the context. I think what Mike's saying is that the type of the referenced bean, HelloWorld in this case, must be a Java interface rather than a Java class. It is an interface in the example above. If you do need an example of the explicit approach you can see it here [1] also. If you need a links to examples in the 1.x code base instead I can look that up for you. Simon [1] http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/itest/implementation-spring/src/main/resources/sca/references/ -- Apache Tuscany committer: tuscany.apache.org Co-author of a book about Tuscany and SCA: tuscanyinaction.com I'm using 1.6 mainly due to the lack of available resources for 2.x I've managed to get it working, I think it was due to me missing the @Remotable on the Interface for the external service (I could of sworn I had it at one point!), though it may be to the tidied up files. I appreciate the help! Thank you very much! Gk