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 WS-Addressing 1.0 (May 2006). This version of the specification is used by Microsoft's Windows
30   * Communication Foundation (WCF), and supported by Axis 1 and 2.
31   *
32   * @author Arjen Poutsma
33   * @see <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509">Web Services Addressing, August 2004</a>
34   * @since 1.5.0
35   */
36  
37  public class Addressing10 extends AbstractAddressingVersion {
38  
39      private static final String NAMESPACE_URI = "http://www.w3.org/2005/08/addressing";
40  
41      public void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map) {
42          Assert.notNull(map.getAction(), "'Action' is required");
43          super.addAddressingHeaders(message, map);
44      }
45  
46      public boolean hasRequiredProperties(MessageAddressingProperties map) {
47          if (map.getAction() == null) {
48              return false;
49          }
50          if (map.getReplyTo() != null || map.getFaultTo() != null) {
51              return map.getMessageId() != null;
52          }
53          return true;
54  
55      }
56  
57      protected String getNamespaceUri() {
58          return NAMESPACE_URI;
59      }
60  
61      protected QName getReferencePropertiesName() {
62          return null;
63      }
64  
65      protected URI getDefaultTo() {
66          return getAnonymous();
67      }
68  
69      protected EndpointReference getDefaultReplyTo(EndpointReference from) {
70          return new EndpointReference(getAnonymous());
71      }
72  
73      protected final URI getAnonymous() {
74          return URI.create(NAMESPACE_URI + "/anonymous");
75      }
76  
77      protected final URI getNone() {
78          return URI.create(NAMESPACE_URI + "/none");
79      }
80  
81      protected final QName getMessageAddressingHeaderRequiredFaultSubcode() {
82          return QNameUtils.createQName(NAMESPACE_URI, "MessageAddressingHeaderRequired", getNamespacePrefix());
83      }
84  
85      protected final String getMessageAddressingHeaderRequiredFaultReason() {
86          return "A required header representing a Message Addressing Property is not present";
87      }
88  
89      protected QName getInvalidAddressingHeaderFaultSubcode() {
90          return QNameUtils.createQName(NAMESPACE_URI, "InvalidAddressingHeader", getNamespacePrefix());
91      }
92  
93      protected String getInvalidAddressingHeaderFaultReason() {
94          return "A header representing a Message Addressing Property is not valid and the message cannot be processed";
95      }
96  
97      public String toString() {
98          return "WS-Addressing 1.0";
99      }
100 }