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/05/29 22:23:49 UTC

svn commit: r542643 [3/3] - in /webservices/axis2/branches/java/jaxws21/modules: jaxws-api/ jaxws-api/src/javax/xml/ws/ jaxws-api/src/javax/xml/ws/handler/ jaxws-api/src/javax/xml/ws/soap/ jaxws-api/src/javax/xml/ws/spi/ jaxws-api/src/javax/xml/ws/wsad...

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=542643&r1=542642&r2=542643
==============================================================================
--- 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 Tue May 29 13:23:45 2007
@@ -18,15 +18,38 @@
  */
 package org.apache.axis2.jaxws.spi;
 
+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.ws.Endpoint;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.spi.ServiceDelegate;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+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.SubmissionEndpointReference;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceBuilder;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
+import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.server.endpoint.EndpointImpl;
+import org.apache.axis2.util.XMLUtils;
+import org.w3c.dom.Element;
 
 import java.net.URL;
+import java.util.List;
 
 public class Provider extends javax.xml.ws.spi.Provider {
+    private static volatile JAXBContext jaxbContext;
 
     @Override
     public Endpoint createAndPublishEndpoint(String s, Object obj) {
@@ -43,5 +66,125 @@
     @Override
     public ServiceDelegate createServiceDelegate(URL url, QName qname, Class clazz) {
         return new org.apache.axis2.jaxws.spi.ServiceDelegate(url, qname, clazz);
+    }
+
+    @Override
+    public W3CEndpointReference createW3CEndpointReference(String address,
+            QName serviceName,
+            QName portName,
+            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.");
+        }
+        
+        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);
+                    axis2EPR.addMetaData(omElement);
+                }
+            }
+            
+            if (referenceParameters != null) {
+                for (Element element : referenceParameters) {
+                    OMElement omElement = XMLUtils.toOM(element);
+                    axis2EPR.addReferenceParameter(omElement);
+                }            
+            }
+            
+            w3cEPR = EndpointReferenceConverter.convertFromAxis2(axis2EPR, W3CEndpointReference.class);
+        }
+        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 w3cEPR;
+    }
+
+    @Override
+    public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
+        if (jaxwsEPR == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("The endpoint reference cannot be null.");
+        }
+        
+        if (sei == null) {
+            throw ExceptionFactory.makeWebServiceException(
+                    Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
+        }
+
+        org.apache.axis2.addressing.EndpointReference axis2EPR = null;
+        try {
+            axis2EPR = EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Invalid endpoint reference.", e);
+        }
+        
+        String addressingNamespace = (jaxwsEPR instanceof SubmissionEndpointReference) ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
+        org.apache.axis2.jaxws.spi.ServiceDelegate serviceDelegate = null;
+        
+        try {
+            ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(axis2EPR, addressingNamespace);
+            WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(axis2EPR, addressingNamespace);
+            
+            serviceDelegate = new org.apache.axis2.jaxws.spi.ServiceDelegate(new URL(wsdlLocation.getURL()), serviceName.getName(), Service.class);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("An error occured updating the endpoint", e);
+        }
+
+        return serviceDelegate.getPort(axis2EPR, addressingNamespace, sei, features);
+    }
+
+    @Override
+    public EndpointReference readEndpointReference(Source eprInfoset) {
+        EndpointReference epr = null;
+
+        try {
+            JAXBContext jaxbContext = getJAXBContext();
+            Unmarshaller um = jaxbContext.createUnmarshaller();
+            epr = (EndpointReference) um.unmarshal(eprInfoset);
+        }
+        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 epr;
+    }
+    
+    private JAXBContext getJAXBContext() throws JAXBException {
+        //This is an implementation of double-checked locking.
+        //It works because jaxbContext is volatile.
+        if (jaxbContext == null) {
+            synchronized (javax.xml.ws.spi.Provider.class) {
+                if (jaxbContext == null)
+                    jaxbContext = JAXBContext.newInstance(W3CEndpointReference.class, SubmissionEndpointReference.class);
+            }
+        }
+        
+        return jaxbContext;
     }
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Tue May 29 13:23:45 2007
@@ -16,13 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.axis2.jaxws.spi;
 
 import javax.xml.ws.handler.HandlerResolver;
+
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
 import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.addressing.SubmissionEndpointReference;
+import org.apache.axis2.jaxws.addressing.util.EndpointReferenceConverter;
 import org.apache.axis2.jaxws.client.PropertyMigrator;
 import org.apache.axis2.jaxws.client.dispatch.JAXBDispatch;
 import org.apache.axis2.jaxws.client.dispatch.XMLDispatch;
@@ -31,7 +36,11 @@
 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.handler.HandlerResolverImpl;
+import org.apache.axis2.jaxws.feature.config.MTOMConfigurator;
+import org.apache.axis2.jaxws.feature.config.RespectBindingConfigurator;
+import org.apache.axis2.jaxws.feature.config.W3CAndSubmissionAddressingConfigurator;
+import org.apache.axis2.jaxws.feature.util.WebServiceFeatureConfigUtil;
+import org.apache.axis2.jaxws.feature.util.WebServiceFeatureConfigurator;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
@@ -44,10 +53,11 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
 import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.Service.Mode;
 import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.HandlerResolver;
 import javax.xml.ws.http.HTTPBinding;
 import javax.xml.ws.soap.SOAPBinding;
 import java.lang.reflect.Proxy;
@@ -90,12 +100,21 @@
                         "serviceDelegateConstruct0", serviceQname.toString(), url.toString()));
             }
         }
