You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2011/07/26 20:38:47 UTC

svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Author: antelder
Date: Tue Jul 26 18:38:46 2011
New Revision: 1151203

URL: http://svn.apache.org/viewvc?rev=1151203&view=rev
Log:
Add some code to try to convert the wsdl string from the remote endpoint back into a WSDLInterfaceContract. This doesn't work properly and throws an InvalidWSDLException with some JDKs. Committing as-is to see if anyone has any ideas why

Added:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Tue Jul 26 18:38:46 2011
@@ -31,9 +31,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.xml.WSDLReader;
 import javax.wsdl.xml.WSDLWriter;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -82,7 +79,6 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
 import org.apache.tuscany.sca.invocation.Interceptor;
@@ -115,7 +111,6 @@ import org.apache.tuscany.sca.runtime.Ru
 import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
 import org.apache.tuscany.sca.work.WorkScheduler;
 import org.oasisopen.sca.ServiceRuntimeException;
-import org.xml.sax.InputSource;
 
 /**
  * Runtime model for Endpoint that supports java serialization
@@ -1067,24 +1062,12 @@ public class RuntimeEndpointImpl extends
         if (wsdl == null || wsdl.length() < 1) {
             return;
         }
-        try {
-            InterfaceContract ic = getComponentServiceInterfaceContract();
-            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
-            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
-            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
-            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
-            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
-            InputSource inputSource = new InputSource(new StringReader(wsdl));
-            Definition def = reader.readWSDL("", inputSource);
-            wsdlDef.setDefinition(def);
-            wsdlIface.setWsdlDefinition(wsdlDef);
-            wsdlIC.setInterface(wsdlIface);
-            ic.setNormalizedWSDLContract(wsdlIC);
-        } catch (WSDLException e) {
-            throw new RuntimeException(e);
+        InterfaceContract ic = getComponentServiceInterfaceContract();
+        if (ic != null) {
+            ic.setNormalizedWSDLContract(WSDLHelper.createWSDLInterfaceContract(registry, wsdl));
         }
     }
-    
+
     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
 
         if ( interfaceContract.getNormalizedWSDLContract() == null){

Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1151203&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java Tue Jul 26 18:38:46 2011
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.core.assembly.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URI;
+
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException;
+
+public class WSDLHelper {
+
+    /**
+     * This creates a WSDLInterfaceContract from a WSDL document
+     * TODO: Presently this writes the wsdl string to a temporary file which is then used by the Tuscany contribution
+     * code to turn the wsdl into the correctly populated Tuscany model objects. There must/should be a way to have
+     * that happen without needing the external file but i've not been able to find the correct configuration to 
+     * get that to happen with all the schema objects created correctly. 
+     */
+    public static WSDLInterfaceContract createWSDLInterfaceContract(ExtensionPointRegistry registry, String wsdl) {
+        File wsdlFile = null;
+        try {
+            
+            wsdlFile = writeToFile(wsdl);
+            System.out.println("wsdl: " + wsdlFile);
+
+            FactoryExtensionPoint fep = registry.getExtensionPoint(FactoryExtensionPoint.class);
+            URLArtifactProcessorExtensionPoint apep = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+            ExtensibleURLArtifactProcessor aproc = new ExtensibleURLArtifactProcessor(apep);
+            ProcessorContext ctx = new ProcessorContext();
+            
+            ContributionFactory cf = fep.getFactory(ContributionFactory.class);
+            final Contribution c = cf.createContribution();
+            c.setURI("temp");
+            c.setLocation(wsdlFile.toURI().toURL().toString());
+            c.setModelResolver(new ExtensibleModelResolver(c, registry.getExtensionPoint(ModelResolverExtensionPoint.class), fep));
+            
+            WSDLDefinition wd = aproc.read(null, new URI("temp.wsdl"), wsdlFile.toURI().toURL(), ctx, WSDLDefinition.class);
+            c.getModelResolver().addModel(wd, ctx);
+            c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
+            PortType pt = (PortType)wd.getDefinition().getAllPortTypes().values().iterator().next();
+            
+            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
+            WSDLInterface nwi = wsdlFactory.createWSDLInterface(pt, wd, c.getModelResolver(), null);
+            nwi.setWsdlDefinition(wd);
+            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
+            wsdlIC.setInterface(nwi);
+            
+            wsdlFile.delete();
+            
+            return wsdlIC;
+
+        } catch (InvalidWSDLException e) {
+            //* TODO: Also, this doesn't seem to work reliably and sometimes the schema objects don't get built correctly
+            //* org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException: Element cannot be resolved: {http://sample/}sayHello
+            //*         at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.java:276)
+            //* It seems like it works ok for me with IBM JDK but not with a Sun one        
+            // I'm still trying to track this down but committing like this to see if anyone has any ideas 
+            e.printStackTrace();
+            return null;
+        } catch(Exception e) {
+            throw new RuntimeException(e);
+        } finally {
+            if (wsdlFile != null) {
+                wsdlFile.delete();
+            }
+        }
+    }
+    
+    private static File writeToFile(String wsdl) throws FileNotFoundException, IOException {
+        File f = File.createTempFile("endpoint", ".wsdl");
+        Writer out = new OutputStreamWriter(new FileOutputStream(f));
+        try {
+          out.write(wsdl);
+        }
+        finally {
+          out.close();
+        }
+        return f;
+    }
+}

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Tue Jul 26 18:38:46 2011
@@ -915,9 +915,9 @@ public class EndpointReferenceBinderImpl
             return true;
         }
         
