cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r603999 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/transport/http/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/resour...
Date Thu, 13 Dec 2007 19:38:50 GMT
Author: dkulp
Date: Thu Dec 13 11:38:37 2007
New Revision: 603999

URL: http://svn.apache.org/viewvc?rev=603999&view=rev
Log:
Merged revisions 603438 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r603438 | ningjiang | 2007-12-11 21:12:22 -0500 (Tue, 11 Dec 2007) | 1 line
  
  CXF-1279 applied the patch with thanks to Christian, also added a systest for the Servlet
transport
........

Added:
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
      - copied unchanged from r603438, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/AbstractEndpointFactory.java
Thu Dec 13 11:38:37 2007
@@ -45,6 +45,7 @@
     protected DataBinding dataBinding;
     protected BindingFactory bindingFactory;
     protected DestinationFactory destinationFactory;
+    protected String publishedEndpointUrl;
     protected QName endpointName;
     protected QName serviceName;
     protected Map<String, Object> properties;
@@ -108,6 +109,14 @@
 
     public void setDestinationFactory(DestinationFactory destinationFactory) {
         this.destinationFactory = destinationFactory;
+    }
+
+    public String getPublishedEndpointUrl() {
+        return publishedEndpointUrl;
+    }
+
+    public void setPublishedEndpointUrl(String publishedEndpointUrl) {
+        this.publishedEndpointUrl = publishedEndpointUrl;
     }
 
     public QName getEndpointName() {

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
Thu Dec 13 11:38:37 2007
@@ -34,13 +34,18 @@
 
 import javax.wsdl.Definition;
 import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
 import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.extensions.schema.SchemaImport;
 import javax.wsdl.extensions.schema.SchemaReference;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
 import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.w3c.dom.Document;
@@ -50,7 +55,6 @@
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
 import org.apache.cxf.common.i18n.Message;
@@ -148,6 +152,11 @@
                                                        base);
                     def = mp.get(wsdl2);
                 }
+                
+                if (endpointInfo.getProperty("publishedEndpointUrl") != null) {
+                    String publishingUrl = String.valueOf(endpointInfo.getProperty("publishedEndpointUrl"));
+                    updatePublishedEndpointUrl(publishingUrl, def, endpointInfo.getName());
+                }
     
                 WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class)
                     .getWSDLFactory().newWSDLWriter();
@@ -226,7 +235,6 @@
                                                      baseUri), e);
         }
     }
-    
 
     static String resolveWithCatalogs(OASISCatalogManager catalogs, String start, String
base) {
         String resolvedSchemaLocation = null;
@@ -284,6 +292,38 @@
                     Schema see = (Schema)el;
                     updateSchemaImports(see, doneSchemas, base);
                 }
+            }
+        }
+    }    
+
+    protected void updatePublishedEndpointUrl(String publishingUrl, Definition def, QName
name) {
+        Collection<Service> services = CastUtils.cast(def.getAllServices().values());
+        for (Service service : services) {
+            Collection<Port> ports = CastUtils.cast(service.getPorts().values());
+            if (ports.isEmpty()) {
+                continue;
+            }
+            
+            if (name == null) {
+                setSoapAddressLocationOn(ports.iterator().next(), publishingUrl);
+                break; // only update the first port since we don't target any specific port
+            } else {
+                for (Port port : ports) {
+                    if (name.getLocalPart().equals(port.getName())) {
+                        setSoapAddressLocationOn(port, publishingUrl);
+                    }
+                }
+            }
+        }
+    }
+    
+    private void setSoapAddressLocationOn(Port port, String url) {
+        List extensions = port.getExtensibilityElements();
+        for (Object extension : extensions) {
+            if (extension instanceof SOAP12Address) {
+                ((SOAP12Address)extension).setLocationURI(url);
+            } else if (extension instanceof SOAPAddress) {
+                ((SOAPAddress)extension).setLocationURI(url);
             }
         }
     }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Thu Dec 13 11:38:37 2007