+        
+        ConfigurationContext context= serviceDescription.getAxisConfigContext();
 
         // Register the necessary ApplicationContextMigrators
-        ApplicationContextMigratorUtil
-                .addApplicationContextMigrator(serviceDescription.getAxisConfigContext(),
-                                               Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
-                                               new PropertyMigrator());
+        ApplicationContextMigratorUtil.addApplicationContextMigrator(context,
+                Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID, new PropertyMigrator());
+        
+        // Register our WebServiceFeature configurators.
+        WebServiceFeatureConfigurator[] configurators = {new W3CAndSubmissionAddressingConfigurator(),
+                new MTOMConfigurator(), new RespectBindingConfigurator()};
+        
+        for (WebServiceFeatureConfigurator configurator : configurators) {
+            WebServiceFeatureConfigUtil.addWebServiceFeatureConfigurator(context,
+                    Constants.WEB_SERVICE_FEATURE_CONFIGURATOR_LIST_ID, configurator);            
+        }
     }
 
     //================================================
@@ -125,29 +144,139 @@
     * (non-Javadoc)
     * @see javax.xml.ws.spi.ServiceDelegate#createDispatch(javax.xml.namespace.QName, java.lang.Class, javax.xml.ws.Service.Mode)
     */
-    public <T> Dispatch<T> createDispatch(QName qname, Class<T> clazz, Mode mode)
+    public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Mode mode)
             throws WebServiceException {
-        if (qname == null) {
+        return createDispatch(portName, type, mode, (WebServiceFeature[]) null);
+    }
+
+    /*
+    * (non-Javadoc)
+    * @see javax.xml.ws.spi.ServiceDelegate#createDispatch(javax.xml.namespace.QName, javax.xml.bind.JAXBContext, javax.xml.ws.Service.Mode)
+    */
+    public Dispatch<java.lang.Object> createDispatch(QName portName, JAXBContext context, Mode mode) {
+        return createDispatch(portName, context, mode, (WebServiceFeature[]) null);
+    }
+
+    @Override
+    public <T> Dispatch<T> createDispatch(EndpointReference jaxwsEPR, Class<T> type, Mode mode, WebServiceFeature... features) {
+        if (jaxwsEPR == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory
+                    .makeWebServiceException("The endpoint reference cannot be null.");
+        }
+        if (!isValidDispatchType(type)) {
+            throw ExceptionFactory
+                    .makeWebServiceException(Messages.getMessage("dispatchInvalidType"));
+        }
+        
+        org.apache.axis2.addressing.EndpointReference axis2EPR = null;
+        try {
+            axis2EPR = EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Invalid endpoint reference.", e);
+        }
+        
+        String addressingNamespace = (jaxwsEPR instanceof SubmissionEndpointReference) ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
+
+        EndpointDescription endpointDesc =
+                DescriptionFactory.updateEndpoint(serviceDescription, null, axis2EPR,
+                                                  addressingNamespace,
+                                                  DescriptionFactory.UpdateType.CREATE_DISPATCH);
+        if (endpointDesc == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Unable to generate an endpoint description for endpoint reference " + jaxwsEPR);
+        }
+
+        // FIXME: This call needs to be revisited.  Not really sure what we're trying to do here. 
+        addBinding(endpointDesc.getClientBindingID());
+
+        XMLDispatch<T> dispatch = new XMLDispatch<T>(this, endpointDesc, axis2EPR, addressingNamespace, features);
+        if (mode != null) {
+            dispatch.setMode(mode);
+        } else {
+            dispatch.setMode(Service.Mode.PAYLOAD);
+        }
+
+        if (serviceClient == null)
+            serviceClient = getServiceClient(endpointDesc.getPortQName());
+
+        dispatch.setServiceClient(serviceClient);
+        dispatch.setType(type);
+        return dispatch;
+    }
+
+    @Override
+    public Dispatch<Object> createDispatch(EndpointReference jaxwsEPR, JAXBContext context, Mode mode, WebServiceFeature... features) {
+        if (jaxwsEPR == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory
+                    .makeWebServiceException("The endpoint reference cannot be null.");
+        }
+
+        org.apache.axis2.addressing.EndpointReference axis2EPR = null;
+        try {
+            axis2EPR = EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Invalid endpoint reference.", e);
+        }
+        
+        String addressingNamespace = (jaxwsEPR instanceof SubmissionEndpointReference) ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
+
+        EndpointDescription endpointDesc =
+                DescriptionFactory.updateEndpoint(serviceDescription, null, axis2EPR,
+                                                  addressingNamespace,
+                                                  DescriptionFactory.UpdateType.CREATE_DISPATCH);
+        if (endpointDesc == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Unable to generate an endpoint description for endpoint reference " + jaxwsEPR);
+        }
+
+        addBinding(endpointDesc.getClientBindingID());
+
+        JAXBDispatch<Object> dispatch = new JAXBDispatch(this, endpointDesc, axis2EPR, addressingNamespace, features);
+
+        if (mode != null) {
+            dispatch.setMode(mode);
+        } else {
+            dispatch.setMode(Service.Mode.PAYLOAD);
+        }
+
+        if (serviceClient == null)
+            serviceClient = getServiceClient(endpointDesc.getPortQName());
+
+        dispatch.setJAXBContext(context);
+        dispatch.setServiceClient(serviceClient);
+
+        return dispatch;
+    }
+
+    @Override
+    public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Mode mode, WebServiceFeature... features) {
+        if (portName == null) {
             throw ExceptionFactory
                     .makeWebServiceException(Messages.getMessage("createDispatchFail0"));
         }
-        if (!isValidDispatchType(clazz)) {
+        if (!isValidDispatchType(type)) {
             throw ExceptionFactory
                     .makeWebServiceException(Messages.getMessage("dispatchInvalidType"));
         }
 
         EndpointDescription endpointDesc =
-                DescriptionFactory.updateEndpoint(serviceDescription, null, qname,
+                DescriptionFactory.updateEndpoint(serviceDescription, null, portName,
                                                   DescriptionFactory.UpdateType.CREATE_DISPATCH);
         if (endpointDesc == null) {
             throw ExceptionFactory.makeWebServiceException(
-                    Messages.getMessage("createDispatchFail2", qname.toString()));
+                    Messages.getMessage("createDispatchFail2", portName.toString()));
         }
 
         // FIXME: This call needs to be revisited.  Not really sure what we're trying to do here. 
         addBinding(endpointDesc.getClientBindingID());
 
-        XMLDispatch<T> dispatch = new XMLDispatch<T>(this, endpointDesc);
+        XMLDispatch<T> dispatch = new XMLDispatch<T>(this, endpointDesc, features);
         if (mode != null) {
             dispatch.setMode(mode);
         } else {
@@ -155,34 +284,31 @@
         }
 
         if (serviceClient == null)
-            serviceClient = getServiceClient(qname);
+            serviceClient = getServiceClient(portName);
 
         dispatch.setServiceClient(serviceClient);
-        dispatch.setType(clazz);
+        dispatch.setType(type);
         return dispatch;
     }
 
-    /*
-    * (non-Javadoc)
-    * @see javax.xml.ws.spi.ServiceDelegate#createDispatch(javax.xml.namespace.QName, javax.xml.bind.JAXBContext, javax.xml.ws.Service.Mode)
-    */
-    public Dispatch<java.lang.Object> createDispatch(QName qname, JAXBContext context, Mode mode) {
-        if (qname == null) {
+    @Override
+    public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode mode, WebServiceFeature... features) {
+        if (portName == null) {
             throw ExceptionFactory
                     .makeWebServiceException(Messages.getMessage("createDispatchFail0"));
         }
 
         EndpointDescription endpointDesc =
-                DescriptionFactory.updateEndpoint(serviceDescription, null, qname,
+                DescriptionFactory.updateEndpoint(serviceDescription, null, portName,
                                                   DescriptionFactory.UpdateType.CREATE_DISPATCH);
         if (endpointDesc == null) {
             throw ExceptionFactory.makeWebServiceException(
-                    Messages.getMessage("createDispatchFail2", qname.toString()));
+                    Messages.getMessage("createDispatchFail2", portName.toString()));
         }
 
         addBinding(endpointDesc.getClientBindingID());
 
-        JAXBDispatch<Object> dispatch = new JAXBDispatch(this, endpointDesc);
+        JAXBDispatch<Object> dispatch = new JAXBDispatch(this, endpointDesc, features);
 
         if (mode != null) {
             dispatch.setMode(mode);
@@ -191,7 +317,7 @@
         }
 
         if (serviceClient == null)
-            serviceClient = getServiceClient(qname);
+            serviceClient = getServiceClient(portName);
 
         dispatch.setJAXBContext(context);
         dispatch.setServiceClient(serviceClient);
@@ -204,7 +330,7 @@
      * @see javax.xml.ws.spi.ServiceDelegate#getPort(java.lang.Class)
      */
     public <T> T getPort(Class<T> sei) throws WebServiceException {
-        return getPort(null, sei);
+        return getPort((QName) null, sei, (WebServiceFeature[]) null);
     }
 
     /*
@@ -212,6 +338,54 @@
     * @see javax.xml.ws.spi.ServiceDelegate#getPort(javax.xml.namespace.QName, java.lang.Class)
     */
     public <T> T getPort(QName portName, Class<T> sei) throws WebServiceException {
+        return getPort(portName, sei, (WebServiceFeature[]) null);
+    }
+
+    @Override
+    public <T> T getPort(Class<T> sei, WebServiceFeature... features) {
+        return getPort((QName) null, sei, features);
+    }
+
+    @Override
+    public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
+        /* TODO Check to see if WSDL Location is provided.
+         * if not check WebService annotation's WSDLLocation
+         * if both are not provided then throw exception.
+         * (JLB): I'm not sure lack of WSDL should cause an exception
+         */
+
+
+        if (!isValidWSDLLocation()) {
+            //TODO: Should I throw Exception if no WSDL
+            //throw ExceptionFactory.makeWebServiceException("WSLD Not found");
+        }
+        
+        if (jaxwsEPR == null) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("The endpoint reference cannot be null.");
+        }
+        
+        if (sei == null) {
+            throw ExceptionFactory.makeWebServiceException(
+                    Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
+        }
+
+        org.apache.axis2.addressing.EndpointReference axis2EPR = null;
+        try {
+            axis2EPR = EndpointReferenceConverter.convertToAxis2(jaxwsEPR);
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("Invalid endpoint reference.", e);
+        }
+        
+        String addressingNamespace = (jaxwsEPR instanceof SubmissionEndpointReference) ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
+
+        return getPort(axis2EPR, addressingNamespace, sei, features);
+    }
+
+    @Override
+    public <T> T getPort(QName portName, Class<T> sei, WebServiceFeature... features) {
         /* TODO Check to see if WSDL Location is provided.
          * if not check WebService annotation's WSDLLocation
          * if both are not provided then throw exception.
@@ -234,10 +408,10 @@
         if (endpointDesc == null) {
             // TODO: NLS
             throw ExceptionFactory.makeWebServiceException(
-                    "Unable to getPort for port QName " + portName.toString());
+                    "Unable to getPort for port QName " + portName);
         }
 
-        JAXWSProxyHandler proxyHandler = new JAXWSProxyHandler(this, sei, endpointDesc);
+        JAXWSProxyHandler proxyHandler = new JAXWSProxyHandler(this, sei, endpointDesc, features);
 
         Class[] seiClazz = new Class[] { sei, org.apache.axis2.jaxws.spi.BindingProvider.class };
         Object proxyClass = Proxy.newProxyInstance(getClassLoader(sei), seiClazz, proxyHandler);
@@ -325,6 +499,24 @@
      */
     public ServiceClient getServiceClient(QName portQName) throws WebServiceException {
         return serviceDescription.getServiceClient(portQName);
+    }
+    
+    public <T> T getPort(org.apache.axis2.addressing.EndpointReference axis2EPR, String addressingNamespace, Class<T> sei, WebServiceFeature... features) {
+        EndpointDescription endpointDesc =
+                DescriptionFactory.updateEndpoint(serviceDescription, sei, axis2EPR,
+                                                  addressingNamespace,
+                                                  DescriptionFactory.UpdateType.GET_PORT);
+        if (endpointDesc == null) {
+            // TODO: NLS
+            throw ExceptionFactory.makeWebServiceException(
+                    "Unable to getPort for epr " + axis2EPR);
+        }
+
+        JAXWSProxyHandler proxyHandler = new JAXWSProxyHandler(this, sei, endpointDesc, axis2EPR, addressingNamespace, features);
+
+        Class[] seiClazz = new Class[] { sei, org.apache.axis2.jaxws.spi.BindingProvider.class };
+        Object proxyClass = Proxy.newProxyInstance(getClassLoader(sei), seiClazz, proxyHandler);
+        return sei.cast(proxyClass);        
     }
 
     //================================================

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/AddressingConstants.java Tue May 29 13:23:45 2007
@@ -1,20 +1,21 @@
 /*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed 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.
-*/
-
-
+ * 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.addressing;
 
 import javax.xml.namespace.QName;
@@ -116,7 +117,9 @@
         static final String WSA_NAMESPACE =
                 "http://www.w3.org/2005/08/addressing";
         static final String WSAW_NAMESPACE =
-                "http://www.w3.org/2006/05/addressing/wsdl";
+            "http://www.w3.org/2006/05/addressing/wsdl";
+        static final String WSAM_NAMESPACE =
+            "http://www.w3.org/2007/02/addressing/metadata";
         /**
          * @deprecated use {@link #WSA_DEFAULT_RELATIONSHIP_TYPE} instead.
          */
@@ -135,6 +138,7 @@
         static final String WSA_SERVICE_NAME_ENDPOINT_NAME = "EndpointName";
         static final String WSA_POLICIES = "Policies";
         static final String WSA_METADATA = "Metadata";
+        static final String WSA_DEFAULT_METADATA_PREFIX = "wsam";
 
         static final String WSA_INTERFACE_NAME = "InterfaceName";
 
@@ -193,6 +197,8 @@
         static final String EPR_REFERENCE_PROPERTIES = "ReferenceProperties";
         static final String WSA_FAULT_ACTION =
                 "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
+        static final String WSA_SERVICE_NAME_ENDPOINT_NAME = "PortName";
+        static final String WSA_INTERFACE_NAME = "PortType";
 
         // fault information
         static final String FAULT_INVALID_HEADER = "InvalidMessageInformationHeader";

Modified: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/EndpointReferenceHelper.java Tue May 29 13:23:45 2007
@@ -1,18 +1,21 @@
 /*
-* Copyright 2006 The Apache Software Foundation.
-*
-* Licensed 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.
-*/
+ * 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.addressing;
 
 import org.apache.axiom.om.OMAttribute;
@@ -25,6 +28,8 @@
 import org.apache.axiom.om.util.ElementHelper;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.metadata.ServiceName;
+import org.apache.axis2.addressing.metadata.WSDLLocation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -228,8 +233,8 @@
             if (addressAttributes != null) {
                 Iterator attrIter = addressAttributes.iterator();
                 while (attrIter.hasNext()) {
-                    OMAttribute omAttributes = (OMAttribute) attrIter.next();
-                    addressE.addAttribute(omAttributes);
+                    OMAttribute omAttribute = (OMAttribute) attrIter.next();
+                    AttributeHelper.importOMAttribute(omAttribute, addressE);
                 }
             }
 
@@ -247,8 +252,8 @@
                 if (metadataAttributes != null) {
                     Iterator attrIter = metadataAttributes.iterator();
                     while (attrIter.hasNext()) {
-                        OMAttribute omAttributes = (OMAttribute) attrIter.next();
-                        metadataE.addAttribute(omAttributes);
+                        OMAttribute omAttribute = (OMAttribute) attrIter.next();
+                        AttributeHelper.importOMAttribute(omAttribute, metadataE);
                     }
                 }
             }
@@ -352,7 +357,130 @@
             log.debug("fromOM: Endpoint reference, " + epr);
         }
     }
