You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by pr...@apache.org on 2007/07/20 21:32:01 UTC

svn commit: r558100 - in /webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws: ./ addressing/util/ context/ registry/ server/ server/endpoint/ spi/

Author: pradine
Date: Fri Jul 20 12:31:59 2007
New Revision: 558100

URL: http://svn.apache.org/viewvc?view=rev&rev=558100
Log:
First pass at generating endpoint references for service providers.

Added:
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java
Modified:
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceBuilder.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
    webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Fri Jul 20 12:31:59 2007
@@ -34,6 +34,7 @@
 import org.apache.axis2.addressing.metadata.ServiceName;
 import org.apache.axis2.addressing.metadata.WSDLLocation;
 import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactory;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceBuilder;
 import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
 import org.apache.axis2.jaxws.binding.BindingUtils;
 import org.apache.axis2.jaxws.client.PropertyValidator;
@@ -251,14 +252,11 @@
         
         if (epr == null || !addressingNamespace.equals(this.addressingNamespace)) {
             String address = endpointDesc.getEndpointAddress();
-            epr = new org.apache.axis2.addressing.EndpointReference(address);
             QName service = endpointDesc.getServiceQName();
             QName port = endpointDesc.getPortQName();
             URL wsdlURL = ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
-            ServiceName serviceName = new ServiceName(service, port.getLocalPart());
-            WSDLLocation wsdlLocation = new WSDLLocation(port.getNamespaceURI(), wsdlURL.toString());
-            EndpointReferenceHelper.setServiceNameMetadata(epr, addressingNamespace, serviceName);
-            EndpointReferenceHelper.setWSDLLocationMetadata(epr, addressingNamespace, wsdlLocation);
+
+            epr = new EndpointReferenceBuilder().createEndpointReference(address, service, port, wsdlURL.toString(), addressingNamespace);
         }
         
         return epr;

Added: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java?view=auto&rev=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java Fri Jul 20 12:31:59 2007
@@ -0,0 +1,82 @@
+/*
+ * 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.axis2.jaxws.addressing.util;
+
+import javax.xml.namespace.QName;
+
+public class EndpointKey {
+    private QName service;
+    private QName endpoint;
+    
+    public EndpointKey(QName service, QName endpoint) {
+        if (service == null)
+            throw new IllegalArgumentException("The service qname cannot be null.");
+        
+        if (endpoint == null)
+            throw new IllegalArgumentException("The endpoint qname cannot be null.");
+        
+        this.service = service;
+        this.endpoint = endpoint;
+    }
+
+    public QName getEndpoint() {
+        return endpoint;
+    }
+
+    public QName getService() {
+        return service;
+    }
+
+    /* (non-Javadoc)
+     * Generated by Eclipse - suggest re-generation if class changes
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final EndpointKey other = (EndpointKey) obj;
+        if (endpoint == null) {
+            if (other.endpoint != null)
+                return false;
+        } else if (!endpoint.equals(other.endpoint))
+            return false;
+        if (service == null) {
+            if (other.service != null)
+                return false;
+        } else if (!service.equals(other.service))
+            return false;
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * Generated by Eclipse - suggest re-generation if class changes
+     */
+    @Override
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((endpoint == null) ? 0 : endpoint.hashCode());
+        result = PRIME * result + ((service == null) ? 0 : service.hashCode());
+        return result;
+    }   
+}

Added: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java?view=auto&rev=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java Fri Jul 20 12:31:59 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.axis2.jaxws.addressing.util;
+
+import java.util.HashMap;
+
+import org.apache.axis2.jaxws.addressing.util.EndpointKey;
+
+public class EndpointMap extends HashMap<EndpointKey, String> {
+    
+    
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 694539734825500599L;
+
+    public EndpointMap() {
+        super();
+    }
+}

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceBuilder.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceBuilder.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceBuilder.java Fri Jul 20 12:31:59 2007
@@ -18,43 +18,118 @@
  */
 package org.apache.axis2.jaxws.addressing.util;
 
