You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pr...@apache.org on 2008/02/18 16:01:56 UTC

svn commit: r628773 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: BindingProvider.java binding/BindingImpl.java binding/SOAPBinding.java client/config/AddressingConfigurator.java spi/Binding.java spi/BindingProvider.java

Author: pradine
Date: Mon Feb 18 07:01:47 2008
New Revision: 628773

URL: http://svn.apache.org/viewvc?rev=628773&view=rev
Log:
As the org.apache.axis2.jaxws.spi.BindingProvider interface is added to the proxies returned by JAX-WS move the getAxis2EndpointReference() and getAddressingNamespace() methods to the org.apache.axis2.jaxws.spi.Binding interface instead.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Binding.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/BindingProvider.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Mon Feb 18 07:01:47 2008
@@ -54,10 +54,6 @@
     protected EndpointDescription endpointDesc;
 
     protected ServiceDelegate serviceDelegate;
-    
-    protected org.apache.axis2.addressing.EndpointReference epr;
-    
-    protected String addressingNamespace;
 
     private org.apache.axis2.jaxws.spi.Binding binding;
 
@@ -68,16 +64,16 @@
                            WebServiceFeature... features) {
         this.endpointDesc = epDesc;
         this.serviceDelegate = svcDelegate;
-        this.epr = epr;
-        this.addressingNamespace = addressingNamespace;
         
-        initialize(features);
+        initialize(epr, addressingNamespace, features);
     }
 
     /*
      * Initialize any objects needed by the BindingProvider
      */
-    private void initialize(WebServiceFeature... features) {
+    private void initialize(org.apache.axis2.addressing.EndpointReference epr,
+                            String addressingNamespace,
+                            WebServiceFeature... features) {
         requestContext = new ValidatingClientContext();
         responseContext = new ValidatingClientContext();
         
@@ -121,7 +117,15 @@
         }
         binding.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));
         
-        binding.setFeatures(features);
+        //Set JAX-WS 2.1 related properties.
+        try {
+            binding.setAxis2EndpointReference(epr);
+            binding.setAddressingNamespace(addressingNamespace);
+            binding.setFeatures(features);
+        }
+        catch (Exception e) {
+            throw ExceptionFactory.makeWebServiceException(e);
+        }
     }
 
     public ServiceDelegate getServiceDelegate() {
@@ -227,20 +231,44 @@
         }
     }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.xml.ws.BindingProvider#getEndpointReference()
+     */
     public EndpointReference getEndpointReference() {
         return getEndpointReference(W3CEndpointReference.class);
     }
 
+    /*
+     *  (non-Javadoc)
+     * @see javax.xml.ws.BindingProvider#getEndpointReference(java.lang.Class)
+     */
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
         EndpointReference jaxwsEPR = null;
         String addressingNamespace = EndpointReferenceUtils.getAddressingNamespace(clazz);
         