+    
+    /**
+     * 
+     * @param epr
+     * @param addressingNamespace
+     * @return
+     * @throws AxisFault
+     */
+    public static ServiceName getServiceNameMetadata(EndpointReference epr, String addressingNamespace) throws AxisFault {
+        ServiceName serviceName = new ServiceName();
+        List elements = null;
+        
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace))
+            elements = epr.getExtensibleElements();
+        else
+            elements = epr.getMetaData();
+        
+        if (elements != null) {
+            //Retrieve the service name and endpoint name.
+            for (int i = 0, size = elements.size(); i < size; i++) {
+                OMElement omElement = (OMElement) elements.get(i);
+                if (ServiceName.isServiceNameElement(omElement)) {
+                    try {
+                        serviceName.fromOM(omElement);
+                        break;
+                    }
+                    catch (Exception e) {
+                        //TODO NLS enable.
+                        throw new AxisFault("Metadata conversion error.", e);
+                    }
+                }
+            }
+        }
+        
+        return serviceName;
+    }
+    
+    /**
+     * 
+     * @param epr
+     * @param addressingNamespace
+     * @return
+     * @throws AxisFault
+     */
+    public static WSDLLocation getWSDLLocationMetadata(EndpointReference epr, String addressingNamespace) throws AxisFault {
+        WSDLLocation wsdlLocation = new WSDLLocation();
+        List attributes = null;
+
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace))
+            attributes = epr.getAttributes();
+        else
+            attributes = epr.getMetadataAttributes();
+        
+        if (attributes != null) {
+            //Retrieve the wsdl location.
+            for (int i = 0, size = attributes.size(); i < size; i++) {
+                OMAttribute omAttribute = (OMAttribute) attributes.get(i);
+                if (WSDLLocation.isWSDLLocationAttribute(omAttribute)) {
+                    try {
+                        wsdlLocation.fromOM(omAttribute);
+                        break;
+                    }
+                    catch (Exception e) {
+                        //TODO NLS enable.
+                        throw new AxisFault("Metadata conversion error.", e);
+                    }
+                }
+            }
+        }
+        
+        return wsdlLocation;
+    }
 