-import java.util.List;
+import java.net.URL;
 
 import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.EndpointReferenceHelper;
 import org.apache.axis2.addressing.metadata.ServiceName;
 import org.apache.axis2.addressing.metadata.WSDLLocation;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.util.WSDL4JWrapper;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
 
 public final class EndpointReferenceBuilder {
+    private static final EndpointMap map =
+        (EndpointMap) FactoryRegistry.getFactory(EndpointMap.class);
     
     public EndpointReferenceBuilder() {
     }
     
-    public static EndpointReference createEndpointReference(String address) {
+    public void addAddress(QName serviceName, QName endpoint, String address) {
+        EndpointKey key = new EndpointKey(serviceName, endpoint);
+        
+        if (address == null || "".equals(address))
+            throw new IllegalStateException("The specified address is not a valid value: " + address);
+        
+        map.put(key, address);
+    }
+    
+    public EndpointReference createEndpointReference(String address) {
+        if (address == null || "".equals(address))
+            throw new IllegalStateException("The specified address is not a valid value: " + address);
+
         return new EndpointReference(address);
     }
     
-    public static EndpointReference createEndpointReference(QName serviceName, QName endpoint, String wsdlDocumentLocation) {
-        return null;
+    public EndpointReference createEndpointReference(QName serviceName, QName endpoint) {
+        EndpointKey key = new EndpointKey(serviceName, endpoint);
+        String address = map.get(key);
+        
+        return createEndpointReference(address);
     }
     
-    public static EndpointReference createEndpointReference(String address,
-                                                            QName serviceName,
-                                                            QName endpoint,
-                                                            List<OMElement> metadata,
-                                                            String wsdlDocumentLocation,
-                                                            List<OMElement> referenceParameters,
-                                                            String addressingNamespace) throws AxisFault {
-        EndpointReference epr = new EndpointReference(address);
-        ServiceName service = new ServiceName(serviceName, endpoint.getLocalPart());
-        WSDLLocation wsdlLocation = new WSDLLocation(endpoint.getNamespaceURI(), wsdlDocumentLocation);
-        EndpointReferenceHelper.setServiceNameMetadata(epr, addressingNamespace, service);
-        EndpointReferenceHelper.setWSDLLocationMetadata(epr, addressingNamespace, wsdlLocation);
-
-        return epr;
+    public EndpointReference createEndpointReference(String address, QName serviceName, QName portName, String wsdlDocumentLocation, String addressingNamespace) {
+        EndpointReference axis2EPR = null;
+        
+        if (address != null) {
+            //TODO NLS enable.
+        	if (serviceName == null && portName != null)
+                throw new IllegalStateException("Cannot create an endpoint reference because the service name is null, and the port name is not null.");
+        		
+            axis2EPR = createEndpointReference(address);
+        }
+        else if (serviceName != null && portName != null) {
+            axis2EPR = createEndpointReference(serviceName, portName);
+        }
+        else {
+            //TODO NLS enable.
+            throw new IllegalStateException("Cannot create an endpoint reference because the address, service name, and/or port name are null.");
+        }
+        
+        try {
+            if (wsdlDocumentLocation != null) {
+            	URL wsdlURL = new URL(wsdlDocumentLocation);
+            	WSDLWrapper wrapper = new WSDL4JWrapper(wsdlURL);
+            	
+            	if (serviceName != null) {
+            		//TODO NLS
+            		if (wrapper.getService(serviceName) == null)
+            			throw new IllegalStateException("The specified service name does not exist in the WSDL from the specified location.");
+                	
+                	if (portName != null) {
+                		String[] ports = wrapper.getPorts(serviceName);
+                		String portLocalName = portName.getLocalPart();
+                		boolean found = false;
+                		
+                		if (ports != null) {
+                			for (String port : ports) {
+                				if (port.equals(portLocalName)) {
+                					found = true;
+                					break;
+                				}
+                			}
+                		}
+                		
+                		//TODO NLS
+                		if (!found)
+                			throw new IllegalStateException("The specified port name does not exist in the specified WSDL service.");
+                	}
+            	}
+            	
+                WSDLLocation wsdlLocation = new WSDLLocation(portName.getNamespaceURI(), wsdlDocumentLocation);
+                EndpointReferenceHelper.setWSDLLocationMetadata(axis2EPR, addressingNamespace, wsdlLocation);
+            }
+            
+            //TODO If no service name and port name are specified, but the wsdl location is
+            //specified, and the WSDL only contains one service and one port then maybe we
+            //should simply use those.
+            if (serviceName != null && portName != null) {
+                ServiceName service = new ServiceName(serviceName, portName.getLocalPart());
+                EndpointReferenceHelper.setServiceNameMetadata(axis2EPR, addressingNamespace, service);
+            }
+        }
+        catch (IllegalStateException ise) {
+        	throw ise;
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("A problem occured during the creation of an endpoint reference. See the nested exception for details.", e);
+        }
+        
+        return axis2EPR;
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java Fri Jul 20 12:31:59 2007
@@ -18,10 +18,21 @@
  */
 package org.apache.axis2.jaxws.context;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.metadata.ServiceName;
+import org.apache.axis2.addressing.metadata.WSDLLocation;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactory;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceBuilder;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.util.XMLUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
 import javax.xml.ws.EndpointReference;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
@@ -29,6 +40,7 @@
 
 import org.w3c.dom.Element;
 
+import java.net.URI;
 import java.security.Principal;
 
 public class WebServiceContextImpl implements WebServiceContext {
@@ -97,13 +109,47 @@
     }
 
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
-        T jaxwsEPR = null;
+        EndpointReference jaxwsEPR = null;
+        String addressingNamespace = getAddressingNamespace(clazz);
         
+        if (soapMessageContext != null) {
+            QName service = (QName) soapMessageContext.get(MessageContext.WSDL_SERVICE);
+            QName endpoint = (QName) soapMessageContext.get(MessageContext.WSDL_PORT);
+            URI wsdlURI = (URI) soapMessageContext.get(MessageContext.WSDL_DESCRIPTION);
+            
+            org.apache.axis2.addressing.EndpointReference axis2EPR =
+                new EndpointReferenceBuilder().createEndpointReference(null, service, endpoint, wsdlURI.toString(), addressingNamespace);
+            
+            try {
+                if (referenceParameters != null) {
+                    for (Element element : referenceParameters) {
+                        OMElement omElement = XMLUtils.toOM(element);
+                        axis2EPR.addReferenceParameter(omElement);
+                    }            
+                }
+                
+                jaxwsEPR = EndpointReferenceConverter.convertFromAxis2(axis2EPR, addressingNamespace);
+            }
+            catch (Exception e) {
+                //TODO NLS enable.
+                throw ExceptionFactory.makeWebServiceException("Error creating endpoint reference", e);
+            }
+        }
+        else {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Unable to create endpoint references.");        	
+        }
         
-        return jaxwsEPR;
+        return clazz.cast(jaxwsEPR);
+    }
+
+    public EndpointReference getEndpointReference(Element... referenceParameters) {
+        return getEndpointReference(W3CEndpointReference.class, referenceParameters);
     }
 
-    public EndpointReference getEndpointReference(Element... arg0) {
-        return getEndpointReference(W3CEndpointReference.class, arg0);
+    private String getAddressingNamespace(Class clazz) {
+        EndpointReferenceFactory eprFactory =
+            (EndpointReferenceFactory) FactoryRegistry.getFactory(EndpointReferenceFactory.class);
+        return eprFactory.getAddressingNamespace(clazz);
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java Fri Jul 20 12:31:59 2007
@@ -21,6 +21,7 @@
 
 import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactory;
 import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactoryImpl;
+import org.apache.axis2.jaxws.addressing.util.EndpointMap;
 import org.apache.axis2.jaxws.handler.lifecycle.factory.HandlerLifecycleManagerFactory;
 import org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockFactoryImpl;
 import org.apache.axis2.jaxws.message.databinding.impl.OMBlockFactoryImpl;
@@ -67,6 +68,7 @@
         table.put(ClassFinderFactory.class, new ClassFinderFactory());
         table.put(EndpointDispatcherFactory.class, new EndpointDispatcherFactory());
         table.put(EndpointReferenceFactory.class, new EndpointReferenceFactoryImpl());
+        table.put(EndpointMap.class, new EndpointMap());
         table.put(ExecutorFactory.class, new JAXWSExecutorFactory());
     }
 

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Fri Jul 20 12:31:59 2007
@@ -25,9 +25,9 @@
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceBuilder;
 import org.apache.axis2.jaxws.binding.SOAPBinding;
 import org.apache.axis2.jaxws.core.InvocationContext;
-import org.apache.axis2.jaxws.core.MEPContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.core.util.MessageContextUtils;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
@@ -54,6 +54,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.ws.http.HTTPBinding;
@@ -310,6 +311,19 @@
             ServiceDescription sd =
                     DescriptionFactory.createServiceDescriptionFromServiceImpl(implClass, axisSvc);
             EndpointDescription ed = sd.getEndpointDescriptions_AsCollection().iterator().next();
+            
+            // TODO: This is only temporary until the deprecated method is no longer used
+            QName service = ed.getServiceQName();
+            QName endpoint = ed.getPortQName();
+            axisSvc = ed.getAxisService();
+            
+            try {
+                new EndpointReferenceBuilder().addAddress(service, endpoint, axisSvc.getEPRs()[0]);
+            }
+            catch (Exception e) {
+                throw ExceptionFactory.makeWebServiceException(e);
+            }
+            
             return ed;
         }
     }

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java Fri Jul 20 12:31:59 2007
@@ -18,25 +18,34 @@
  */
 package org.apache.axis2.jaxws.server.endpoint;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.addressing.factory.EndpointReferenceFactory;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceBuilder;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
 import org.apache.axis2.jaxws.binding.BindingUtils;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.transport.http.HTTPWorkerFactory;
 import org.apache.axis2.transport.http.server.SimpleHttpServer;
 import org.apache.axis2.transport.http.server.WorkerFactory;
+import org.apache.axis2.util.XMLUtils;
 import org.w3c.dom.Element;
 
+import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 import javax.xml.ws.Binding;
 import javax.xml.ws.EndpointReference;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
 import java.io.IOException;
+import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
@@ -207,15 +216,42 @@
 
     @Override
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
-        T jaxwsEPR = null;
+        EndpointReference jaxwsEPR = null;
+        String addressingNamespace = getAddressingNamespace(clazz);
+        String address = endpointDesc.getEndpointAddress();
+        QName serviceName = endpointDesc.getServiceQName();
+        QName portName = endpointDesc.getPortQName();
+        URL wsdlURL = ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
         
+        org.apache.axis2.addressing.EndpointReference axis2EPR =
+        	new EndpointReferenceBuilder().createEndpointReference(address, serviceName, portName, wsdlURL.toString(), addressingNamespace);
         
+        try {
+            if (referenceParameters != null) {
+                for (Element element : referenceParameters) {
+                    OMElement omElement = XMLUtils.toOM(element);
+                    axis2EPR.addReferenceParameter(omElement);
+                }            
+            }
+            
+            jaxwsEPR = EndpointReferenceConverter.convertFromAxis2(axis2EPR, addressingNamespace);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Error creating endpoint reference", e);
+        }
 
-        return jaxwsEPR;
+        return clazz.cast(jaxwsEPR);
     }
 
     @Override
-    public EndpointReference getEndpointReference(Element... arg0) {
-        return getEndpointReference(W3CEndpointReference.class, arg0);
+    public EndpointReference getEndpointReference(Element... referenceParameters) {
+        return getEndpointReference(W3CEndpointReference.class, referenceParameters);
+    }
+
+    private String getAddressingNamespace(Class clazz) {
+        EndpointReferenceFactory eprFactory =
+            (EndpointReferenceFactory) FactoryRegistry.getFactory(EndpointReferenceFactory.class);
+        return eprFactory.getAddressingNamespace(clazz);
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java?view=diff&rev=558100&r1=558099&r2=558100
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java Fri Jul 20 12:31:59 2007
@@ -75,27 +75,13 @@
             List<Element> metadata,
             String wsdlDocumentLocation,
             List<Element> referenceParameters) {
-        org.apache.axis2.addressing.EndpointReference axis2EPR = null;
-        
-        if (address != null) {
-            axis2EPR = EndpointReferenceBuilder.createEndpointReference(address);
-        }
-        else if (serviceName != null && portName != null) {
-            axis2EPR = EndpointReferenceBuilder.createEndpointReference(serviceName, portName, wsdlDocumentLocation);
-        }
-        else {
-            //TODO NLS enable.
-            throw new IllegalStateException("Cannot create an endpoint reference because the address, service name, and port name are all null.");
-        }
+        String addressingNamespace = getAddressingNamespace(W3CEndpointReference.class);    	
+        org.apache.axis2.addressing.EndpointReference axis2EPR =
+        	new EndpointReferenceBuilder().createEndpointReference(address, serviceName, portName, wsdlDocumentLocation, addressingNamespace);
         
         W3CEndpointReference w3cEPR = null;
         
         try {
-            //This enables EndpointReference.getPort() to work.
-            if (serviceName != null && portName != null) {
-                
-            }
-            
             if (metadata != null) {
                 for (Element element : metadata) {
                     OMElement omElement = XMLUtils.toOM(element);
@@ -110,7 +96,6 @@
                 }            
             }
             
-            String addressingNamespace = getAddressingNamespace(W3CEndpointReference.class);
             w3cEPR =
                 (W3CEndpointReference) EndpointReferenceConverter.convertFromAxis2(axis2EPR, addressingNamespace);
         }
@@ -172,7 +157,7 @@
             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
             OMElement eprElement = (OMElement) XMLUtils.toOM(bais);
             org.apache.axis2.addressing.EndpointReference axis2EPR =
-                new org.apache.axis2.addressing.EndpointReference("");
+                new EndpointReferenceBuilder().createEndpointReference("");
             String addressingNamespace = EndpointReferenceHelper.fromOM(axis2EPR, eprElement);
             
             jaxwsEPR = EndpointReferenceConverter.convertFromAxis2(axis2EPR, addressingNamespace);



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