View Javadoc

1   /*
2    * Copyright 2005-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.wsdl.wsdl11.provider;
18  
19  import java.util.Properties;
20  import javax.wsdl.Definition;
21  import javax.wsdl.WSDLException;
22  
23  /**
24   * Implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces that supports SOAP 1.1 and
25   * SOAP 1.2. Delegates to {@link Soap11Provider} and {@link Soap12Provider}.
26   * <p/>
27   * By setting the {@link #setSoapActions(java.util.Properties) soapActions} property, the SOAP Actions defined in the
28   * resulting WSDL can be set. Additionally, the transport uri can be changed from the default HTTP transport by using the
29   * {@link #setTransportUri(String) transportUri} property.
30   * <p/>
31   * The {@link #setCreateSoap11Binding(boolean) createSoap11} and {@link #setCreateSoap12Binding(boolean) createSoap12}
32   * properties indicate whether a SOAP 1.1 or SOAP 1.2 binding should be created. These properties default to
33   * <code>true</code> and <code>false</code> respectively.
34   *
35   * @author Arjen Poutsma
36   * @since 1.5.0
37   */
38  public class SoapProvider implements BindingsProvider, ServicesProvider {
39  
40      private final Soap11Provider soap11BindingProvider = new Soap11Provider();
41  
42      private final Soap12Provider soap12BindingProvider = new Soap12Provider();
43  
44      private boolean createSoap11Binding = true;
45  
46      private boolean createSoap12Binding = false;
47  
48      /**
49       * Indicates whether a SOAP 1.1 binding should be created.
50       * <p/>
51       * Defaults to <code>true</code>.
52       */
53      public void setCreateSoap11Binding(boolean createSoap11Binding) {
54          this.createSoap11Binding = createSoap11Binding;
55      }
56  
57      /**
58       * Indicates whether a SOAP 1.2 binding should be created.
59       * <p/>
60       * Defaults to <code>false</code>.
61       */
62      public void setCreateSoap12Binding(boolean createSoap12Binding) {
63          this.createSoap12Binding = createSoap12Binding;
64      }
65  
66      /**
67       * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation
68       * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}.
69       *
70       * @param soapActions the soap
71       */
72      public void setSoapActions(Properties soapActions) {
73          soap11BindingProvider.setSoapActions(soapActions);
74          soap12BindingProvider.setSoapActions(soapActions);
75      }
76  
77      /** Sets the value used for the binding transport attribute value. Defaults to HTTP. */
78      public void setTransportUri(String transportUri) {
79          soap11BindingProvider.setTransportUri(transportUri);
80          soap12BindingProvider.setTransportUri(transportUri);
81      }
82  
83      /** Sets the value used for the SOAP Address location attribute value. */
84      public void setLocationUri(String locationUri) {
85          soap11BindingProvider.setLocationUri(locationUri);
86          soap12BindingProvider.setLocationUri(locationUri);
87      }
88  
89      /** Sets the service name. */
90      public void setServiceName(String serviceName) {
91          soap11BindingProvider.setServiceName(serviceName);
92          soap12BindingProvider.setServiceName(serviceName);
93      }
94  
95      public void addBindings(Definition definition) throws WSDLException {
96          if (createSoap11Binding) {
97              soap11BindingProvider.addBindings(definition);
98          }
99          if (createSoap12Binding) {
100             soap12BindingProvider.addBindings(definition);
101         }
102     }
103 
104     public void addServices(Definition definition) throws WSDLException {
105         if (createSoap11Binding) {
106             soap11BindingProvider.addServices(definition);
107         }
108         if (createSoap12Binding) {
109             soap12BindingProvider.addServices(definition);
110         }
111     }
112 }