+    /**
+     * 
+     * @param epr
+     * @param addressingNamespace
+     * @param serviceName
+     * @throws AxisFault
+     */
+    public static void setServiceNameMetadata(EndpointReference epr, String addressingNamespace, ServiceName serviceName) throws AxisFault {
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
+            OMElement omElement = serviceName.toOM(ServiceName.subQName);
+            epr.addExtensibleElement(omElement);
+        }
+        else {
+            OMElement omElement = serviceName.toOM(ServiceName.finalQName);
+            epr.addMetaData(omElement);
+        }
+    }
+    
+    /**
+     * 
+     * @param epr
+     * @param addressingNamespace
+     * @return
+     * @throws AxisFault
+     */
+    public static void setWSDLLocationMetadata(EndpointReference epr, String addressingNamespace, WSDLLocation wsdlLocation) throws AxisFault {
+        OMAttribute attribute = wsdlLocation.toOM();
+
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
+            epr.addAttribute(attribute);
+        }
+        else {
+            ArrayList list = new ArrayList();
+            list.add(attribute);
+            epr.setMetadataAttributes(list);
+        }
+    }
+    
+    /**
+     * 
+     * @param source
+     * @param destination
+     */
+    public static void transferReferenceParameters(EndpointReference source, EndpointReference destination) {
+        Map referenceParameters = source.getAllReferenceParameters();
+        Iterator iterator = referenceParameters.values().iterator();
+        while (iterator.hasNext()) {
+            destination.addReferenceParameter((OMElement) iterator.next());                        
+        }
+    }
+    
     static {
         finalQNames.put(AddressingConstants.EPR_ADDRESS, new QName(
                 AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS));

Added: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/InterfaceName.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/InterfaceName.java?view=auto&rev=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/InterfaceName.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/InterfaceName.java Tue May 29 13:23:45 2007
@@ -0,0 +1,157 @@
+/*
+ * 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.addressing.metadata;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+
+public class InterfaceName {
+    public static final QName subQName = new QName(Submission.WSA_NAMESPACE, Submission.WSA_INTERFACE_NAME, AddressingConstants.WSA_DEFAULT_PREFIX);
+    public static final QName finalQName = new QName(Final.WSAM_NAMESPACE, Final.WSA_INTERFACE_NAME, Final.WSA_DEFAULT_METADATA_PREFIX);
+    
+    /**
+     * Field name
+     */
+    private QName name;
+
+    /**
+     * 
+     */
+    public InterfaceName() {
+    }
+
+    /**
+     * @param name
+     */
+    public InterfaceName(QName name) {
+        this.name = name;
+    }
+
+    /**
+     * Method getName
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * Method setName
+     *
+     * @param name
+     */
+    public void setName(QName name) {
+        this.name = name;
+    }
+    
+    /**
+     * Convenience method to convert objects of this type to an {@link OMElement} so that it
+     * can be added to an {@link org.apache.axis2.addressing.EndpointReference}
+     * 
+     * <p>Use:</p>
+     * <p>
+     * OMElement omElement =
+     * serviceName.toOM(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing", "PortType", "wsa"));
+     * </p>
+     * <p>or</p>
+     * <p>
+     * OMElement omElement =
+     * serviceName.toOM(new QName("http://www.w3.org/2007/02/addressing/metadata", "InterfaceName", "wsam"));
+     * </p>
+     * <p>
+     * the difference being whether the EndpointReference is meant to represent a 2004/08
+     * (Submission) or 2005/08 (Final) EndpointReference, respectively.
+     * </p>
+     * 
+     * @param qname the <code>QName</code> that carries the namespace of the metadata element.
+     * @return an OMElement that can be added to the metadata of an EndpointReference.
+     */
+    public OMElement toOM(QName qname) throws AxisFault {
+        String prefix = qname.getPrefix();
+        if (prefix == null) {
+            throw new AxisFault("The prefix cannot be null.");
+        }
+        
+        String localName = qname.getLocalPart();
+        if (!Final.WSA_INTERFACE_NAME.equals(localName) && !Submission.WSA_INTERFACE_NAME.equals(localName)) {
+            throw new AxisFault("The local name must be 'InterfaceName' or 'PortType'.");
+        }
+        
+        String namespace = qname.getNamespaceURI();
+        if (namespace == null) {
+            throw new AxisFault("The namespace canot be null.");
+        }
+            
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace metadataNs = fac.createOMNamespace(namespace, prefix);
+        OMElement element = fac.createOMElement(localName, metadataNs);
+        element.setText(name);
+
+        return element;
+    }
+    
+    /**
+     * Convenience method to extract metadata from an element.
+     * 
+     * <p>
+     * &lt;wsam:InterfaceName xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata"&gt;...&lt;/wsam:ServiceName&gt;
+     * </p>
+     * <p>or</p>
+     * <p>
+     * &lt;wsa:PortType xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"&gt;...&lt;/wsa:ServiceName&gt;
+     * </p>
+     * 
+     * @param omElement the <code>OMElement</code> that holds the metadata.
+     */
+    public void fromOM(OMElement omElement) throws AxisFault {
+        QName qname = omElement.getQName();
+        
+        if (!finalQName.equals(qname) && !subQName.equals(qname)) {
+            throw new AxisFault("Unrecognized element.");
+        }
+
+        name = omElement.getTextAsQName();
+    }
+    
+    /**
+     * Static method to test whether an <code>OMElement</code> is recognized
+     * as a ServiceName element. If this method returns <code>true</code> then
+     * {@link #fromOM(OMElement)} is guaranteed not to fail.
+     * 
+     * @param omElement the <code>OMElement</code> to test.
+     * @return <code>true</code> if the element is a ServiceName element,
+     * <code>false</code> otherwise.
+     */
+    public static boolean isInterfaceNameElement(OMElement omElement) {
+        boolean result = false;
+        QName qname = omElement.getQName();
+        
+        if (finalQName.equals(qname) || subQName.equals(qname))
+            result = true;
+        
+        return result;
+    }
+}