-        if (!BindingUtils.isSOAPBinding(binding.getBindingID()))
-            throw new UnsupportedOperationException("This method is unsupported for the binding: " + binding.getBindingID());
-        
         try {
-            org.apache.axis2.addressing.EndpointReference epr =
-                getAxis2EndpointReference(addressingNamespace);
+            org.apache.axis2.addressing.EndpointReference epr = binding.getAxis2EndpointReference();
+            
+            if (epr == null) {
+                String address =
+                    (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+                if (address == null)
+                    address = endpointDesc.getEndpointAddress();
+                QName service = endpointDesc.getServiceQName();
+                QName port = endpointDesc.getPortQName();
+                URL wsdlURL =
+                    ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
+                String wsdlLocation = (wsdlURL != null) ? wsdlURL.toString() : null;
+
+                epr = EndpointReferenceUtils.createAxis2EndpointReference(address, service, port, wsdlLocation, addressingNamespace);
+            }
+            else if (!addressingNamespace.equals(binding.getAddressingNamespace())) {
+                //TODO NLS enable
+                throw ExceptionFactory.makeWebServiceException("BindingProvider has been cofigured for namespace " +
+                        binding.getAddressingNamespace() + ", but a request has been made for namespace " + addressingNamespace);
+            }
+
             jaxwsEPR = EndpointReferenceUtils.convertFromAxis2(epr, addressingNamespace);
         }
         catch (Exception e) {
@@ -250,47 +278,11 @@
         
         return clazz.cast(jaxwsEPR);
     }
-
-    public org.apache.axis2.addressing.EndpointReference getAxis2EndpointReference(String addressingNamespace) {
-        org.apache.axis2.addressing.EndpointReference epr = this.epr;
-        
-        //TODO NLS enable.
-        if (addressingNamespace == null)
-            throw ExceptionFactory.makeWebServiceException("The addressing namespace cannot be null.");
-        
-        if (epr == null) {
-            String address =
-                (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
-            if (address == null)
-                address = endpointDesc.getEndpointAddress();
-            QName service = endpointDesc.getServiceQName();
-            QName port = endpointDesc.getPortQName();
-            URL wsdlURL =
-                ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
-            String wsdlLocation = (wsdlURL != null) ? wsdlURL.toString() : null;
-
-            epr = EndpointReferenceUtils.createAxis2EndpointReference(address, service, port, wsdlLocation, addressingNamespace);
-        }
-        else if (!addressingNamespace.equals(this.addressingNamespace)) {
-            //TODO NLS enable
-            throw ExceptionFactory.makeWebServiceException("BindingProvider has been cofigured for namespace " +
-                    this.addressingNamespace + ", but a request has been made for namespace " + addressingNamespace);
-        }
-        
-        return epr;
-    }
-    
-    public String getAddressingNamespace() {
-        return addressingNamespace;
-    }
     
     /*
     * An inner class used to validate properties as they are set by the client.
     */
     class ValidatingClientContext extends Hashtable<String, Object> {
-        /**
-         * 
-         */
         private static final long serialVersionUID = 3485112205801917858L;
 
         @Override

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java Mon Feb 18 07:01:47 2008
@@ -25,6 +25,7 @@
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.handler.Handler;
 
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.feature.ClientConfigurator;
@@ -113,5 +114,25 @@
                 framework.addFeature(feature);
             }
         }
+    }
+    
+    public void setAddressingNamespace(String addressingNamespace) {
+        //TODO NLS enable
+        throw new UnsupportedOperationException("This method is not supported for the current binding, " + bindingId);   
+    }
+
+    public void setAxis2EndpointReference(EndpointReference epr) {
+        //TODO NLS enable
+        throw new UnsupportedOperationException("This method is not supported for the current binding, " + bindingId);   
+    }
+
+    public String getAddressingNamespace() {
+        //TODO NLS enable
+        throw new UnsupportedOperationException("This method is not supported for the current binding, " + bindingId);   
+    }
+
+    public EndpointReference getAxis2EndpointReference() {
+        //TODO NLS enable
+        throw new UnsupportedOperationException("This method is not supported for the current binding, " + bindingId);   
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java Mon Feb 18 07:01:47 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.axis2.jaxws.binding;
 
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
@@ -44,6 +45,10 @@
     private boolean mtomEnabled = false;
 
     private static Log log = LogFactory.getLog(SOAPBinding.class);
+    
+    private EndpointReference epr;
+    
+    private String addressingNamespace;
 
     public SOAPBinding(EndpointDescription endpointDesc) {
         super(endpointDesc);
@@ -216,4 +221,23 @@
         return returnSet;
     }
 
+    @Override
+    public String getAddressingNamespace() {
+        return addressingNamespace;
+    }
+
+    @Override
+    public EndpointReference getAxis2EndpointReference() {
+        return epr;
+    }
+
+    @Override
+    public void setAddressingNamespace(String addressingNamespace) {
+        this.addressingNamespace = addressingNamespace;
+    }
+
+    @Override
+    public void setAxis2EndpointReference(EndpointReference epr) {
+        this.epr = epr;
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java Mon Feb 18 07:01:47 2008
@@ -62,11 +62,10 @@
             boolean submissionAddressingEnabled = submissionAddressingFeature.isEnabled();
             
             if (w3cAddressingEnabled && submissionAddressingEnabled) {
-                //Use the addressing namespace of the specified EPR,
-                //else default to 2005/08
-                addressingNamespace = provider.getAddressingNamespace();
-                if (addressingNamespace == null)
-                    addressingNamespace = Final.WSA_NAMESPACE;
+                //Use the addressing namespace of the EPR specified
+                //via the JAX-WS 2.1 API. If no EPR was specified
+                //then the 2005/08 namespace will be used.
+                addressingNamespace = bnd.getAddressingNamespace();
                 disableAddressing = Boolean.FALSE;
             }
             else if (w3cAddressingEnabled) {
@@ -119,9 +118,12 @@
         
         if (!disableAddressing) {
             try {
-                EndpointReference epr = provider.getAxis2EndpointReference(addressingNamespace);
-                org.apache.axis2.context.MessageContext axis2MessageContext = messageContext.getAxisMessageContext();
-                axis2MessageContext.setTo(epr);
+                EndpointReference epr = bnd.getAxis2EndpointReference();
+                if (epr != null) {
+                    org.apache.axis2.context.MessageContext axis2MessageContext =
+                        messageContext.getAxisMessageContext();
+                    axis2MessageContext.setTo(epr);
+                }
                 
                 ServiceDescription sd = messageContext.getEndpointDescription().getServiceDescription();
                 AxisConfiguration axisConfig = sd.getAxisConfigContext().getAxisConfiguration();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Binding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Binding.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Binding.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Binding.java Mon Feb 18 07:01:47 2008
@@ -20,6 +20,7 @@
 
 import javax.xml.ws.WebServiceFeature;
 
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.jaxws.core.MessageContext;
 
 /**
@@ -31,4 +32,12 @@
     public WebServiceFeature getFeature(String id);
     
     public void configure(MessageContext messageContext, BindingProvider provider);
+    
+    public void setAxis2EndpointReference(EndpointReference epr);
+    
+    public void setAddressingNamespace(String addressingNamespace);
+    
+    public EndpointReference getAxis2EndpointReference();
+    
+    public String getAddressingNamespace();
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/BindingProvider.java?rev=628773&r1=628772&r2=628773&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/BindingProvider.java Mon Feb 18 07:01:47 2008
@@ -18,7 +18,6 @@
  */
 package org.apache.axis2.jaxws.spi;
 
-import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 
 /**
@@ -28,8 +27,4 @@
     public EndpointDescription getEndpointDescription();
 
     public ServiceDelegate getServiceDelegate();
-    
-    public EndpointReference getAxis2EndpointReference(String addressingNamespace);
-    
-    public String getAddressingNamespace();
 }



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