tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r575335 - in /incubator/tuscany/java/sca/modules/binding-ws-axis2/src: main/java/org/apache/tuscany/sca/binding/ws/axis2/ test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/ test/resources/org/apache/tuscany/sca/binding/ws/axis2/i...
Date Thu, 13 Sep 2007 15:39:21 GMT
Author: antelder
Date: Thu Sep 13 08:39:20 2007
New Revision: 575335

URL: http://svn.apache.org/viewvc?rev=575335&view=rev
Log:
Start getting binding.ws wsa epr's used 

Added:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
  (with props)
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite
Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java?rev=575335&r1=575334&r2=575335&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
Thu Sep 13 08:39:20 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.tuscany.sca.binding.ws.axis2;
 
+import java.io.IOException;
 import java.util.List;
 
 import javax.wsdl.Binding;
@@ -28,11 +29,19 @@
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
 
 import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -143,7 +152,7 @@
      */
     protected Invoker createInvoker(Operation operation) {
         Options options = new Options();
-        EndpointReference epTo = getPortLocationEPR(wsBinding);
+        EndpointReference epTo = getWSATOEPR(wsBinding);
         if (epTo != null) {
             options.setTo(epTo);
         }
@@ -182,6 +191,19 @@
         return false;
     }
 
+    protected EndpointReference getWSATOEPR(WebServiceBinding binding) {
+        EndpointReference epr = getEPR(binding);
+        if (epr == null) {
+            epr = getPortLocationEPR(binding);
+        } else if (epr.getAddress() == null) {
+            EndpointReference bindingEPR = getPortLocationEPR(binding);
+            if (bindingEPR != null) {
+                epr.setAddress(bindingEPR.getAddress());
+            }
+        }
+        return epr;
+    }
+
     protected EndpointReference getPortLocationEPR(WebServiceBinding binding) {
         String ep = binding.getURI();
         if (ep == null && binding.getPort() != null) {
@@ -194,6 +216,27 @@
             }
         }
         return ep != null ? new EndpointReference(ep) : null;
+    }
+
+    protected org.apache.axis2.addressing.EndpointReference getEPR(WebServiceBinding wsBinding)
{
+        if (wsBinding.getEndPointReference() == null) {
+            return null;
+        }
+        try {
+
+            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new
DOMSource(wsBinding.getEndPointReference()));
+            StAXOMBuilder builder = new StAXOMBuilder(parser);
+            OMElement omElement = builder.getDocumentElement();
+            org.apache.axis2.addressing.EndpointReference epr = EndpointReferenceHelper.fromOM(omElement);
+            return epr;
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        } catch (FactoryConfigurationError e) {
+            throw new RuntimeException(e);
+        }
     }
 
     protected String getSOAPAction(String operationName) {

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java?rev=575335&r1=575334&r2=575335&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
Thu Sep 13 08:39:20 2007
@@ -221,19 +221,28 @@
         
         // either there is no wsdl port endpoint URI or that URI is relative
 
-        URI bindingURI = URI.create(wsBinding.getURI());
-        if (bindingURI.isAbsolute()) {
-            // there is an absoulte uri specified on the binding: <binding.ws uri="xxx"
-            if (wsdlURI != null) {
-                // there is a relative URI in the wsdl port
-                return URI.create(bindingURI + "/" + wsdlURI);
-            } else {
-                return bindingURI;
+        URI completeURI;
+        if (wsBinding.getURI() != null) {
+            completeURI = URI.create(wsBinding.getURI());
+            if (!completeURI.isAbsolute()) {
+                completeURI = URI.create(baseURI + "/" + wsBinding.getURI());
             }
         } else {
-            bindingURI = URI.create(baseURI + "/" + wsBinding.getURI());
-            return bindingURI;
+            completeURI = URI.create(baseURI + "/" + wsBinding.getName());
         }
+        
+        if (eprURI != null) {
+            // there is a relative URI in the binding EPR
+            completeURI = URI.create(completeURI + "/" + eprURI);
+        }
+
+        if (wsdlURI != null) {
+            // there is a relative URI in the wsdl port
+            completeURI = URI.create(completeURI + "/" + wsdlURI);
+        }
+        
+        return completeURI;
+
     }
 
     private org.apache.axis2.addressing.EndpointReference getEPR() {

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java?rev=575335&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
(added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
Thu Sep 13 08:39:20 2007
@@ -0,0 +1,47 @@
+/*
+ * 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.binding.ws.axis2.itests.epr;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorld;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class HelloWorldTestCase extends TestCase {
+
+    private SCADomain domain;
+    private HelloWorld helloWorld;
+
+    public void testCalculator() throws Exception {
+        assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite");
+        helloWorld = domain.getService(HelloWorld.class, "HelloWorldComponent");
+    }
+    
+    @Override
+    protected void tearDown() throws Exception {
+        domain.close();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite?rev=575335&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite
(added)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite
Thu Sep 13 08:39:20 2007
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+
+           name="HelloWorld">
+
+    <service name="helloWorld" promote="HelloWorldService">
+        <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+        <binding.ws>
+           <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+              <wsa:Address>http://localhost:8085/myService</wsa:Address>
+           </wsa:EndpointReference>
+        </binding.ws>
+    </service>
+
+    <component name="HelloWorldService">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+    </component>
+
+    <component name="HelloWorldComponent">
+		<implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+        <reference name="helloWorldWS" />
+    </component>
+
+    <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
+        <binding.ws>
+           <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+              <wsa:Address>http://localhost:8085/myService</wsa:Address>
+           </wsa:EndpointReference>
+        </binding.ws>
+    </reference>
+
+</composite>



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


Mime
View raw message