Added: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/ServiceName.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/ServiceName.java?view=auto&rev=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/ServiceName.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/ServiceName.java Tue May 29 13:23:45 2007
@@ -0,0 +1,202 @@
+/*
+ * 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.addressing.metadata;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+
+public class ServiceName {
+    public static final QName subQName = new QName(Submission.WSA_NAMESPACE, AddressingConstants.EPR_SERVICE_NAME, AddressingConstants.WSA_DEFAULT_PREFIX);
+    public static final QName finalQName = new QName(Final.WSAM_NAMESPACE, AddressingConstants.EPR_SERVICE_NAME, Final.WSA_DEFAULT_METADATA_PREFIX);
+    
+    /**
+     * Field name
+     */
+    private QName name;
+
+    /**
+     * Field portName
+     */
+    private String endpointName;
+    
+    /**
+     * 
+     *
+     */
+    public ServiceName() {
+    }
+
+    /**
+     * @param name
+     */
+    public ServiceName(QName name) {
+        this.name = name;
+    }
+
+    /**
+     * @param name
+     * @param endpointName
+     */
+    public ServiceName(QName name, String endpointName) {
+        this.name = name;
+        this.endpointName = endpointName;
+    }
+
+    /**
+     * Method getName
+     */
+    public QName getName() {
+        return name;
+    }
+
+    /**
+     * Method getPortName
+     */
+    public String getEndpointName() {
+        return endpointName;
+    }
+
+    /**
+     * Method setName
+     *
+     * @param name
+     */
+    public void setName(QName name) {
+        this.name = name;
+    }
+
+    /**
+     * Method setPortName
+     *
+     * @param endpointName
+     */
+    public void setEndpointName(String endpointName) {
+        this.endpointName = endpointName;
+    }
+    
+    /**
+     * Convenience method to convert objects of this type to an {@link OMElement} so that it
+     * can be added to an {@link org.apache.axis2.addressing.EndpointReference}
+     * 
+     * <p>Use:</p>
+     * <p>
+     * OMElement omElement =
+     * serviceName.toOM(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing", "ServiceName", "wsa"));
+     * </p>
+     * <p>or</p>
+     * <p>
+     * OMElement omElement =
+     * serviceName.toOM(new QName("http://www.w3.org/2007/02/addressing/metadata", "ServiceName", "wsam"));
+     * </p>
+     * <p>
+     * the difference being whether the EndpointReference is meant to represent a 2004/08
+     * (Submission) or 2005/08 (Final) EndpointReference, respectively.
+     * </p>
+     * 
+     * @param qname the <code>QName</code> that carries the namespace of the metadata element.
+     * @return an OMElement that can be added to the metadata of an EndpointReference.
+     */
+    public OMElement toOM(QName qname) throws AxisFault {
+        String localName = qname.getLocalPart();
+        if (!AddressingConstants.EPR_SERVICE_NAME.equals(localName)) {
+            throw new AxisFault("The local name must be 'ServiceName'.");
+        }
+        
+        String prefix = qname.getPrefix();
+        if (prefix == null) {
+            throw new AxisFault("The prefix cannot be null.");
+        }
+        
+        String namespace = qname.getNamespaceURI();
+        if (namespace == null) {
+            throw new AxisFault("The namespace canot be null.");
+        }
+            
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace metadataNs = fac.createOMNamespace(namespace, prefix);
+        OMElement element = fac.createOMElement(localName, metadataNs);
+        element.setText(name);
+        
+        if (endpointName != null) {
+            String attributeName =
+                Submission.WSA_NAMESPACE.equals(namespace) ?
+                        Submission.WSA_SERVICE_NAME_ENDPOINT_NAME : Final.WSA_SERVICE_NAME_ENDPOINT_NAME;
+            element.addAttribute(attributeName, endpointName, null);
+        }
+
+        return element;
+    }
+    
+    /**
+     * Convenience method to extract metadata from the ServiceName element.
+     * 
+     * <p>
+     * &lt;wsam:ServiceName xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata" EndpointName="..."&gt;...&lt;/wsam:ServiceName&gt;
+     * </p>
+     * <p>or</p>
+     * <p>
+     * &lt;wsa:ServiceName xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" PortName="..."&gt;...&lt;/wsa:ServiceName&gt;
+     * </p>
+     * 
+     * @param omElement the <code>OMElement</code> that holds the metadata.
+     */
+    public void fromOM(OMElement omElement) throws AxisFault {
+        QName qname = omElement.getQName();
+        String attributeName = null;
+        if (finalQName.equals(qname)) {
+            attributeName = Final.WSA_SERVICE_NAME_ENDPOINT_NAME;
+        }
+        else if (subQName.equals(qname)) {
+            attributeName = Submission.WSA_SERVICE_NAME_ENDPOINT_NAME;
+        }
+        else {
+            throw new AxisFault("Unrecognized element.");
+        }
+
+        name = omElement.getTextAsQName();
+        endpointName = omElement.getAttributeValue(new QName(attributeName));
+    }
+    
+    /**
+     * Static method to test whether an <code>OMElement</code> is recognized
+     * as a ServiceName element. If this method returns <code>true</code> then
+     * {@link #fromOM(OMElement)} is guaranteed not to fail.
+     * 
+     * @param omElement the <code>OMElement</code> to test.
+     * @return <code>true</code> if the element is a ServiceName element,
+     * <code>false</code> otherwise.
+     */
+    public static boolean isServiceNameElement(OMElement omElement) {
+        boolean result = false;
+        QName qname = omElement.getQName();
+        
+        if (finalQName.equals(qname) || subQName.equals(qname))
+            result = true;
+        
+        return result;
+    }
+}