@@ -46,6 +46,7 @@
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.invoker.Invoker;
+import org.apache.cxf.service.model.EndpointInfo;
 
 public class EndpointImpl extends javax.xml.ws.Endpoint 
     implements InterceptorProvider, Configurable {
@@ -73,6 +74,7 @@
     private String bindingUri;
     private String wsdlLocation;
     private String address;
+    private String publishedEndpointUrl;
     private QName endpointName;
     private QName serviceName;
     private Class implementorClass;
@@ -226,8 +228,13 @@
         checkPublishPermission();
         
         ServerImpl serv = getServer(addr);
-        if (addr != null) {
-            serv.getEndpoint().getEndpointInfo().setAddress(addr);
+        if (addr != null) {            
+            EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
+            endpointInfo.setAddress(addr);
+            if (publishedEndpointUrl != null) {
+                // TODO is there a good place to put this key-string as a constant?
+                endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
+            }
         }
         serv.start();
     }
@@ -351,6 +358,20 @@
 
     public void setAddress(String address) {
         this.address = address;
+    }
+    
+    /**
+    * The published endpoint url is used for excplicitely specifying the url of the
+    * endpoint that would show up the generated wsdl definition, when the service is
+    * brought on line.
+    * @return
+    */
+    public String getPublishedEndpointUrl() {
+        return publishedEndpointUrl;
+    }
+    
+    public void setPublishedEndpointUrl(String publishedEndpointUrl) {
+        this.publishedEndpointUrl = publishedEndpointUrl;
     }
 
     public QName getEndpointName() {

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd
Thu Dec 13 11:38:37 2007
@@ -55,6 +55,7 @@
           <xsd:attribute name="implementor" type="xsd:string"/>
           <xsd:attribute name="implementorClass" type="xsd:string"/>
           <xsd:attribute name="publish" type="xsd:boolean" default="true"/>
+          <xsd:attribute name="publishedEndpointUrl" type="xsd:string"/>
           <xsd:attribute name="endpointName" type="xsd:QName" />
           <xsd:attribute name="serviceName" type="xsd:QName" />
           <xsd:attribute name="wsdlLocation" type="xsd:string" />

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Thu Dec 13 11:38:37 2007
@@ -22,6 +22,7 @@
 import java.io.StringWriter;
 import java.util.List;
 
+
 import javax.xml.namespace.QName;
 
 import junit.framework.Assert;
@@ -147,6 +148,12 @@
         bean = ctx.getBean("wsdlLocation");
         assertNotNull(bean);
         
+        bean = ctx.getBean("publishedEndpointUrl");
+        assertNotNull(bean);
+        String expectedEndpointUrl = "http://cxf.apache.org/Greeter";
+        ep = (EndpointImpl) bean;
+        assertEquals(expectedEndpointUrl, ep.getPublishedEndpointUrl());
+        
         // test for existence of Endpoint without an id element
         boolean found = false;
         String[] names = ctx.getBeanNamesForType(EndpointImpl.class);
@@ -160,6 +167,7 @@
         testInterceptors(ctx);
     }
 
+   
     private void testNamespaceMapping(ApplicationContext ctx) throws Exception {
         AnonymousComplexType act = (AnonymousComplexType) ctx.getBean("bookClient");
         Client client = ClientProxy.getClient(act);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
Thu Dec 13 11:38:37 2007
@@ -120,4 +120,9 @@
     implementor="java.lang.Object"
     implementorClass="org.apache.cxf.jaxws.service.Hello"
     address="http://localhost:8080/test"/>
+    
+  <jaxws:endpoint id="publishedEndpointUrl"
+    implementor="#greeter"
+    address="http://localhost:8080/publishedEndpointUrl"
+    publishedEndpointUrl="http://cxf.apache.org/Greeter"/>
 </beans>

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
Thu Dec 13 11:38:37 2007
@@ -216,6 +216,10 @@
         ei.setName(endpointName);
         ei.setAddress(getAddress());
         ei.setBinding(bindingInfo);
+        
+        if (publishedEndpointUrl != null && !"".equals(publishedEndpointUrl)) {
+            ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
+        }
 
         if (destinationFactory instanceof WSDLEndpointFactory) {
             WSDLEndpointFactory we = (WSDLEndpointFactory) destinationFactory;

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
Thu Dec 13 11:38:37 2007
@@ -114,7 +114,15 @@
         assertTrue("the soap address should changed",
                    res.getText().contains("<soap:address location=\"" + CONTEXT_URL +
"/services/Greeter"));
         
-        
+        req = 
+            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter2?wsdl");
+        res = client.getResponse(req);    
+        assertEquals(200, res.getResponseCode());
+        assertEquals("text/xml", res.getContentType());
+        assertTrue("the wsdl should contain the opertion greetMe",
+                   res.getText().contains("<wsdl:operation name=\"greetMe\">"));
+        assertTrue("the soap address should be updated",
+                   res.getText().contains("<soap:address location=\"http://cxf.apache.org/Greeter"));
         
     }
     

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml?rev=603999&r1=603998&r2=603999&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
Thu Dec 13 11:38:37 2007
@@ -50,6 +50,7 @@
     <jaxws:endpoint id="endpoint2" 
               implementor="org.apache.hello_world_soap_http.GreeterImpl"
               address="/services/Greeter2"
+              publishedEndpointUrl="http://cxf.apache.org/Greeter"
               />     
   
 </beans>



Mime
View raw message