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 ng...@apache.org on 2007/04/16 22:45:48 UTC

svn commit: r529395 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/binding/ src/org/apache/axis2/jaxws/server/endpoint/ test/org/apache/axis2/jaxws/endpoint/

Author: ngallardo
Date: Mon Apr 16 13:45:47 2007
New Revision: 529395

URL: http://svn.apache.org/viewvc?view=rev&rev=529395
Log:
AXIS2-2539

Set the right binding type on the Endpoint.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java
Modified:
    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/server/endpoint/EndpointImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java?view=auto&rev=529395
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java Mon Apr 16 13:45:47 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.binding;
+
+import javax.xml.ws.Binding;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+
+public class BindingUtils {
+
+    /**
+     * Creates a Binding instance based on an EndpointDescription.
+     * @param ed
+     * @return
+     */
+    public static Binding createBinding(EndpointDescription ed) {
+        if (ed == null) {
+            // Do we default to the SOAPBinding?            
+        }
+        
+        String bindingType = ed.getBindingType();
+        if (BindingUtils.isSOAPBinding(bindingType)) {
+            return new SOAPBinding(ed);
+        }
+        else if (BindingUtils.isHTTPBinding(bindingType)) { 
+            return new HTTPBinding(ed);
+        }
+        else {
+            // If we can't figure it out, let's default to 
+            // a SOAPBinding
+            return new SOAPBinding(ed);
+        }
+    }
+    
+    public static boolean isSOAPBinding(String url) {
+        if (url != null && (url.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
+                url.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+                url.equals(SOAPBinding.SOAP12HTTP_BINDING)|| 
+                url.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
+            return true;
+        }
+        return false;
+    }
+    
+    public static boolean isHTTPBinding(String url) {
+        if (url != null && url.equals(HTTPBinding.HTTP_BINDING)) {
+            return true;
+        }
+        return false;
+    }
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java?view=auto&rev=529395
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java Mon Apr 16 13:45:47 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.binding;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+
+public class HTTPBinding extends BindingImpl implements javax.xml.ws.http.HTTPBinding {
+
+    public HTTPBinding(EndpointDescription ed) {
+        super(ed);
+    }
+
+}
\ No newline at end of file

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?view=diff&rev=529395&r1=529394&r2=529395
==============================================================================
--- 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 Apr 16 13:45:47 2007
@@ -1,18 +1,20 @@
 /*
- * Copyright 2006 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.binding;
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java?view=diff&rev=529395&r1=529394&r2=529395
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java Mon Apr 16 13:45:47 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.binding.BindingImpl;
+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;
@@ -69,8 +70,8 @@
             endpointDesc = sd.getEndpointDescriptions_AsCollection().iterator().next();
         }
         
-        if (endpointDesc != null) {
-            binding = new BindingImpl(endpointDesc);
+        if (endpointDesc != null && binding == null) {
+            binding = BindingUtils.createBinding(endpointDesc);
         }
         
         published = false;

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java?view=diff&rev=529395&r1=529394&r2=529395
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/endpoint/BasicEndpointTests.java Mon Apr 16 13:45:47 2007
@@ -19,7 +19,9 @@
 package org.apache.axis2.jaxws.endpoint;
 
 import javax.jws.WebService;
+import javax.xml.ws.Binding;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.soap.SOAPBinding;
 
 import junit.framework.TestCase;
 
@@ -35,7 +37,19 @@
         assertTrue("The endpoint was not published successfully", ep.isPublished());
     }
     
-    @WebService
+    public void testGetBinding() throws Exception {
+        SampleEndpoint sample = new SampleEndpoint();
+
+        Endpoint ep = Endpoint.create(sample);
+        assertTrue("The returned Endpoint instance was null", ep != null);
+
+        Binding bnd = ep.getBinding();
+        assertTrue("The returned Binding instance was null", bnd != null);
+        assertTrue("The returned Binding instance was of the wrong type (" + bnd.getClass().getName() + "), expected SOAPBinding", 
+                SOAPBinding.class.isAssignableFrom(bnd.getClass()));
+    }
+    
+        @WebService
     class SampleEndpoint {
         
         public int foo(String bar) {



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