Added: webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java?view=auto&rev=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java (added)
+++ webservices/axis2/branches/java/jaxws21/modules/kernel/src/org/apache/axis2/addressing/metadata/WSDLLocation.java Tue May 29 13:23:45 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.addressing.metadata;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+
+public class WSDLLocation {
+    private static final QName WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
+    
+    private String targetNamespace;
+    private String wsdlURL;
+    
+    public WSDLLocation() {
+    }
+    
+    public WSDLLocation(String targetNamespace, String wsdlURL) {
+        this.targetNamespace = targetNamespace;
+        this.wsdlURL = wsdlURL;
+    }
+    
+    public String getTargetNamespace() {
+        return targetNamespace;
+    }
+    public void setTargetNamespace(String targetNamespace) {
+        this.targetNamespace = targetNamespace;
+    }
+    public String getURL() {
+        return wsdlURL;
+    }
+    public void setURL(String wsdlURL) {
+        this.wsdlURL = wsdlURL;
+    }
+    
+    /**
+     * Convenience method to convert an object of this type to an <code>OMAttribute</code>
+     * 
+     * @return an <code>OMAttribute</code> that can be added to an <code>EndpointReference</code>
+     */
+    public OMAttribute toOM() {
+        String value = new StringBuffer(targetNamespace).append(" ").append(wsdlURL).toString();
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace wsdliNs = fac.createOMNamespace(WSDLI.getNamespaceURI(), WSDLI.getPrefix());
+        OMAttribute omAttribute = fac.createOMAttribute(WSDLI.getLocalPart(), wsdliNs, value);
+        
+        return omAttribute;
+    }
+    
+    /**
+     * Convenience method for converting an OMAttribute to an instance of this type.
+     * <p>
+     * &lt;... xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...&gt
+     * </p>
+     * @param omAttribute the <code>OMAttribute</code> that holds the wsdl location.
+     * @throws AxisFault
+     */
+    public void fromOM(OMAttribute omAttribute) throws AxisFault {
+        QName qname = omAttribute.getQName();
+        if (WSDLI.equals(qname)) {
+           String value = omAttribute.getAttributeValue().trim();
+           String[] values = value.split("\\s", 2);
+           
+           //Don't set any values if split doesn't
+           //give us the correct number of elements.
+           if (values.length != 2)
+               return;
+           
+           targetNamespace = values[0];
+           wsdlURL = values[1];
+        }
+        else {
+            throw new AxisFault("Unrecognized element.");
+        }
+    }
+    
+    
+    /**
+     * Static method to test whether an <code>OMElement</code> is recognized
+     * as a ServiceName element. If this method returns <code>true</code> then
+     * {@link #fromOM(OMAttribute)} is guaranteed not to throw an exception.
+     * 
+     * @param omAttribute the <code>OMElement</code> to test.
+     * @return <code>true</code> if the element is a ServiceName element,
+     * <code>false</code> otherwise.
+     */
+    public static boolean isWSDLLocationAttribute(OMAttribute omAttribute) {
+        boolean result = false;
+        QName qname = omAttribute.getQName();
+        
+        if (WSDLI.equals(qname))
+            result = true;
+        
+        return result;
+    }
+}

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java Tue May 29 13:23:45 2007
@@ -1,29 +1,31 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed 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
- *
+ * 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.
+ *      
+ * 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.description;
 
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
 
 import javax.xml.namespace.QName;
