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://www.w3.org/Submission/2004/SUBM-ws-addressing-20040810/">Web Services Addressing, August
34   *      2004</a>
35   * @since 1.5.0
36   */
37  public class Addressing200408 extends AbstractAddressingVersion {
38  
39      private static final String NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
40  
41      public void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map) {
42          Assert.notNull(map.getAction(), "'Action' is required");
43          Assert.notNull(map.getTo(), "'To' is required");
44          super.addAddressingHeaders(message, map);
45      }
46  
47      public boolean hasRequiredProperties(MessageAddressingProperties map) {
48          if (map.getTo() == null) {
49              return false;
50          }
51          if (map.getAction() == null) {
52              return false;
53          }
54          if (map.getReplyTo() != null || map.getFaultTo() != null) {
55              return map.getMessageId() != null;
56          }
57          return true;
58      }
59  
60      protected final URI getAnonymous() {
61          return URI.create(NAMESPACE_URI + "/role/anonymous");
62      }
63  
64      protected final String getInvalidAddressingHeaderFaultReason() {
65          return "A message information header is not valid and the message cannot be processed.";
66      }
67  
68      protected final QName getInvalidAddressingHeaderFaultSubcode() {
69          return QNameUtils.createQName(NAMESPACE_URI, "InvalidMessageInformationHeader", getNamespacePrefix());
70      }
71  
72      protected final String getMessageAddressingHeaderRequiredFaultReason() {
73          return "A required message information header, To, MessageID, or Action, is not present.";
74      }
75  
76      protected final QName getMessageAddressingHeaderRequiredFaultSubcode() {
77          return QNameUtils.createQName(NAMESPACE_URI, "MessageInformationHeaderRequired", getNamespacePrefix());
78      }
79  
80      protected final String getNamespaceUri() {
81          return NAMESPACE_URI;
82      }
83  
84      protected URI getDefaultTo() {
85          return null;
86      }
87  
88      protected final EndpointReference getDefaultReplyTo(EndpointReference from) {
89          return from;
90      }
91  
92      protected final URI getNone() {
93          return null;
94      }
95  
96      public String toString() {
97          return "WS-Addressing August 2004";
98      }
99  }