View Javadoc

1   /*
2    * Copyright 2007 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.soap.addressing.version;
18  
19  import java.net.URI;
20  import javax.xml.namespace.QName;
21  
22  import org.springframework.util.Assert;
23  import org.springframework.ws.soap.SoapMessage;
24  import org.springframework.ws.soap.addressing.core.EndpointReference;
25  import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
26  import org.springframework.xml.namespace.QNameUtils;
27  
28  /**
29   * Implements the August 2004 edition of the WS-Addressing specification. This version of the specification is used by
30   * Microsoft's Web Services Enhancements (WSE) 3.0, and supported by Axis 1 and 2, and XFire.
31   *
32   * @author Arjen Poutsma
33   * @see <a href="http://msdn.microsoft.com/ws/2004/08/ws-addressing/">Web Services Addressing, August 2004</a>
34   * @since 1.5.0
35   */
36  public class Addressing200408 extends AbstractAddressingVersion {
37  
38      private static final String NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
39  
40      public void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map) {
41          Assert.notNull(map.getAction(), "'Action' must not be null");
42          Assert.notNull(map.getTo(), "'Action' must not be null");
43          super.addAddressingHeaders(message, map);
44      }
45  
46      protected final URI getAnonymous() {
47          return URI.create(NAMESPACE_URI + "/role/anonymous");
48      }
49  
50      protected final String getInvalidAddressingHeaderFaultReason() {
51          return "A message information header is not valid and the message cannot be processed.";
52      }
53  
54      protected final QName getInvalidAddressingHeaderFaultSubcode() {
55          return QNameUtils.createQName(NAMESPACE_URI, "InvalidMessageInformationHeader", getNamespacePrefix());
56      }
57  
58      protected final String getMessageAddressingHeaderRequiredFaultReason() {
59          return "A required message information header, To, MessageID, or Action, is not present.";
60      }
61  
62      protected final QName getMessageAddressingHeaderRequiredFaultSubcode() {
63          return QNameUtils.createQName(NAMESPACE_URI, "MessageInformationHeaderRequired", getNamespacePrefix());
64      }
65  
66      protected final String getNamespaceUri() {
67          return NAMESPACE_URI;
68      }
69  
70      protected final EndpointReference getDefaultReplyTo(EndpointReference from) {
71          return from;
72      }
73  
74      protected final URI getNone() {
75          return null;
76      }
77  
78      public String toString() {
79          return "Ws-Addressing August 2004";
80      }
81  }