+
 import java.net.URL;
 import java.util.HashMap;
 import java.util.List;
@@ -93,6 +95,35 @@
                                                      DescriptionFactory.UpdateType updateType) {
         return DescriptionFactoryImpl
                 .updateEndpoint(serviceDescription, sei, portQName, updateType);
+    }
+
+    /**
+     * Retrieve or create the EndpointDescription hierachy associated with an existing CLIENT side
+     * ServiceDescription for a particular port.  If an EndpointDescritption already exists, it will
+     * be returned; if one does not already exist, it will be created.  Note that if the SEI is null
+     * then the EndpointDescription returned will be for a Dispatch client only and it will not have
+     * an EndpointInterfaceDescription hierachy associated with it.  If, at a later point, the same
+     * port is requested and an SEI is provided, the existing EndpointDescription will be updated
+     * with a newly-created EndpointInterfaceDescription hieracy.
+     *
+     * @param serviceDescription  An existing client-side ServiceDescription.  This must not be
+     *                            null.
+     * @param sei                 The ServiceInterface class.  This can be null for adding a port or
+     *                            creating a Dispatch; it can not be null when getting a port.
+     * @param epr                 The endpoint reference to the target port.
+     * @param addressingNamespace The addressing namespace of the endpoint reference.
+     * @param updateType          The type of the update: adding a port, creating a dispatch, or
+     *                            getting an SEI-based port.
+     * @return An EndpointDescription corresponding to the port.
+     * @see #createServiceDescription(URL, QName, Class)
+     * @see DescriptionFactory.UpdateType
+     */
+    public static EndpointDescription updateEndpoint(ServiceDescription serviceDescription,
+                                                     Class sei, EndpointReference epr,
+                                                     String addressingNamespace,
+                                                     DescriptionFactory.UpdateType updateType) {
+        return DescriptionFactoryImpl
+                .updateEndpoint(serviceDescription, sei, epr, addressingNamespace, updateType);
     }
 
     /**

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceContextAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceContextAnnot.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceContextAnnot.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceContextAnnot.java Tue May 29 13:23:45 2007
@@ -1,23 +1,28 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed 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
- *
+ * 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.
+ *      
+ * 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.description.builder;
 
+import javax.xml.ws.EndpointReference;
 import javax.xml.ws.handler.MessageContext;
+
+import org.w3c.dom.Element;
+
 import java.lang.annotation.Annotation;
 import java.security.Principal;
 
@@ -88,10 +93,20 @@
         this.userPrincipal = userPrincipal;
     }
 
+    public <T extends EndpointReference> T getEndpointReference(Class<T> arg0, Element... arg1) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public EndpointReference getEndpointReference(Element... arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 
     //hmm, should we really do this
     public Class<Annotation> annotationType() {
         return Annotation.class;
-	}
+    }
 	
 }

Modified: webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?view=diff&rev=542643&r1=542642&r2=542643
==============================================================================
--- webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java (original)
+++ webservices/axis2/branches/java/jaxws21/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java Tue May 29 13:23:45 2007
@@ -22,6 +22,9 @@
  * 
  */
 
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.metadata.ServiceName;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.ClientConfigurationFactory;
@@ -235,6 +238,35 @@
             log.debug("EndpointDescription updated: " + endpointDesc);
         }
         return endpointDesc;
