You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/08/04 16:07:09 UTC

svn commit: r428730 - in /incubator/tuscany/java: samples/sca/helloworldws/src/main/webapp/META-INF/sca/ sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/ sca/bindings/binding.axis2/src/main/resources/META-INF/sca/ sca/core/src...

Author: rineholt
Date: Fri Aug  4 07:07:08 2006
New Revision: 428730

URL: http://svn.apache.org/viewvc?rev=428730&view=rev
Log:
TUSCANY-575
http://issues.apache.org/jira/browse/TUSCANY-575
horrible hack to read wsdl in ... will need to get back to this.
added binding builder to scdl

Modified:
    incubator/tuscany/java/samples/sca/helloworldws/src/main/webapp/META-INF/sca/default.scdl
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
    incubator/tuscany/java/sca/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
    incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java

Modified: incubator/tuscany/java/samples/sca/helloworldws/src/main/webapp/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/helloworldws/src/main/webapp/META-INF/sca/default.scdl?rev=428730&r1=428729&r2=428730&view=diff
==============================================================================
--- incubator/tuscany/java/samples/sca/helloworldws/src/main/webapp/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/samples/sca/helloworldws/src/main/webapp/META-INF/sca/default.scdl Fri Aug  4 07:07:08 2006
@@ -16,10 +16,19 @@
  -->
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="helloworldws">
 
-    <service name="HelloWorldWebService">
-        <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)"/>
-        <binding.ws port="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"/>
-        <reference>HelloWorldServiceComponent/HelloWorldService</reference>
+    <service name="HelloWorldWebService"  target="http:///foo">
+        <!-- interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)"/ -->
+        <interface.java interface="helloworld.HelloWorldService"/>
+
+
+<!--FIXME the location attribute is a really bad hack here!  does not follow to spec at all 
+-->
+      <binding.ws endpoint="http://helloworld#wsdl.endpoint(HelloWorldService/HelloWorldSoapPort)"
+          conformanceURIs="http://ws-i.org/profiles/basic/1.1"
+          location="wsdl/helloworld.wsdl"
+         />
+
+        <reference>HelloWorldServiceComponent</reference>
     </service>
 
     <component name="HelloWorldServiceComponent">

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java?rev=428730&r1=428729&r2=428730&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java Fri Aug  4 07:07:08 2006
@@ -171,6 +171,7 @@
         return new DummyServletConfig();
     }
 
