cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r601267 - in /incubator/cxf/trunk/rt: frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ frontend/jaxws/src/test/java/org/apache/cxf/j...
Date Wed, 05 Dec 2007 09:24:28 GMT
Author: jliu
Date: Wed Dec  5 01:24:27 2007
New Revision: 601267

URL: http://svn.apache.org/viewvc?rev=601267&view=rev
Log:
CXF-1214, more support on JAX-WS 2.1 EndpointReference. 

Added:
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
  (with props)
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
  (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/resources/hello_world_soap_http_infoset.xml
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Wed Dec  5 01:24:27 2007
@@ -82,6 +82,7 @@
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.workqueue.OneShotAsyncExecutor;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.VersionTransformer;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.apache.cxf.wsdl11.WSDLServiceFactory;
 
@@ -297,18 +298,23 @@
 
     public <T> T getPort(EndpointReferenceType endpointReference,
                             Class<T> type) {
+        return getPort(endpointReference, type, new WebServiceFeature[]{});
+    }    
+    
+    public <T> T getPort(EndpointReferenceType endpointReference, Class<T> type,
+                         WebServiceFeature... features) {
         endpointReference = EndpointReferenceUtils.resolve(endpointReference, bus);
         QName serviceQName = EndpointReferenceUtils.getServiceName(endpointReference);
         String portName = EndpointReferenceUtils.getPortName(endpointReference);
-        
+
         QName portQName = null;
         if (portName != null && serviceQName != null) {
             portQName = new QName(serviceQName.getNamespaceURI(), portName);
         }
-        
-        return createPort(portQName, endpointReference, type);
-    }    
 
+        return createPort(portQName, endpointReference, type, features);
+    } 
+    
     public Iterator<QName> getPorts() {
         return ports.iterator();
     }
@@ -550,9 +556,10 @@
         throw new UnsupportedOperationException();
     }
 
