On Mon, May 24, 2010 at 11:03 AM, Gregor Kiddie <[email protected]> wrote: > > > -----Original Message----- > From: Simon Laws [mailto:[email protected]] > Sent: 24 May 2010 09:54 > To: [email protected] > Subject: Re: Exception with security (again) > > On Fri, May 21, 2010 at 8:17 PM, Gregor Kiddie > <[email protected]> wrote: >> Ok, last one before I leave for the weekend cursing Tuscany! >> >> >> >> Using an authentication policy on a binding.ws generates the following >> exception. >> >> >> >> Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 >> >> at >> org.apache.tuscany.sca.databinding.axiom.OMElementWrapperHandler.setChildren(OMElementWrapperHandler.java:76) >> >> It looks like childObjects passed into the method has all the parameters >> wrapped up in a single piece of XML >> >> The ChildElements which is pulled from the operation which is passed in, has >> them split up into three Elements. >> >> >> >> The loop in setChildren uses the size of the ChildElements as it's upper >> bounds and references both objects. Unsurprisingly, when it gets to >> childObjects[1] it blows up. >> >> >> >> I've been running through everything for a couple of hours and I'm now >> calling defeat. I'm close to dumping Tuscany for this! >> >> >> >> Gk. > > Hi Gregor > > Sorry that you're having a frustrating time. Can you describe your > scenario so I can reproduce it here. > > Thanks > > Simon > > > -- > Apache Tuscany committer: tuscany.apache.org > Co-author of a book about Tuscany and SCA: tuscanyinaction.com > > My Composite looks like > <?xml version="1.0" encoding="UTF-8"?> > <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" > targetNamespace="com.mycompany.myproduct.authentication" > xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" > name="authentication" > > > <component name="Authentication"> > <implementation.spring > location="WEB-INF/classes/applicationContext.xml" /> > <service name="Authentication"> > <binding.ws /> > </service> > <reference name="authenticationProvider" > > <binding.ws > wsdlElement="http://soa.mycompany.com/webservices/#wsdl.port(MyService/MyServiceSoap12)" > requires="authentication" /> > </reference> > </component> > </composite> > > My definitions file looks like > <?xml version="1.0" encoding="UTF-8"?> > <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" > xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" > > xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" > targetNamespace="com.mycompany.richfx.policy" > > > <policySet name="myCompanyPolicySet" provides="authentication" > appliesTo="sca:binding.ws"> > <tuscany:basicAuthentication> > <tuscany:userName>someusername</tuscany:userName> > <tuscany:password>some-password</tuscany:password> > </tuscany:basicAuthentication> > </policySet> > </definitions> > > Application starts up fine, but when I make the call to the external > webservice (the reference), I get the error in the OP. > Remove the definitions file and the requires="authentication", and the calls > works but gets rejected due to missing the basic authorisation. >
Hi Gregor There's something odd going on here. I set up a test where I deployed our calculator service with the AddService deployed as a web service to Tomcat with Basic Authentication turned on. I created a client project where the calculator has a reference to the AddService with the "authentication" intent set. This was my definitions file. <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://itest/policy" xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" xmlns:ip="http://itest/policy" > <sca:policySet name="BasicAuthenticationPolicySet" provides="authentication" appliesTo="sca:binding.ws"> <tuscany:basicAuthentication> <tuscany:userName>tuscanyuser</tuscany:userName> <tuscany:password>tuscanypwd</tuscany:password> </tuscany:basicAuthentication> </sca:policySet> </definitions> I tried it with both a Java implementation and a spring implementation. Here's my client component from the composite file... <component name="CalculatorServiceComponent"> <!--implementation.java class="calculator.CalculatorServiceImpl"/--> <implementation.spring location="META-INF/spring/CalculatorService-context.xml"/> <reference name="addService" > <interface.java interface="calculator.AddService" /> <binding.ws requires="authentication" uri="http://localhost:8080/sample-calculator-ws-webapp/AddServiceComponent"/> </reference> <reference name="subtractService" target="SubtractServiceComponent" /> <reference name="multiplyService" target="MultiplyServiceComponent" /> <reference name="divideService" target="DivideServiceComponent" /> </component> With the password correctly set I get.... 24-May-2010 13:50:29 org.apache.tuscany.sca.node.impl.NodeImpl <init> INFO: Creating node: Calculator.composite 24-May-2010 13:50:29 org.apache.tuscany.sca.node.impl.NodeImpl configureNode INFO: Loading contribution: file:/D:/sca-java-1.x/samples/calculator/target/classes/ 24-May-2010 13:50:30 org.apache.tuscany.sca.node.impl.NodeImpl start INFO: Starting node: Calculator.composite - Loading XML bean definitions from URL [file:/D:/sca-java-1.x/samples/calculator/target/classes/META-INF/spring/CalculatorService-context.xml] - Module validation failed: The system is attempting to engage a module that is not available: rampart - Refreshing org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387: display name [org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387]; startup date [Mon May 24 13:50:31 BST 2010]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 - Bean factory for application context [org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387]: org.springframework.beans.factory.xml.xmlbeanfact...@192d604 Spring parent context - containsBean called for name: loadTimeWeaver - Pre-instantiating singletons in org.springframework.beans.factory.xml.xmlbeanfact...@192d604: defining beans [CalculatorServiceBean]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 Spring parent context - getBean called for name: addService Spring parent context - getBean called for name: subtractService Spring parent context - getBean called for name: multiplyService Spring parent context - getBean called for name: divideService 3 + 2=5.0 3 - 2=1.0 3 * 2=6.0 3 / 2=1.5 24-May-2010 13:50:32 org.apache.tuscany.sca.node.impl.NodeImpl stop INFO: Stopping node: Calculator.composite - Closing org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387: display name [org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387]; startup date [Mon May 24 13:50:31 BST 2010]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 - Destroying singletons in org.springframework.beans.factory.xml.xmlbeanfact...@192d604: defining beans [CalculatorServiceBean]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 with the password set to "abcdefg" I get... 24-May-2010 13:45:01 org.apache.tuscany.sca.node.impl.NodeImpl <init> INFO: Creating node: Calculator.composite 24-May-2010 13:45:01 org.apache.tuscany.sca.node.impl.NodeImpl configureNode INFO: Loading contribution: file:/D:/sca-java-1.x/samples/calculator/target/classes/ 24-May-2010 13:45:02 org.apache.tuscany.sca.node.impl.NodeImpl start INFO: Starting node: Calculator.composite - Loading XML bean definitions from URL [file:/D:/sca-java-1.x/samples/calculator/target/classes/META-INF/spring/CalculatorService-context.xml] - Module validation failed: The system is attempting to engage a module that is not available: rampart - Refreshing org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387: display name [org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387]; startup date [Mon May 24 13:45:03 BST 2010]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 - Bean factory for application context [org.apache.tuscany.sca.implementation.spring.runtime.context.scagenericapplicationcont...@14a9387]: org.springframework.beans.factory.xml.xmlbeanfact...@192d604 Spring parent context - containsBean called for name: loadTimeWeaver - Pre-instantiating singletons in org.springframework.beans.factory.xml.xmlbeanfact...@192d604: defining beans [CalculatorServiceBean]; parent: org.apache.tuscany.sca.implementation.spring.runtime.context.scaparentapplicationcont...@18782a7 Spring parent context - getBean called for name: addService Spring parent context - getBean called for name: subtractService Spring parent context - getBean called for name: multiplyService Spring parent context - getBean called for name: divideService - Basic authentication scheme selected - Failure authenticating with BASIC 'Application'@localhost:8080 - Unable to sendViaPost to url[http://localhost:8080/sample-calculator-ws-webapp/AddServiceComponent] org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized So it seems to be basically working so my suspicion is turning to the WSDL you have? What style is the WSDL using, by default Tuscany is expecting to deal with Doc/Lit/Wrapped. If the external service is doing something else we'll have to look at how the WSDL is configured. Regards Simon -- Apache Tuscany committer: tuscany.apache.org Co-author of a book about Tuscany and SCA: tuscanyinaction.com