-        // TODO - is there a better test for this. Would have to cast to the
-        //        correct iface type to get to the resolved flag
-        //        We need to rely on normailzed interfaces in this case!!
+//        // TODO - is there a better test for this. Would have to cast to the
+//        //        correct iface type to get to the resolved flag
+//        //        We need to rely on normailzed interfaces in this case!!
         if (endpointContract.getInterface().getOperations().size() == 0){
             // the interface contract is likely remote but unresolved
             // we discussed this on the ML and decided that we could



Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
Hi

I've checked in modified code (see TUSCANY-3916) to deal with
imports/includes. This doesn't use the file based approach but may be
slightly different from the code you had originally. Can you give it a
spin on the JVM/OS combination where you saw failures and see if this
is any better. I haven't addressed the issue directly so it may or may
not be an improvement just by chance.

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
On Wed, Aug 10, 2011 at 10:01 AM, ant elder <an...@apache.org> wrote:
> On Wed, Aug 10, 2011 at 9:51 AM, Simon Laws <si...@googlemail.com> wrote:
>> snip...
>>
>>> org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException:
>>> Element cannot be resolved: {http://sample/}sayHello
>>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.
>>> java:276)
>>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getMessageType(WSDLOperationIntrospectorImpl.j
>>> ava:194)
>>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getInputType(WSDLOperationIntrospectorImpl.jav
>>
>>
>> Ok, so I guess I was just lucky. The particular error could be caused
>> by any number of things, e.g. the XML/XSD implementation varies
>> slightly or even some other difference is causing imports/includes to
>> be processed differently. My preference would be to do the refactoring
>> to get rid of the intermediate file and to process includes/imports
>> properly and see if the result still exhibits this JVM/Maven
>> dependency error.
>>
>
> It does still have the same error. I initially coded it without the
> intermediate file and only added this clunky file based dummy
> contribution approach to try to make the code work as closely as
> possible to the Tuscany file based contribution processing to see if
> the problem was being caused by my code.
>
>   ...ant
>

Do you have the original non-file based code to save me re-creating it?

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by ant elder <an...@apache.org>.
On Wed, Aug 10, 2011 at 9:51 AM, Simon Laws <si...@googlemail.com> wrote:
> snip...
>
>> org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException:
>> Element cannot be resolved: {http://sample/}sayHello
>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.
>> java:276)
>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getMessageType(WSDLOperationIntrospectorImpl.j
>> ava:194)
>>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getInputType(WSDLOperationIntrospectorImpl.jav
>
>
> Ok, so I guess I was just lucky. The particular error could be caused
> by any number of things, e.g. the XML/XSD implementation varies
> slightly or even some other difference is causing imports/includes to
> be processed differently. My preference would be to do the refactoring
> to get rid of the intermediate file and to process includes/imports
> properly and see if the result still exhibits this JVM/Maven
> dependency error.
>

It does still have the same error. I initially coded it without the
intermediate file and only added this clunky file based dummy
contribution approach to try to make the code work as closely as
possible to the Tuscany file based contribution processing to see if
the problem was being caused by my code.

   ...ant

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
snip...

> org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException:
> Element cannot be resolved: {http://sample/}sayHello
>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.
> java:276)
>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getMessageType(WSDLOperationIntrospectorImpl.j
> ava:194)
>        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getInputType(WSDLOperationIntrospectorImpl.jav


Ok, so I guess I was just lucky. The particular error could be caused
by any number of things, e.g. the XML/XSD implementation varies
slightly or even some other difference is causing imports/includes to
be processed differently. My preference would be to do the refactoring
to get rid of the intermediate file and to process includes/imports
properly and see if the result still exhibits this JVM/Maven
dependency error.

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by ant elder <an...@apache.org>.
On Tue, Aug 9, 2011 at 4:00 PM, Simon Laws <si...@googlemail.com> wrote:
> snip...
>>
>> Yes its that code which isn't working correctly. For example if you
>> run something like the helloworld-scaclient testcase you should see an
>> exception InvalidWSDLException: Element cannot be resolved:
>> {http://sample/}sayHello. (The test does pass successfully even with
>> that exception as the remote interface validataion code isn't enabled
>> yet).
>>
>>   ...ant
>>
>
> I'm on:
>
> java version "1.6.0_26"
> Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
>
> and see:
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running sample.HelloworldTestCase
> 09-Aug-2011 15:58:22 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
> gistry initHazelcastInstance
> INFO: started node in domain 'default' + at: /127.0.0.1:7654
> 09-Aug-2011 15:58:22 org.apache.tuscany.sca.impl.NodeImpl <init>
> INFO: domain: default
> 09-Aug-2011 15:58:23 org.apache.tuscany.sca.impl.NodeImpl installContribution
> INFO: installContribution: helloworld
> 09-Aug-2011 15:58:23 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
> gistry addEndpoint
> INFO: Add endpoint - (@106030716)Endpoint:  URI = HelloworldComponent#service-bi
> nding(Helloworld/Helloworld)
> 09-Aug-2011 15:58:23 org.apache.tuscany.sca.impl.NodeImpl startComposite
> INFO: startComposite: helloworld/helloworld.composite
> HelloworldSCAClient, using domainURI uri:default?wka=127.0.0.1:7654
> Calling HelloworldComponent.sayHello("world"):
> wsdl: C:\Users\slaws\AppData\Local\Temp\endpoint154063411841302205.wsdl
> wsdl: C:\Users\slaws\AppData\Local\Temp\endpoint4201080581756982322.wsdl
> Hello world
> 09-Aug-2011 15:58:24 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
> gistry removeEndpoint
> INFO: Removed endpoint - (@106030716)Endpoint:  URI = HelloworldComponent#servic
> e-binding(Helloworld/Helloworld)
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.041 sec
>
> So presumably this is a success case
>
> Simon
>

For me it gets the exception shown below when building with Maven with
both IBM and Sun JDKs and in Eclipse i see that with the Sun JDK but
the IBM one works ok. I think it was working in Maven back in July
with some combination of JDK and Maven release but i can't remember
what that combination was now, i'll try to find some time to find that
again.

   ...ant

Running sample.HelloworldTestCase
10-Aug-2011 09:20:24
org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry
initHazelcastInstance
INFO: started node in domain 'default' + at: /127.0.0.1:7654
10-Aug-2011 09:20:24 org.apache.tuscany.sca.impl.NodeImpl <init>
INFO: domain: default
10-Aug-2011 09:20:25 org.apache.tuscany.sca.impl.NodeImpl installContribution
INFO: installContribution: helloworld
10-Aug-2011 09:20:26
org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry
addEndpoint
INFO: Add endpoint - (@20859482)Endpoint:  URI =
HelloworldComponent#service-binding(Helloworld/Helloworld)
10-Aug-2011 09:20:26 org.apache.tuscany.sca.impl.NodeImpl startComposite
INFO: startComposite: helloworld/helloworld.composite
HelloworldSCAClient, using domainURI uri:default?wka=127.0.0.1:7654
Calling HelloworldComponent.sayHello("world"):
wsdl: C:\Users\IBM_AD~1\AppData\Local\Temp\endpoint2919453658669566982.wsdl
org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException:
Element cannot be resolved: {http://sample/}sayHello
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.
java:276)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getMessageType(WSDLOperationIntrospectorImpl.j
ava:194)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getInputType(WSDLOperationIntrospectorImpl.jav
a:145)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getOperation(WSDLOperationIntrospectorImpl.jav
a:214)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.getOperation(WSDLInterfaceIntrospectorImpl.jav
a:87)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.introspectOperations(WSDLInterfaceIntrospector
Impl.java:67)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.introspectPortType(WSDLInterfaceIntrospectorIm
pl.java:78)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLFactoryImpl.createWSDLInterface(WSDLFactoryImpl.java:56)
        at org.apache.tuscany.sca.core.assembly.impl.WSDLHelper.createWSDLInterfaceContract(WSDLHelper.java:80)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.setNormalizedWSDLContract(RuntimeEndpointImpl.java:1067)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.resolve(RuntimeEndpointImpl.java:937)
        at org.apache.tuscany.sca.assembly.impl.EndpointImpl.getComponent(EndpointImpl.java:79)
        at org.apache.tuscany.sca.client.impl.RemoteServiceInvocationHandler.createEndpointReference(RemoteServiceInvocationHandler.j
ava:175)
        at org.apache.tuscany.sca.client.impl.RemoteServiceInvocationHandler.getHandler(RemoteServiceInvocationHandler.java:152)
        at org.apache.tuscany.sca.client.impl.RemoteServiceInvocationHandler.invoke(RemoteServiceInvocationHandler.java:109)
        at $Proxy8.sayHello(Unknown Source)
        at sample.HelloworldSCAClient.main(HelloworldSCAClient.java:42)
        at sample.HelloworldTestCase.testSayHello(HelloworldTestCase.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
wsdl: C:\Users\IBM_AD~1\AppData\Local\Temp\endpoint4682113607030058420.wsdl
org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException:
Element cannot be resolved: {http://sample/}sayHello
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.
java:276)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getMessageType(WSDLOperationIntrospectorImpl.j
ava:194)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getInputType(WSDLOperationIntrospectorImpl.jav
a:145)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl.getOperation(WSDLOperationIntrospectorImpl.jav
a:214)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.getOperation(WSDLInterfaceIntrospectorImpl.jav
a:87)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.introspectOperations(WSDLInterfaceIntrospector
Impl.java:67)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLInterfaceIntrospectorImpl.introspectPortType(WSDLInterfaceIntrospectorIm
pl.java:78)
        at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLFactoryImpl.createWSDLInterface(WSDLFactoryImpl.java:56)
        at org.apache.tuscany.sca.core.assembly.impl.WSDLHelper.createWSDLInterfaceContract(WSDLHelper.java:80)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.setNormalizedWSDLContract(RuntimeEndpointImpl.java:1067)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl.resolve(RuntimeEndpointImpl.java:937)
        at org.apache.tuscany.sca.assembly.impl.EndpointImpl.getPolicySets(EndpointImpl.java:133)
        at org.apache.tuscany.sca.core.runtime.impl.EndpointReferenceBinderImpl.haveMatchingPolicy(EndpointReferenceBinderImpl.java:6
32)
        at org.apache.tuscany.sca.core.runtime.impl.EndpointReferenceBinderImpl.selectForwardEndpoint(EndpointReferenceBinderImpl.jav
a:416)
        at org.apache.tuscany.sca.core.runtime.impl.EndpointReferenceBinderImpl.bind(EndpointReferenceBinderImpl.java:262)
        at org.apache.tuscany.sca.core.runtime.impl.EndpointReferenceBinderImpl.bindRunTime(EndpointReferenceBinderImpl.java:134)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl.resolveEndpointReference(RuntimeEndpointReferenceIm
pl.java:432)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl.initInvocationChains(RuntimeEndpointReferenceImpl.j
ava:312)
        at org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl.getInvocationChains(RuntimeEndpointReferenceImpl.ja
va:204)
        at org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler.getInvocationChain(JDKInvocationHandler.java:249)
        at org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler.invoke(JDKInvocationHandler.java:106)
        at org.apache.tuscany.sca.core.invocation.impl.AsyncJDKInvocationHandler.doInvokeSync(AsyncJDKInvocationHandler.java:241)
        at org.apache.tuscany.sca.core.invocation.impl.AsyncJDKInvocationHandler.invoke(AsyncJDKInvocationHandler.java:163)
        at org.apache.tuscany.sca.client.impl.RemoteServiceInvocationHandler.invoke(RemoteServiceInvocationHandler.java:109)
        at $Proxy8.sayHello(Unknown Source)
        at sample.HelloworldSCAClient.main(HelloworldSCAClient.java:42)
        at sample.HelloworldTestCase.testSayHello(HelloworldTestCase.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Hello world
10-Aug-2011 09:20:27
org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry
removeEndpoint
INFO: Removed endpoint - (@20859482)Endpoint:  URI =
HelloworldComponent#service-binding(Helloworld/Helloworld)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.192 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
snip...
>
> Yes its that code which isn't working correctly. For example if you
> run something like the helloworld-scaclient testcase you should see an
> exception InvalidWSDLException: Element cannot be resolved:
> {http://sample/}sayHello. (The test does pass successfully even with
> that exception as the remote interface validataion code isn't enabled
> yet).
>
>   ...ant
>

I'm on:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

and see:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running sample.HelloworldTestCase
09-Aug-2011 15:58:22 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
gistry initHazelcastInstance
INFO: started node in domain 'default' + at: /127.0.0.1:7654
09-Aug-2011 15:58:22 org.apache.tuscany.sca.impl.NodeImpl <init>
INFO: domain: default
09-Aug-2011 15:58:23 org.apache.tuscany.sca.impl.NodeImpl installContribution
INFO: installContribution: helloworld
09-Aug-2011 15:58:23 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
gistry addEndpoint
INFO: Add endpoint - (@106030716)Endpoint:  URI = HelloworldComponent#service-bi
nding(Helloworld/Helloworld)
09-Aug-2011 15:58:23 org.apache.tuscany.sca.impl.NodeImpl startComposite
INFO: startComposite: helloworld/helloworld.composite
HelloworldSCAClient, using domainURI uri:default?wka=127.0.0.1:7654
Calling HelloworldComponent.sayHello("world"):
wsdl: C:\Users\slaws\AppData\Local\Temp\endpoint154063411841302205.wsdl
wsdl: C:\Users\slaws\AppData\Local\Temp\endpoint4201080581756982322.wsdl
Hello world
09-Aug-2011 15:58:24 org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRe
gistry removeEndpoint
INFO: Removed endpoint - (@106030716)Endpoint:  URI = HelloworldComponent#servic
e-binding(Helloworld/Helloworld)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.041 sec

So presumably this is a success case

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by ant elder <an...@apache.org>.
On Tue, Aug 9, 2011 at 3:20 PM, Simon Laws <si...@googlemail.com> wrote:
> On Tue, Aug 9, 2011 at 3:02 PM, ant elder <an...@gmail.com> wrote:
>> On Tue, Aug 9, 2011 at 2:50 PM, Simon Laws <si...@googlemail.com> wrote:
>>> On Tue, Jul 26, 2011 at 7:38 PM,  <an...@apache.org> wrote:
>>>> Author: antelder
>>>> Date: Tue Jul 26 18:38:46 2011
>>>> New Revision: 1151203
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1151203&view=rev
>>>> Log:
>>>> Add some code to try to convert the wsdl string from the remote endpoint back into a WSDLInterfaceContract. This doesn't work properly and throws an InvalidWSDLException with some JDKs. Committing as-is to see if anyone has any ideas why
>>>>
>>>> Added:
>>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>>>> Modified:
>>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>>>>
>>>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>>>> ==============================================================================
>>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
>>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Tue Jul 26 18:38:46 2011
>>>> @@ -31,9 +31,6 @@ import java.util.List;
>>>>  import java.util.Map;
>>>>  import java.util.concurrent.ConcurrentHashMap;
>>>>
>>>> -import javax.wsdl.Definition;
>>>> -import javax.wsdl.WSDLException;
>>>> -import javax.wsdl.xml.WSDLReader;
>>>>  import javax.wsdl.xml.WSDLWriter;
>>>>  import javax.xml.namespace.QName;
>>>>  import javax.xml.stream.XMLStreamException;
>>>> @@ -82,7 +79,6 @@ import org.apache.tuscany.sca.interfaced
>>>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
>>>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
>>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>>>> -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>>>>  import org.apache.tuscany.sca.invocation.Interceptor;
>>>> @@ -115,7 +111,6 @@ import org.apache.tuscany.sca.runtime.Ru
>>>>  import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
>>>>  import org.apache.tuscany.sca.work.WorkScheduler;
>>>>  import org.oasisopen.sca.ServiceRuntimeException;
>>>> -import org.xml.sax.InputSource;
>>>>
>>>>  /**
>>>>  * Runtime model for Endpoint that supports java serialization
>>>> @@ -1067,24 +1062,12 @@ public class RuntimeEndpointImpl extends
>>>>         if (wsdl == null || wsdl.length() < 1) {
>>>>             return;
>>>>         }
>>>> -        try {
>>>> -            InterfaceContract ic = getComponentServiceInterfaceContract();
>>>> -            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>>>> -            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>>>> -            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
>>>> -            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
>>>> -            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
>>>> -            InputSource inputSource = new InputSource(new StringReader(wsdl));
>>>> -            Definition def = reader.readWSDL("", inputSource);
>>>> -            wsdlDef.setDefinition(def);
>>>> -            wsdlIface.setWsdlDefinition(wsdlDef);
>>>> -            wsdlIC.setInterface(wsdlIface);
>>>> -            ic.setNormalizedWSDLContract(wsdlIC);
>>>> -        } catch (WSDLException e) {
>>>> -            throw new RuntimeException(e);
>>>> +        InterfaceContract ic = getComponentServiceInterfaceContract();
>>>> +        if (ic != null) {
>>>> +            ic.setNormalizedWSDLContract(WSDLHelper.createWSDLInterfaceContract(registry, wsdl));
>>>>         }
>>>>     }
>>>> -
>>>> +
>>>>     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
>>>>
>>>>         if ( interfaceContract.getNormalizedWSDLContract() == null){
>>>>
>>>> Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1151203&view=auto
>>>> ==============================================================================
>>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java (added)
>>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java Tue Jul 26 18:38:46 2011
>>>> @@ -0,0 +1,117 @@
>>>> +/*
>>>> + * Licensed to the Apache Software Foundation (ASF) under one
>>>> + * or more contributor license agreements.  See the NOTICE file
>>>> + * distributed with this work for additional information
>>>> + * regarding copyright ownership.  The ASF licenses this file
>>>> + * to you under the Apache License, Version 2.0 (the
>>>> + * "License"); you may not use this file except in compliance
>>>> + * with the License.  You may obtain a copy of the License at
>>>> + *
>>>> + *   http://www.apache.org/licenses/LICENSE-2.0
>>>> + *
>>>> + * Unless required by applicable law or agreed to in writing,
>>>> + * software distributed under the License is distributed on an
>>>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>>>> + * KIND, either express or implied.  See the License for the
>>>> + * specific language governing permissions and limitations
>>>> + * under the License.
>>>> + */
>>>> +
>>>> +package org.apache.tuscany.sca.core.assembly.impl;
>>>> +
>>>> +import java.io.File;
>>>> +import java.io.FileNotFoundException;
>>>> +import java.io.FileOutputStream;
>>>> +import java.io.IOException;
>>>> +import java.io.OutputStreamWriter;
>>>> +import java.io.Writer;
>>>> +import java.net.URI;
>>>> +
>>>> +import javax.wsdl.PortType;
>>>> +
>>>> +import org.apache.tuscany.sca.contribution.Contribution;
>>>> +import org.apache.tuscany.sca.contribution.ContributionFactory;
>>>> +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
>>>> +import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
>>>> +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
>>>> +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
>>>> +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
>>>> +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
>>>> +import org.apache.tuscany.sca.core.FactoryExtensionPoint;
>>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>>>> +import org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException;
>>>> +
>>>> +public class WSDLHelper {
>>>> +
>>>> +    /**
>>>> +     * This creates a WSDLInterfaceContract from a WSDL document
>>>> +     * TODO: Presently this writes the wsdl string to a temporary file which is then used by the Tuscany contribution
>>>> +     * code to turn the wsdl into the correctly populated Tuscany model objects. There must/should be a way to have
>>>> +     * that happen without needing the external file but i've not been able to find the correct configuration to
>>>> +     * get that to happen with all the schema objects created correctly.
>>>> +     */
>>>> +    public static WSDLInterfaceContract createWSDLInterfaceContract(ExtensionPointRegistry registry, String wsdl) {
>>>> +        File wsdlFile = null;
>>>> +        try {
>>>> +
>>>> +            wsdlFile = writeToFile(wsdl);
>>>> +            System.out.println("wsdl: " + wsdlFile);
>>>> +
>>>> +            FactoryExtensionPoint fep = registry.getExtensionPoint(FactoryExtensionPoint.class);
>>>> +            URLArtifactProcessorExtensionPoint apep = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
>>>> +            ExtensibleURLArtifactProcessor aproc = new ExtensibleURLArtifactProcessor(apep);
>>>> +            ProcessorContext ctx = new ProcessorContext();
>>>> +
>>>> +            ContributionFactory cf = fep.getFactory(ContributionFactory.class);
>>>> +            final Contribution c = cf.createContribution();
>>>> +            c.setURI("temp");
>>>> +            c.setLocation(wsdlFile.toURI().toURL().toString());
>>>> +            c.setModelResolver(new ExtensibleModelResolver(c, registry.getExtensionPoint(ModelResolverExtensionPoint.class), fep));
>>>> +
>>>> +            WSDLDefinition wd = aproc.read(null, new URI("temp.wsdl"), wsdlFile.toURI().toURL(), ctx, WSDLDefinition.class);
>>>> +            c.getModelResolver().addModel(wd, ctx);
>>>> +            c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
>>>> +            PortType pt = (PortType)wd.getDefinition().getAllPortTypes().values().iterator().next();
>>>> +
>>>> +            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>>>> +            WSDLInterface nwi = wsdlFactory.createWSDLInterface(pt, wd, c.getModelResolver(), null);
>>>> +            nwi.setWsdlDefinition(wd);
>>>> +            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>>>> +            wsdlIC.setInterface(nwi);
>>>> +
>>>> +            wsdlFile.delete();
>>>> +
>>>> +            return wsdlIC;
>>>> +
>>>> +        } catch (InvalidWSDLException e) {
>>>> +            //* TODO: Also, this doesn't seem to work reliably and sometimes the schema objects don't get built correctly
>>>> +            //* org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException: Element cannot be resolved: {http://sample/}sayHello
>>>> +            //*         at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.java:276)
>>>> +            //* It seems like it works ok for me with IBM JDK but not with a Sun one
>>>> +            // I'm still trying to track this down but committing like this to see if anyone has any ideas
>>>> +            e.printStackTrace();
>>>> +            return null;
>>>> +        } catch(Exception e) {
>>>> +            throw new RuntimeException(e);
>>>> +        } finally {
>>>> +            if (wsdlFile != null) {
>>>> +                wsdlFile.delete();
>>>> +            }
>>>> +        }
>>>> +    }
>>>> +
>>>> +    private static File writeToFile(String wsdl) throws FileNotFoundException, IOException {
>>>> +        File f = File.createTempFile("endpoint", ".wsdl");
>>>> +        Writer out = new OutputStreamWriter(new FileOutputStream(f));
>>>> +        try {
>>>> +          out.write(wsdl);
>>>> +        }
>>>> +        finally {
>>>> +          out.close();
>>>> +        }
>>>> +        return f;
>>>> +    }
>>>> +}
>>>>
>>>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>>>> ==============================================================================
>>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
>>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Tue Jul 26 18:38:46 2011
>>>> @@ -915,9 +915,9 @@ public class EndpointReferenceBinderImpl
>>>>             return true;
>>>>         }
>>>>
>>>> -        // TODO - is there a better test for this. Would have to cast to the
>>>> -        //        correct iface type to get to the resolved flag
>>>> -        //        We need to rely on normailzed interfaces in this case!!
>>>> +//        // TODO - is there a better test for this. Would have to cast to the
>>>> +//        //        correct iface type to get to the resolved flag
>>>> +//        //        We need to rely on normailzed interfaces in this case!!
>>>>         if (endpointContract.getInterface().getOperations().size() == 0){
>>>>             // the interface contract is likely remote but unresolved
>>>>             // we discussed this on the ML and decided that we could
>>>>
>>>>
>>>>
>>>
>>> Ant
>>>
>>> Have been looking into this and I have a concern about writing the
>>> WSDL as is as WSDL4J as we have it configured flattens any top level
>>> includes/imports but leaves any nested includes/imports intact. These
>>> will not resolve correctly on the reference side.
>>>
>>> Now this may be a configuration issue (will look at it) but if this is
>>> just how it is we need to pass the interface information via the
>>> registry in some more complete form. An alternative would be to
>>> provide more information in the registry about which contribution owns
>>> the endpoint and hence load the artifacts directly but this is another
>>> layer of complexity which I'd avoid if possible.
>>>
>>
>> Yep imports will be an issue. As the simple case of wsdl with no
>> imports doesn't work yet though so i didn't code anything for dealing
>> with it yet.
>>
>>   ...ant
>>
>
> What was the code that you tried and which failed? I only see the code
> that writes to file and reads it back again. Or was it the case that
> the failure was happening with the code writing to/reading from file?
>

Yes its that code which isn't working correctly. For example if you
run something like the helloworld-scaclient testcase you should see an
exception InvalidWSDLException: Element cannot be resolved:
{http://sample/}sayHello. (The test does pass successfully even with
that exception as the remote interface validataion code isn't enabled
yet).

   ...ant

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
On Tue, Aug 9, 2011 at 3:02 PM, ant elder <an...@gmail.com> wrote:
> On Tue, Aug 9, 2011 at 2:50 PM, Simon Laws <si...@googlemail.com> wrote:
>> On Tue, Jul 26, 2011 at 7:38 PM,  <an...@apache.org> wrote:
>>> Author: antelder
>>> Date: Tue Jul 26 18:38:46 2011
>>> New Revision: 1151203
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1151203&view=rev
>>> Log:
>>> Add some code to try to convert the wsdl string from the remote endpoint back into a WSDLInterfaceContract. This doesn't work properly and throws an InvalidWSDLException with some JDKs. Committing as-is to see if anyone has any ideas why
>>>
>>> Added:
>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>>> Modified:
>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>>>
>>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>>> ==============================================================================
>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Tue Jul 26 18:38:46 2011
>>> @@ -31,9 +31,6 @@ import java.util.List;
>>>  import java.util.Map;
>>>  import java.util.concurrent.ConcurrentHashMap;
>>>
>>> -import javax.wsdl.Definition;
>>> -import javax.wsdl.WSDLException;
>>> -import javax.wsdl.xml.WSDLReader;
>>>  import javax.wsdl.xml.WSDLWriter;
>>>  import javax.xml.namespace.QName;
>>>  import javax.xml.stream.XMLStreamException;
>>> @@ -82,7 +79,6 @@ import org.apache.tuscany.sca.interfaced
>>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
>>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>>> -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>>>  import org.apache.tuscany.sca.invocation.Interceptor;
>>> @@ -115,7 +111,6 @@ import org.apache.tuscany.sca.runtime.Ru
>>>  import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
>>>  import org.apache.tuscany.sca.work.WorkScheduler;
>>>  import org.oasisopen.sca.ServiceRuntimeException;
>>> -import org.xml.sax.InputSource;
>>>
>>>  /**
>>>  * Runtime model for Endpoint that supports java serialization
>>> @@ -1067,24 +1062,12 @@ public class RuntimeEndpointImpl extends
>>>         if (wsdl == null || wsdl.length() < 1) {
>>>             return;
>>>         }
>>> -        try {
>>> -            InterfaceContract ic = getComponentServiceInterfaceContract();
>>> -            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>>> -            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>>> -            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
>>> -            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
>>> -            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
>>> -            InputSource inputSource = new InputSource(new StringReader(wsdl));
>>> -            Definition def = reader.readWSDL("", inputSource);
>>> -            wsdlDef.setDefinition(def);
>>> -            wsdlIface.setWsdlDefinition(wsdlDef);
>>> -            wsdlIC.setInterface(wsdlIface);
>>> -            ic.setNormalizedWSDLContract(wsdlIC);
>>> -        } catch (WSDLException e) {
>>> -            throw new RuntimeException(e);
>>> +        InterfaceContract ic = getComponentServiceInterfaceContract();
>>> +        if (ic != null) {
>>> +            ic.setNormalizedWSDLContract(WSDLHelper.createWSDLInterfaceContract(registry, wsdl));
>>>         }
>>>     }
>>> -
>>> +
>>>     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
>>>
>>>         if ( interfaceContract.getNormalizedWSDLContract() == null){
>>>
>>> Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1151203&view=auto
>>> ==============================================================================
>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java (added)
>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java Tue Jul 26 18:38:46 2011
>>> @@ -0,0 +1,117 @@
>>> +/*
>>> + * Licensed to the Apache Software Foundation (ASF) under one
>>> + * or more contributor license agreements.  See the NOTICE file
>>> + * distributed with this work for additional information
>>> + * regarding copyright ownership.  The ASF licenses this file
>>> + * to you under the Apache License, Version 2.0 (the
>>> + * "License"); you may not use this file except in compliance
>>> + * with the License.  You may obtain a copy of the License at
>>> + *
>>> + *   http://www.apache.org/licenses/LICENSE-2.0
>>> + *
>>> + * Unless required by applicable law or agreed to in writing,
>>> + * software distributed under the License is distributed on an
>>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>>> + * KIND, either express or implied.  See the License for the
>>> + * specific language governing permissions and limitations
>>> + * under the License.
>>> + */
>>> +
>>> +package org.apache.tuscany.sca.core.assembly.impl;
>>> +
>>> +import java.io.File;
>>> +import java.io.FileNotFoundException;
>>> +import java.io.FileOutputStream;
>>> +import java.io.IOException;
>>> +import java.io.OutputStreamWriter;
>>> +import java.io.Writer;
>>> +import java.net.URI;
>>> +
>>> +import javax.wsdl.PortType;
>>> +
>>> +import org.apache.tuscany.sca.contribution.Contribution;
>>> +import org.apache.tuscany.sca.contribution.ContributionFactory;
>>> +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
>>> +import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
>>> +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
>>> +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
>>> +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
>>> +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
>>> +import org.apache.tuscany.sca.core.FactoryExtensionPoint;
>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>>> +import org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException;
>>> +
>>> +public class WSDLHelper {
>>> +
>>> +    /**
>>> +     * This creates a WSDLInterfaceContract from a WSDL document
>>> +     * TODO: Presently this writes the wsdl string to a temporary file which is then used by the Tuscany contribution
>>> +     * code to turn the wsdl into the correctly populated Tuscany model objects. There must/should be a way to have
>>> +     * that happen without needing the external file but i've not been able to find the correct configuration to
>>> +     * get that to happen with all the schema objects created correctly.
>>> +     */
>>> +    public static WSDLInterfaceContract createWSDLInterfaceContract(ExtensionPointRegistry registry, String wsdl) {
>>> +        File wsdlFile = null;
>>> +        try {
>>> +
>>> +            wsdlFile = writeToFile(wsdl);
>>> +            System.out.println("wsdl: " + wsdlFile);
>>> +
>>> +            FactoryExtensionPoint fep = registry.getExtensionPoint(FactoryExtensionPoint.class);
>>> +            URLArtifactProcessorExtensionPoint apep = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
>>> +            ExtensibleURLArtifactProcessor aproc = new ExtensibleURLArtifactProcessor(apep);
>>> +            ProcessorContext ctx = new ProcessorContext();
>>> +
>>> +            ContributionFactory cf = fep.getFactory(ContributionFactory.class);
>>> +            final Contribution c = cf.createContribution();
>>> +            c.setURI("temp");
>>> +            c.setLocation(wsdlFile.toURI().toURL().toString());
>>> +            c.setModelResolver(new ExtensibleModelResolver(c, registry.getExtensionPoint(ModelResolverExtensionPoint.class), fep));
>>> +
>>> +            WSDLDefinition wd = aproc.read(null, new URI("temp.wsdl"), wsdlFile.toURI().toURL(), ctx, WSDLDefinition.class);
>>> +            c.getModelResolver().addModel(wd, ctx);
>>> +            c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
>>> +            PortType pt = (PortType)wd.getDefinition().getAllPortTypes().values().iterator().next();
>>> +
>>> +            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>>> +            WSDLInterface nwi = wsdlFactory.createWSDLInterface(pt, wd, c.getModelResolver(), null);
>>> +            nwi.setWsdlDefinition(wd);
>>> +            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>>> +            wsdlIC.setInterface(nwi);
>>> +
>>> +            wsdlFile.delete();
>>> +
>>> +            return wsdlIC;
>>> +
>>> +        } catch (InvalidWSDLException e) {
>>> +            //* TODO: Also, this doesn't seem to work reliably and sometimes the schema objects don't get built correctly
>>> +            //* org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException: Element cannot be resolved: {http://sample/}sayHello
>>> +            //*         at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.java:276)
>>> +            //* It seems like it works ok for me with IBM JDK but not with a Sun one
>>> +            // I'm still trying to track this down but committing like this to see if anyone has any ideas
>>> +            e.printStackTrace();
>>> +            return null;
>>> +        } catch(Exception e) {
>>> +            throw new RuntimeException(e);
>>> +        } finally {
>>> +            if (wsdlFile != null) {
>>> +                wsdlFile.delete();
>>> +            }
>>> +        }
>>> +    }
>>> +
>>> +    private static File writeToFile(String wsdl) throws FileNotFoundException, IOException {
>>> +        File f = File.createTempFile("endpoint", ".wsdl");
>>> +        Writer out = new OutputStreamWriter(new FileOutputStream(f));
>>> +        try {
>>> +          out.write(wsdl);
>>> +        }
>>> +        finally {
>>> +          out.close();
>>> +        }
>>> +        return f;
>>> +    }
>>> +}
>>>
>>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>>> ==============================================================================
>>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
>>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Tue Jul 26 18:38:46 2011
>>> @@ -915,9 +915,9 @@ public class EndpointReferenceBinderImpl
>>>             return true;
>>>         }
>>>
>>> -        // TODO - is there a better test for this. Would have to cast to the
>>> -        //        correct iface type to get to the resolved flag
>>> -        //        We need to rely on normailzed interfaces in this case!!
>>> +//        // TODO - is there a better test for this. Would have to cast to the
>>> +//        //        correct iface type to get to the resolved flag
>>> +//        //        We need to rely on normailzed interfaces in this case!!
>>>         if (endpointContract.getInterface().getOperations().size() == 0){
>>>             // the interface contract is likely remote but unresolved
>>>             // we discussed this on the ML and decided that we could
>>>
>>>
>>>
>>
>> Ant
>>
>> Have been looking into this and I have a concern about writing the
>> WSDL as is as WSDL4J as we have it configured flattens any top level
>> includes/imports but leaves any nested includes/imports intact. These
>> will not resolve correctly on the reference side.
>>
>> Now this may be a configuration issue (will look at it) but if this is
>> just how it is we need to pass the interface information via the
>> registry in some more complete form. An alternative would be to
>> provide more information in the registry about which contribution owns
>> the endpoint and hence load the artifacts directly but this is another
>> layer of complexity which I'd avoid if possible.
>>
>
> Yep imports will be an issue. As the simple case of wsdl with no
> imports doesn't work yet though so i didn't code anything for dealing
> with it yet.
>
>   ...ant
>

What was the code that you tried and which failed? I only see the code
that writes to file and reads it back again. Or was it the case that
the failure was happening with the code writing to/reading from file?

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by ant elder <an...@gmail.com>.
On Tue, Aug 9, 2011 at 2:50 PM, Simon Laws <si...@googlemail.com> wrote:
> On Tue, Jul 26, 2011 at 7:38 PM,  <an...@apache.org> wrote:
>> Author: antelder
>> Date: Tue Jul 26 18:38:46 2011
>> New Revision: 1151203
>>
>> URL: http://svn.apache.org/viewvc?rev=1151203&view=rev
>> Log:
>> Add some code to try to convert the wsdl string from the remote endpoint back into a WSDLInterfaceContract. This doesn't work properly and throws an InvalidWSDLException with some JDKs. Committing as-is to see if anyone has any ideas why
>>
>> Added:
>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>> Modified:
>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>>
>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>> ==============================================================================
>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Tue Jul 26 18:38:46 2011
>> @@ -31,9 +31,6 @@ import java.util.List;
>>  import java.util.Map;
>>  import java.util.concurrent.ConcurrentHashMap;
>>
>> -import javax.wsdl.Definition;
>> -import javax.wsdl.WSDLException;
>> -import javax.wsdl.xml.WSDLReader;
>>  import javax.wsdl.xml.WSDLWriter;
>>  import javax.xml.namespace.QName;
>>  import javax.xml.stream.XMLStreamException;
>> @@ -82,7 +79,6 @@ import org.apache.tuscany.sca.interfaced
>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
>>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>> -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>>  import org.apache.tuscany.sca.invocation.Interceptor;
>> @@ -115,7 +111,6 @@ import org.apache.tuscany.sca.runtime.Ru
>>  import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
>>  import org.apache.tuscany.sca.work.WorkScheduler;
>>  import org.oasisopen.sca.ServiceRuntimeException;
>> -import org.xml.sax.InputSource;
>>
>>  /**
>>  * Runtime model for Endpoint that supports java serialization
>> @@ -1067,24 +1062,12 @@ public class RuntimeEndpointImpl extends
>>         if (wsdl == null || wsdl.length() < 1) {
>>             return;
>>         }
>> -        try {
>> -            InterfaceContract ic = getComponentServiceInterfaceContract();
>> -            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>> -            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>> -            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
>> -            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
>> -            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
>> -            InputSource inputSource = new InputSource(new StringReader(wsdl));
>> -            Definition def = reader.readWSDL("", inputSource);
>> -            wsdlDef.setDefinition(def);
>> -            wsdlIface.setWsdlDefinition(wsdlDef);
>> -            wsdlIC.setInterface(wsdlIface);
>> -            ic.setNormalizedWSDLContract(wsdlIC);
>> -        } catch (WSDLException e) {
>> -            throw new RuntimeException(e);
>> +        InterfaceContract ic = getComponentServiceInterfaceContract();
>> +        if (ic != null) {
>> +            ic.setNormalizedWSDLContract(WSDLHelper.createWSDLInterfaceContract(registry, wsdl));
>>         }
>>     }
>> -
>> +
>>     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
>>
>>         if ( interfaceContract.getNormalizedWSDLContract() == null){
>>
>> Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1151203&view=auto
>> ==============================================================================
>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java (added)
>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java Tue Jul 26 18:38:46 2011
>> @@ -0,0 +1,117 @@
>> +/*
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements.  See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership.  The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License.  You may obtain a copy of the License at
>> + *
>> + *   http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied.  See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +
>> +package org.apache.tuscany.sca.core.assembly.impl;
>> +
>> +import java.io.File;
>> +import java.io.FileNotFoundException;
>> +import java.io.FileOutputStream;
>> +import java.io.IOException;
>> +import java.io.OutputStreamWriter;
>> +import java.io.Writer;
>> +import java.net.URI;
>> +
>> +import javax.wsdl.PortType;
>> +
>> +import org.apache.tuscany.sca.contribution.Contribution;
>> +import org.apache.tuscany.sca.contribution.ContributionFactory;
>> +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
>> +import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
>> +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
>> +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
>> +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
>> +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
>> +import org.apache.tuscany.sca.core.FactoryExtensionPoint;
>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>> +import org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException;
>> +
>> +public class WSDLHelper {
>> +
>> +    /**
>> +     * This creates a WSDLInterfaceContract from a WSDL document
>> +     * TODO: Presently this writes the wsdl string to a temporary file which is then used by the Tuscany contribution
>> +     * code to turn the wsdl into the correctly populated Tuscany model objects. There must/should be a way to have
>> +     * that happen without needing the external file but i've not been able to find the correct configuration to
>> +     * get that to happen with all the schema objects created correctly.
>> +     */
>> +    public static WSDLInterfaceContract createWSDLInterfaceContract(ExtensionPointRegistry registry, String wsdl) {
>> +        File wsdlFile = null;
>> +        try {
>> +
>> +            wsdlFile = writeToFile(wsdl);
>> +            System.out.println("wsdl: " + wsdlFile);
>> +
>> +            FactoryExtensionPoint fep = registry.getExtensionPoint(FactoryExtensionPoint.class);
>> +            URLArtifactProcessorExtensionPoint apep = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
>> +            ExtensibleURLArtifactProcessor aproc = new ExtensibleURLArtifactProcessor(apep);
>> +            ProcessorContext ctx = new ProcessorContext();
>> +
>> +            ContributionFactory cf = fep.getFactory(ContributionFactory.class);
>> +            final Contribution c = cf.createContribution();
>> +            c.setURI("temp");
>> +            c.setLocation(wsdlFile.toURI().toURL().toString());
>> +            c.setModelResolver(new ExtensibleModelResolver(c, registry.getExtensionPoint(ModelResolverExtensionPoint.class), fep));
>> +
>> +            WSDLDefinition wd = aproc.read(null, new URI("temp.wsdl"), wsdlFile.toURI().toURL(), ctx, WSDLDefinition.class);
>> +            c.getModelResolver().addModel(wd, ctx);
>> +            c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
>> +            PortType pt = (PortType)wd.getDefinition().getAllPortTypes().values().iterator().next();
>> +
>> +            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
>> +            WSDLInterface nwi = wsdlFactory.createWSDLInterface(pt, wd, c.getModelResolver(), null);
>> +            nwi.setWsdlDefinition(wd);
>> +            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
>> +            wsdlIC.setInterface(nwi);
>> +
>> +            wsdlFile.delete();
>> +
>> +            return wsdlIC;
>> +
>> +        } catch (InvalidWSDLException e) {
>> +            //* TODO: Also, this doesn't seem to work reliably and sometimes the schema objects don't get built correctly
>> +            //* org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException: Element cannot be resolved: {http://sample/}sayHello
>> +            //*         at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.java:276)
>> +            //* It seems like it works ok for me with IBM JDK but not with a Sun one
>> +            // I'm still trying to track this down but committing like this to see if anyone has any ideas
>> +            e.printStackTrace();
>> +            return null;
>> +        } catch(Exception e) {
>> +            throw new RuntimeException(e);
>> +        } finally {
>> +            if (wsdlFile != null) {
>> +                wsdlFile.delete();
>> +            }
>> +        }
>> +    }
>> +
>> +    private static File writeToFile(String wsdl) throws FileNotFoundException, IOException {
>> +        File f = File.createTempFile("endpoint", ".wsdl");
>> +        Writer out = new OutputStreamWriter(new FileOutputStream(f));
>> +        try {
>> +          out.write(wsdl);
>> +        }
>> +        finally {
>> +          out.close();
>> +        }
>> +        return f;
>> +    }
>> +}
>>
>> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
>> ==============================================================================
>> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
>> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Tue Jul 26 18:38:46 2011
>> @@ -915,9 +915,9 @@ public class EndpointReferenceBinderImpl
>>             return true;
>>         }
>>
>> -        // TODO - is there a better test for this. Would have to cast to the
>> -        //        correct iface type to get to the resolved flag
>> -        //        We need to rely on normailzed interfaces in this case!!
>> +//        // TODO - is there a better test for this. Would have to cast to the
>> +//        //        correct iface type to get to the resolved flag
>> +//        //        We need to rely on normailzed interfaces in this case!!
>>         if (endpointContract.getInterface().getOperations().size() == 0){
>>             // the interface contract is likely remote but unresolved
>>             // we discussed this on the ML and decided that we could
>>
>>
>>
>
> Ant
>
> Have been looking into this and I have a concern about writing the
> WSDL as is as WSDL4J as we have it configured flattens any top level
> includes/imports but leaves any nested includes/imports intact. These
> will not resolve correctly on the reference side.
>
> Now this may be a configuration issue (will look at it) but if this is
> just how it is we need to pass the interface information via the
> registry in some more complete form. An alternative would be to
> provide more information in the registry about which contribution owns
> the endpoint and hence load the artifacts directly but this is another
> layer of complexity which I'd avoid if possible.
>

Yep imports will be an issue. As the simple case of wsdl with no
imports doesn't work yet though so i didn't code anything for dealing
with it yet.

   ...ant

Re: svn commit: r1151203 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java

Posted by Simon Laws <si...@googlemail.com>.
On Tue, Jul 26, 2011 at 7:38 PM,  <an...@apache.org> wrote:
> Author: antelder
> Date: Tue Jul 26 18:38:46 2011
> New Revision: 1151203
>
> URL: http://svn.apache.org/viewvc?rev=1151203&view=rev
> Log:
> Add some code to try to convert the wsdl string from the remote endpoint back into a WSDLInterfaceContract. This doesn't work properly and throws an InvalidWSDLException with some JDKs. Committing as-is to see if anyone has any ideas why
>
> Added:
>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
> Modified:
>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
>    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
>
> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Tue Jul 26 18:38:46 2011
> @@ -31,9 +31,6 @@ import java.util.List;
>  import java.util.Map;
>  import java.util.concurrent.ConcurrentHashMap;
>
> -import javax.wsdl.Definition;
> -import javax.wsdl.WSDLException;
> -import javax.wsdl.xml.WSDLReader;
>  import javax.wsdl.xml.WSDLWriter;
>  import javax.xml.namespace.QName;
>  import javax.xml.stream.XMLStreamException;
> @@ -82,7 +79,6 @@ import org.apache.tuscany.sca.interfaced
>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
>  import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
> -import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
>  import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
>  import org.apache.tuscany.sca.invocation.Interceptor;
> @@ -115,7 +111,6 @@ import org.apache.tuscany.sca.runtime.Ru
>  import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
>  import org.apache.tuscany.sca.work.WorkScheduler;
>  import org.oasisopen.sca.ServiceRuntimeException;
> -import org.xml.sax.InputSource;
>
>  /**
>  * Runtime model for Endpoint that supports java serialization
> @@ -1067,24 +1062,12 @@ public class RuntimeEndpointImpl extends
>         if (wsdl == null || wsdl.length() < 1) {
>             return;
>         }
> -        try {
> -            InterfaceContract ic = getComponentServiceInterfaceContract();
> -            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
> -            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
> -            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
> -            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
> -            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
> -            InputSource inputSource = new InputSource(new StringReader(wsdl));
> -            Definition def = reader.readWSDL("", inputSource);
> -            wsdlDef.setDefinition(def);
> -            wsdlIface.setWsdlDefinition(wsdlDef);
> -            wsdlIC.setInterface(wsdlIface);
> -            ic.setNormalizedWSDLContract(wsdlIC);
> -        } catch (WSDLException e) {
> -            throw new RuntimeException(e);
> +        InterfaceContract ic = getComponentServiceInterfaceContract();
> +        if (ic != null) {
> +            ic.setNormalizedWSDLContract(WSDLHelper.createWSDLInterfaceContract(registry, wsdl));
>         }
>     }
> -
> +
>     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract) {
>
>         if ( interfaceContract.getNormalizedWSDLContract() == null){
>
> Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1151203&view=auto
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java (added)
> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java Tue Jul 26 18:38:46 2011
> @@ -0,0 +1,117 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +
> +package org.apache.tuscany.sca.core.assembly.impl;
> +
> +import java.io.File;
> +import java.io.FileNotFoundException;
> +import java.io.FileOutputStream;
> +import java.io.IOException;
> +import java.io.OutputStreamWriter;
> +import java.io.Writer;
> +import java.net.URI;
> +
> +import javax.wsdl.PortType;
> +
> +import org.apache.tuscany.sca.contribution.Contribution;
> +import org.apache.tuscany.sca.contribution.ContributionFactory;
> +import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
> +import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
> +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
> +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
> +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
> +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> +import org.apache.tuscany.sca.core.FactoryExtensionPoint;
> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
> +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
> +import org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException;
> +
> +public class WSDLHelper {
> +
> +    /**
> +     * This creates a WSDLInterfaceContract from a WSDL document
> +     * TODO: Presently this writes the wsdl string to a temporary file which is then used by the Tuscany contribution
> +     * code to turn the wsdl into the correctly populated Tuscany model objects. There must/should be a way to have
> +     * that happen without needing the external file but i've not been able to find the correct configuration to
> +     * get that to happen with all the schema objects created correctly.
> +     */
> +    public static WSDLInterfaceContract createWSDLInterfaceContract(ExtensionPointRegistry registry, String wsdl) {
> +        File wsdlFile = null;
> +        try {
> +
> +            wsdlFile = writeToFile(wsdl);
> +            System.out.println("wsdl: " + wsdlFile);
> +
> +            FactoryExtensionPoint fep = registry.getExtensionPoint(FactoryExtensionPoint.class);
> +            URLArtifactProcessorExtensionPoint apep = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
> +            ExtensibleURLArtifactProcessor aproc = new ExtensibleURLArtifactProcessor(apep);
> +            ProcessorContext ctx = new ProcessorContext();
> +
> +            ContributionFactory cf = fep.getFactory(ContributionFactory.class);
> +            final Contribution c = cf.createContribution();
> +            c.setURI("temp");
> +            c.setLocation(wsdlFile.toURI().toURL().toString());
> +            c.setModelResolver(new ExtensibleModelResolver(c, registry.getExtensionPoint(ModelResolverExtensionPoint.class), fep));
> +
> +            WSDLDefinition wd = aproc.read(null, new URI("temp.wsdl"), wsdlFile.toURI().toURL(), ctx, WSDLDefinition.class);
> +            c.getModelResolver().addModel(wd, ctx);
> +            c.getModelResolver().resolveModel(WSDLDefinition.class, wd, ctx);
> +            PortType pt = (PortType)wd.getDefinition().getAllPortTypes().values().iterator().next();
> +
> +            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
> +            WSDLInterface nwi = wsdlFactory.createWSDLInterface(pt, wd, c.getModelResolver(), null);
> +            nwi.setWsdlDefinition(wd);
> +            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
> +            wsdlIC.setInterface(nwi);
> +
> +            wsdlFile.delete();
> +
> +            return wsdlIC;
> +
> +        } catch (InvalidWSDLException e) {
> +            //* TODO: Also, this doesn't seem to work reliably and sometimes the schema objects don't get built correctly
> +            //* org.apache.tuscany.sca.interfacedef.wsdl.impl.InvalidWSDLException: Element cannot be resolved: {http://sample/}sayHello
> +            //*         at org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl$WSDLPart.<init>(WSDLOperationIntrospectorImpl.java:276)
> +            //* It seems like it works ok for me with IBM JDK but not with a Sun one
> +            // I'm still trying to track this down but committing like this to see if anyone has any ideas
> +            e.printStackTrace();
> +            return null;
> +        } catch(Exception e) {
> +            throw new RuntimeException(e);
> +        } finally {
> +            if (wsdlFile != null) {
> +                wsdlFile.delete();
> +            }
> +        }
> +    }
> +
> +    private static File writeToFile(String wsdl) throws FileNotFoundException, IOException {
> +        File f = File.createTempFile("endpoint", ".wsdl");
> +        Writer out = new OutputStreamWriter(new FileOutputStream(f));
> +        try {
> +          out.write(wsdl);
> +        }
> +        finally {
> +          out.close();
> +        }
> +        return f;
> +    }
> +}
>
> Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
> URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1151203&r1=1151202&r2=1151203&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
> +++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Tue Jul 26 18:38:46 2011
> @@ -915,9 +915,9 @@ public class EndpointReferenceBinderImpl
>             return true;
>         }
>
> -        // TODO - is there a better test for this. Would have to cast to the
> -        //        correct iface type to get to the resolved flag
> -        //        We need to rely on normailzed interfaces in this case!!
> +//        // TODO - is there a better test for this. Would have to cast to the
> +//        //        correct iface type to get to the resolved flag
> +//        //        We need to rely on normailzed interfaces in this case!!
>         if (endpointContract.getInterface().getOperations().size() == 0){
>             // the interface contract is likely remote but unresolved
>             // we discussed this on the ML and decided that we could
>
>
>

Ant

Have been looking into this and I have a concern about writing the
WSDL as is as WSDL4J as we have it configured flattens any top level
includes/imports but leaves any nested includes/imports intact. These
will not resolve correctly on the reference side.

Now this may be a configuration issue (will look at it) but if this is
just how it is we need to pass the interface information via the
registry in some more complete form. An alternative would be to
provide more information in the registry about which contribution owns
the endpoint and hence load the artifacts directly but this is another
layer of complexity which I'd avoid if possible.

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com