+    }
+
+    /**
+     * @see org.apache.axis2.jaxws.description.DescriptionFactory#updateEndpoint(ServiceDescription,
+     *      Class, EndpointReference, String, DescriptionFactory.UpdateType)
+     */
+    public static EndpointDescription updateEndpoint(
+            ServiceDescription serviceDescription, Class sei, EndpointReference epr,
+            String addressingNamespace,
+            DescriptionFactory.UpdateType updateType) {
+        QName portQName = null;
+        
+        try {
+            ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(epr, addressingNamespace);
+            QName serviceQName = serviceDescription.getServiceQName();
+            
+            if (!serviceQName.equals(serviceName.getName()))
+                throw ExceptionFactory.makeWebServiceException("The service name of the endpoint reference does not match the service name of the service client.");
+            
+            //An assumption is made here that the namespace associated with the ServiceName also
+            //applies to the PortName.
+            portQName = new QName(serviceQName.getNamespaceURI(), serviceName.getEndpointName());
+        }
+        catch (Exception e) {
+            //TODO NLS enable.
+            throw ExceptionFactory.makeWebServiceException("An error occured updating the endpoint", e);
+        }
+        
+        return updateEndpoint(serviceDescription, sei, portQName, updateType);
     }
 
     public static ClientConfigurationFactory getClientConfigurationFactory() {



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