+
     private class DummyServletConfig implements ServletConfig {
 
         public String getServletName() {

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java?rev=428730&r1=428729&r2=428730&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/WebServiceBindingLoader.java Fri Aug  4 07:07:08 2006
@@ -16,19 +16,24 @@
  */
 package org.apache.tuscany.binding.axis2;
 
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
 
+import java.io.IOException;
+import java.net.URL;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.List;
+
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
-import org.osoa.sca.annotations.Scope;
-
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
@@ -36,11 +41,12 @@
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
 import org.apache.tuscany.spi.services.wsdl.WSDLDefinitionRegistry;
-
+import org.osoa.sca.annotations.Scope;
+import org.xml.sax.InputSource;
 
 /**
  * Parses a <code>WebServiceBinding</code> entry in an assembly XML file
- *
+ * 
  * @version $Rev$ $Date$
  */
 @Scope("MODULE")
@@ -49,8 +55,14 @@
 
     protected WSDLDefinitionRegistry wsdlRegistry;
 
-    public WebServiceBindingLoader(@Autowire LoaderRegistry registry,
-                                   @Autowire WSDLDefinitionRegistry wsdlRegistry) {
+    private String wsdlLocation;
+
+    private String endpointAttribute;
+
+ 
+    public WebServiceBindingLoader(@Autowire
+    LoaderRegistry registry, @Autowire
+    WSDLDefinitionRegistry wsdlRegistry) {
         super(registry);
         this.wsdlRegistry = wsdlRegistry;
     }
@@ -60,22 +72,29 @@
     }
 
     public WebServiceBinding load(CompositeComponent parent, XMLStreamReader reader,
-                                  DeploymentContext deploymentContext
-    ) throws XMLStreamException, LoaderException {
-        String uri = reader.getAttributeValue(null, "uri");
-        String portURI = reader.getAttributeValue(null, "port");
-        return createBinding(uri, portURI);
+            DeploymentContext deploymentContext) throws XMLStreamException,
+            LoaderException {
+        // not sure what uri was here ? String uri = reader.getAttributeValue(null, "uri");
+        String uri = null;
+        endpointAttribute = reader.getAttributeValue(null, "endpoint");
+        wsdlLocation = reader.getAttributeValue(null, "location");
+        try {
+            return createBinding(uri, endpointAttribute);
+        } catch (Exception e) {
+
+            throw new LoaderException(e);
+        }
     }
 
     @SuppressWarnings("unchecked")
-    private WebServiceBinding createBinding(String port, String portURI) {
+    private WebServiceBinding createBinding(String port, String portURI) throws WSDLException, IOException {
         List<Definition> definitions = null;
         // FIXME wsdlRegistry.getDefinitionsForNamespace(portNamespace,
         // resourceLoader);
         // Get the WSDL port namespace and name
         if (port == null && portURI != null) {
             int h = portURI.indexOf('#');
-            String portNamespace = portURI.substring(0, h);
+ //           String portNamespace = portURI.substring(0, h);
             String serviceName;
             String portName;
 
@@ -94,11 +113,17 @@
                 serviceName = null;
                 portName = fragment;
             }
+            // FIXME need to find out how to get wsdl and what context to use --- terrible hack attack!
+            URL wsdlurl = Thread.currentThread().getContextClassLoader().getResource(wsdlLocation);
+            WSDLFactory factory = WSDLFactory.newInstance();
+            WSDLReader reader = factory.newWSDLReader();
+            reader.setFeature("javax.wsdl.verbose", false);
+            InputSource input = new InputSource(wsdlurl.openStream());
+            Definition wsdlDef = reader.readWSDL(wsdlurl.toString(), input);
+            definitions = new LinkedList<Definition>();
+            definitions.add(wsdlDef);
+            // FIXME all the above needs to better addressed.
 
-            // FIXME definitions is always null
-            if (definitions == null) {
-                throw new IllegalArgumentException("Cannot find WSDL definition for " + portNamespace);
-            }
             Definition definition = null;
             Port thePort = null;
             Service service = null;
@@ -107,8 +132,7 @@
                 // Find the port with the given name
                 for (Service serv : (Collection<Service>) def.getServices().values()) {
                     QName sqn = serv.getQName();
-                    if (serviceName != null
-                        && !serviceName.equals(sqn.getLocalPart())) {
+                    if (serviceName != null && !serviceName.equals(sqn.getLocalPart())) {
                         continue;
                     }
 
@@ -131,4 +155,5 @@
         return null;
 
     }
+
 }

Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl?rev=428730&r1=428729&r2=428730&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/resources/META-INF/sca/default.scdl Fri Aug  4 07:07:08 2006
@@ -23,4 +23,10 @@
         <system:implementation.system class="org.apache.tuscany.binding.axis2.WebServiceBindingLoader"/>
     </component>
 
+ <component name="ws.componentBuilder">
+    <system:implementation.system class="org.apache.tuscany.binding.axis2.Axis2BindingBuilder"/>
+ </component>
+
+
+
 </composite>

Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java?rev=428730&r1=428729&r2=428730&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java Fri Aug  4 07:07:08 2006
@@ -17,6 +17,7 @@
 package org.apache.tuscany.core.services.artifact;
 
 import java.io.File;
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
 
@@ -42,11 +43,11 @@
         assertEquals("org/apache/tuscany/spi/1.0-SNAPSHOT/spi-1.0-SNAPSHOT-x86.jar", repo.getPath(artifact));
     }
 
-    public void testArtifactFoundInRepo() throws MalformedURLException {
+    public void testArtifactFoundInRepo() throws MalformedURLException, UnsupportedEncodingException {
         String home = System.getProperty("user.home");
         File file = new File(home, ".m2/repository/org/apache/tuscany/spi/1.0-SNAPSHOT/spi-1.0-SNAPSHOT.jar");
         repo.resolve(artifact);
-        assertEquals(file.toURL(), artifact.getUrl());
+        assertEquals(file.toURL().toString(), java.net.URLDecoder.decode(artifact.getUrl().toString(), "UTF-8"));
     }
 
     public void testArtifactNotFoundInRepo() throws MalformedURLException {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


URL escaping, was: svn commit: r428730 - in /incubator/tuscany/java: samples/sca/helloworldws/src/main/webapp/META-INF/sca/ sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/ sca/bindings/binding.axis2/src/main/resources/META-INF/sca/ sca/core/src...

Posted by Jeremy Boynes <jb...@apache.org>.
Rick

Not sure if you meant to commit this as part of this change - it  
wasn't mentioned in the commit message at all.

Jervis,

Another way to handle spaces in the URL which might be a little  
simpler is:

Index: core/src/test/java/org/apache/tuscany/core/services/artifact/ 
LocalMavenRepositoryTestCase.java
===================================================================
--- core/src/test/java/org/apache/tuscany/core/services/artifact/ 
LocalMavenRepositoryTestCase.java      (revision 428735)
+++ core/src/test/java/org/apache/tuscany/core/services/artifact/ 
LocalMavenRepositoryTestCase.java      (working copy)
@@ -17,7 +17,6 @@
package org.apache.tuscany.core.services.artifact;
import java.io.File;
-import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -27,7 +26,7 @@
/**
   * This testcase assumes that there is a maven repo in the default  
location.
- *
+ *
   * @version $Rev$ $Date$
   */
public class LocalMavenRepositoryTestCase extends TestCase {
@@ -43,11 +42,11 @@
          assertEquals("org/apache/tuscany/spi/1.0-SNAPSHOT/spi-1.0- 
SNAPSHOT-x86.jar", repo.getPath(artifact));
      }
-    public void testArtifactFoundInRepo() throws  
MalformedURLException, UnsupportedEncodingException {
+    public void testArtifactFoundInRepo() throws  
MalformedURLException {
          String home = System.getProperty("user.home");
          File file = new File(home, ".m2/repository/org/apache/ 
tuscany/spi/1.0-SNAPSHOT/spi-1.0-SNAPSHOT.jar");
          repo.resolve(artifact);
-        assertEquals(file.toURL().toString(),  
java.net.URLDecoder.decode(artifact.getUrl().toString(), "UTF-8"));
+        assertEquals(file.toURI().toURL(), artifact.getUrl());
      }
      public void testArtifactNotFoundInRepo() throws  
MalformedURLException {


--
Jeremy

On Aug 4, 2006, at 7:07 AM, rineholt@apache.org wrote:
> Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/ 
> tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/ 
> src/test/java/org/apache/tuscany/core/services/artifact/ 
> LocalMavenRepositoryTestCase.java? 
> rev=428730&r1=428729&r2=428730&view=diff
> ====================================================================== 
> ========
> --- incubator/tuscany/java/sca/core/src/test/java/org/apache/ 
> tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java  
> (original)
> +++ incubator/tuscany/java/sca/core/src/test/java/org/apache/ 
> tuscany/core/services/artifact/LocalMavenRepositoryTestCase.java  
> Fri Aug  4 07:07:08 2006
> @@ -17,6 +17,7 @@
>  package org.apache.tuscany.core.services.artifact;
>
>  import java.io.File;
> +import java.io.UnsupportedEncodingException;
>  import java.net.MalformedURLException;
>  import java.net.URL;
>
> @@ -42,11 +43,11 @@
>          assertEquals("org/apache/tuscany/spi/1.0-SNAPSHOT/spi-1.0- 
> SNAPSHOT-x86.jar", repo.getPath(artifact));
>      }
>
> -    public void testArtifactFoundInRepo() throws  
> MalformedURLException {
> +    public void testArtifactFoundInRepo() throws  
> MalformedURLException, UnsupportedEncodingException {
>          String home = System.getProperty("user.home");
>          File file = new File(home, ".m2/repository/org/apache/ 
> tuscany/spi/1.0-SNAPSHOT/spi-1.0-SNAPSHOT.jar");
>          repo.resolve(artifact);
> -        assertEquals(file.toURL(), artifact.getUrl());
> +        assertEquals(file.toURL().toString(),  
> java.net.URLDecoder.decode(artifact.getUrl().toString(), "UTF-8"));
>      }
>
>      public void testArtifactNotFoundInRepo() throws  
> MalformedURLException {

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org