-    public <T> T getPort(EndpointReference endpointReference,
-                         Class<T> serviceEndpointInterface,
+    public <T> T getPort(EndpointReference endpointReference, Class<T> serviceEndpointInterface,
                          WebServiceFeature... features) {
-        throw new UnsupportedOperationException();
+        return getPort(VersionTransformer.convertToInternal(endpointReference), serviceEndpointInterface,
+                       features);
+
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
Wed Dec  5 01:24:27 2007
@@ -167,7 +167,8 @@
 
     public <T> T getPort(EndpointReference endpointReference, Class<T> serviceEndpointInterface,
                          WebServiceFeature... features) {
-        throw new UnsupportedOperationException();
+        ServiceDelegate sd = createServiceDelegate(null, null, serviceEndpointInterface);
+        return sd.getPort(endpointReference, serviceEndpointInterface, features);
     }
 
     public EndpointReference readEndpointReference(Source eprInfoset) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
Wed Dec  5 01:24:27 2007
@@ -37,9 +37,9 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.jaxws.spi.ProviderImpl;
-import org.apache.cxf.service.model.EndpointInfo;
 
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.GreeterImpl;
@@ -50,19 +50,11 @@
 
 public class EndpointReferenceTest extends AbstractJaxWsTest {
 
-    private final String address = "http://localhost:9000/SoapContext/SoapPort";
-    //private Destination d;
     private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
"SOAPService");
     private final QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapPort");
 
     @Before
     public void setUp() throws Exception {
-        super.setUpBus();
-
-        EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        ei.setAddress(address);
-
-        //d = localTransport.getDestination(ei);
     }
 
     @Test
@@ -128,8 +120,12 @@
      * WebServiceException MUST be thrown.
      */
     @Test
-    @Ignore("Not implemented yet")
     public void testServiceGetPortUsingEndpointReference() throws Exception {
+        BusFactory.setDefaultBus(getBus());
+        GreeterImpl greeter1 = new GreeterImpl();
+        EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
+        endpoint.publish("http://localhost:8080/test");
+        
         javax.xml.ws.Service s = javax.xml.ws.Service
             .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
 
@@ -143,12 +139,17 @@
         Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
 
         String response = greeter.greetMe("John");
+        
         assertEquals("Hello John", response);
     }
 
     @Test
-    @Ignore("Not implemented yet")
     public void testEndpointReferenceGetPort() throws Exception {
+        BusFactory.setDefaultBus(getBus());
+        GreeterImpl greeter1 = new GreeterImpl();
+        EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
+        endpoint.publish("http://localhost:8080/test");
+        
         InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
         Document doc = XMLUtils.parse(is);
         DOMSource erXML = new DOMSource(doc);
@@ -166,7 +167,6 @@
     public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception {
         GreeterImpl greeter = new GreeterImpl();
         EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
-
         endpoint.publish("http://localhost:8080/test");
 
         InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
@@ -297,8 +297,12 @@
     }
     
     @Test
-    @Ignore("Not implemented yet")
     public void testProviderGetPort() throws Exception {
+        BusFactory.setDefaultBus(getBus());
+        GreeterImpl greeter1 = new GreeterImpl();
+        EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
+        endpoint.publish("http://localhost:8080/test");
+        
         ProviderImpl provider = new ProviderImpl();
         
         InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/resources/hello_world_soap_http_infoset.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/resources/hello_world_soap_http_infoset.xml?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/resources/hello_world_soap_http_infoset.xml
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/resources/hello_world_soap_http_infoset.xml
Wed Dec  5 01:24:27 2007
@@ -5,7 +5,10 @@
         <testParameter1>testValue1</testParameter1>
         <testParameter2>testValue2</testParameter2>
     </wsa:ReferenceParameters>
-    <wsa:PortType></wsa:PortType> 
-    <wsa:ServiceName></wsa:ServiceName>
-    <wsa:Policies></wsa:Policies>
+    <wsa:Metadata
+      xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+      xmlns:wsaw="http://www.w3.org/2005/02/addressing/wsdl"
+      xmlns:ns="http://apache.org/hello_world_soap_http">
+        <wsaw:ServiceName EndpointName="SoapPort">ns:SOAPService</wsaw:ServiceName>
+    </wsa:Metadata>
 </wsa:EndpointReference>

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
Wed Dec  5 01:24:27 2007
@@ -20,16 +20,23 @@
 package org.apache.cxf.ws.addressing;
 
 
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
 // importation convention: if the same class name is used for 
 // 2005/08 and 2004/08, then the former version is imported
 // and the latter is fully qualified when used
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.ws.addressing.v200408.AttributedQName;
 import org.apache.cxf.ws.addressing.v200408.AttributedURI;
 import org.apache.cxf.ws.addressing.v200408.ObjectFactory;
@@ -186,6 +193,41 @@
         return internal; 
     }
 
+    /**
+     * Convert from EndpointReference to CXF internal 2005/08 EndpointReferenceType
+     * 
+     * @param external the javax.xml.ws.EndpointReference
+     * @return CXF internal 2005/08 EndpointReferenceType
+     */
+    public static EndpointReferenceType convertToInternal(EndpointReference external) {
+        if (external instanceof W3CEndpointReference) {
+            CachedOutputStream cos = new CachedOutputStream();
+            Result r = new StreamResult(cos);
+            external.writeTo(r);
+
+            JAXBContext jaxContext;
+            try {
+                // CXF internal 2005/08 EndpointReferenceType should be
+                // compatible with W3CEndpointReference
+                jaxContext = ContextUtils.getJAXBContext();
+                EndpointReferenceType internal = jaxContext.createUnmarshaller()
+                    .unmarshal(new StreamSource(cos.getInputStream()), EndpointReferenceType.class)
+                    .getValue();
+                return internal;
+            } catch (JAXBException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            return null;
+        } else {
+            //TODO: 200408
+        }
+        return null;
+    }
+    
     /**
      * Convert from 2005/08 ReferenceParametersType to 2004/08
      * ReferenceParametersType.

Added: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java?rev=601267&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
(added)
+++ incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
Wed Dec  5 01:24:27 2007
@@ -0,0 +1,70 @@
+/**
+ * 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.cxf.ws.addressing;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+public class VersionTransformerTest extends Assert {
+    
+    @Test
+    public void testConvertToInternal() throws Exception {
+        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+        Document doc = XMLUtils.parse(is);
+        DOMSource erXML = new DOMSource(doc);
+        EndpointReference endpointReference = readEndpointReference(erXML);
+        
+        EndpointReferenceType ert = VersionTransformer.convertToInternal(endpointReference);
+
+        assertNotNull(ert);
+        assertEquals("http://localhost:8080/test", ert.getAddress().getValue());
+        assertEquals(new QName("http://apache.org/hello_world_soap_http", "SOAPService"),

+                               EndpointReferenceUtils.getServiceName(ert));
+    }
+    
+    private EndpointReference readEndpointReference(Source eprInfoset) {
+        try {
+            Unmarshaller unmarshaller = JAXBContext.newInstance(W3CEndpointReference.class)
+                .createUnmarshaller();
+            return (EndpointReference)unmarshaller.unmarshal(eprInfoset);
+        } catch (JAXBException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml?rev=601267&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
(added)
+++ incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
Wed Dec  5 01:24:27 2007
@@ -0,0 +1,15 @@
+<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
+    <wsa:Address>http://localhost:8080/test</wsa:Address>
+    <wsa:ReferenceProperties></wsa:ReferenceProperties> 
+    <wsa:ReferenceParameters>
+        <testParameter1>testValue1</testParameter1>
+        <testParameter2>testValue2</testParameter2>
+    </wsa:ReferenceParameters>
+    <wsa:Metadata
+      xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+      xmlns:wsaw="http://www.w3.org/2005/02/addressing/wsdl"
+      xmlns:ns="http://apache.org/hello_world_soap_http">
+        <wsaw:ServiceName>ns:SOAPService</wsaw:ServiceName>
+    </wsa:Metadata>
+  
+</wsa:EndpointReference>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/resources/hello_world_soap_http_infoset.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java?rev=601267&r1=601266&r2=601267&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
Wed Dec  5 01:24:27 2007
@@ -89,7 +89,7 @@
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         expectedNames = null;
         expectedDeclaredTypes = null;
         expectedValues = null;
@@ -97,6 +97,7 @@
         expectedNamespaceURI = null;
         mimeHeaders = null;
         correlatedExchange = null;
+        ContextUtils.setJAXBContext(null);
     }
 
     @Test



Mime
View raw message