You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ga...@apache.org on 2007/04/13 03:47:15 UTC
svn commit: r528309 - in /incubator/cxf/trunk/rt/frontend/jaxws/src:
main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties
main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
Author: gawor
Date: Thu Apr 12 18:47:14 2007
New Revision: 528309
URL: http://svn.apache.org/viewvc?view=rev&rev=528309
Log:
implement some SOAPBinding methods (even though they are not being used right now)
Added:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties (with props)
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java (with props)
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties?view=auto&rev=528309
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties Thu Apr 12 18:47:14 2007
@@ -0,0 +1,23 @@
+#
+#
+# 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.
+#
+#
+NONE_ROLE_ERR = None role cannot be set.
+SAAJ_FACTORY_ERR = Cannot create SAAJ factory instance.
+
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java?view=diff&rev=528309&r1=528308&r2=528309
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java Thu Apr 12 18:47:14 2007
@@ -19,53 +19,88 @@
package org.apache.cxf.jaxws.binding.soap;
-
+import java.util.ResourceBundle;
import java.util.Set;
+import java.util.logging.Logger;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPBinding;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.Soap12;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxws.binding.BindingImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.service.model.BindingInfo;
public class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
-
- private BindingInfo soapBinding;
+ private static final Logger LOG = LogUtils.getL7dLogger(SOAPBindingImpl.class);
+ private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
- // private SoapBinding soapBinding;
+ private BindingInfo soapBinding;
+ private Set<String> roles;
public SOAPBindingImpl(BindingInfo sb) {
- soapBinding = sb;
-
+ soapBinding = sb;
}
public Set<String> getRoles() {
- return null;
+ return this.roles;
}
public void setRoles(Set<String> set) {
- // TODO
+ if (set != null
+ && (set.contains(Soap11.getInstance().getNoneRole())
+ || set.contains(Soap12.getInstance().getNoneRole()))) {
+ throw new WebServiceException(BUNDLE.getString("NONE_ROLE_ERR"));
+ }
+ this.roles = set;
}
public boolean isMTOMEnabled() {
return Boolean.TRUE.equals(soapBinding.getProperty(Message.MTOM_ENABLED));
}
- public void setMTOMEnabled(boolean flag) {
-
+ public void setMTOMEnabled(boolean flag) {
soapBinding.setProperty(Message.MTOM_ENABLED, flag);
}
public MessageFactory getMessageFactory() {
- // TODO: get from wrapped SoapBinding
+ if (this.soapBinding instanceof SoapBindingInfo) {
+ SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding;
+ try {
+ if (bindingInfo.getSoapVersion() instanceof Soap11) {
+ return MessageFactory.newInstance();
+ } else if (bindingInfo.getSoapVersion() instanceof Soap12) {
+ return MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ }
+ } catch (SOAPException e) {
+ throw new WebServiceException(BUNDLE.getString("SAAJ_FACTORY_ERR"), e);
+ }
+ }
return null;
- }
+ }
public SOAPFactory getSOAPFactory() {
- // TODO: get from wrapped SoapBinding
+ if (this.soapBinding instanceof SoapBindingInfo) {
+ SoapBindingInfo bindingInfo = (SoapBindingInfo) this.soapBinding;
+ try {
+ if (bindingInfo.getSoapVersion() instanceof Soap11) {
+ return SOAPFactory.newInstance();
+ } else if (bindingInfo.getSoapVersion() instanceof Soap12) {
+ return SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ }
+ } catch (SOAPException e) {
+ throw new WebServiceException(BUNDLE.getString("SAAJ_FACTORY_ERR"), e);
+ }
+ }
return null;
}
+
}
Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java?view=auto&rev=528309
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java Thu Apr 12 18:47:14 2007
@@ -0,0 +1,96 @@
+/**
+ * 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.cxf.jaxws;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.calculator.CalculatorPortType;
+import org.junit.Test;
+
+public class SOAPBindingTest extends AbstractJaxWsTest {
+
+ private static final QName SERVICE_1 =
+ new QName("http://apache.org/cxf/calculator", "CalculatorService");
+
+ private static final QName PORT_1 =
+ new QName("http://apache.org/cxf/calculator", "CalculatorPort");
+
+ @Test
+ public void testRoles() throws Exception {
+ URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
+ assertNotNull(wsdl1);
+
+ ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
+
+ CalculatorPortType cal = (CalculatorPortType)service.getPort(PORT_1, CalculatorPortType.class);
+
+ BindingProvider bindingProvider = (BindingProvider)cal;
+
+ assertTrue(bindingProvider.getBinding() instanceof SOAPBinding);
+ SOAPBinding binding = (SOAPBinding)bindingProvider.getBinding();
+
+ assertNull(binding.getRoles());
+
+ Set<String> roles = new HashSet<String>();
+ roles.add(Soap11.getInstance().getNextRole());
+
+ binding.setRoles(roles);
+
+ assertNotNull(binding.getRoles());
+ assertEquals(1, binding.getRoles().size());
+ assertEquals(Soap11.getInstance().getNextRole(), binding.getRoles().iterator().next());
+
+ roles.add(Soap11.getInstance().getNoneRole());
+
+ try {
+ binding.setRoles(roles);
+ fail("did not throw exception");
+ } catch (WebServiceException e) {
+ // that's expected with none role
+ }
+ }
+
+ @Test
+ public void testSAAJ() throws Exception {
+ URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
+ assertNotNull(wsdl1);
+
+ ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
+
+ CalculatorPortType cal = (CalculatorPortType)service.getPort(PORT_1, CalculatorPortType.class);
+
+ BindingProvider bindingProvider = (BindingProvider)cal;
+
+ assertTrue(bindingProvider.getBinding() instanceof SOAPBinding);
+ SOAPBinding binding = (SOAPBinding)bindingProvider.getBinding();
+
+ assertNotNull(binding.getMessageFactory());
+
+ assertNotNull(binding.getSOAPFactory());
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SOAPBindingTest.java
------------------------------------------------------------------------------
svn:eol-style = native