1 /*
2  * Copyright 2005-2014 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
27 /**
28  * Implements the August 2004 edition of the WS-Addressing specification. This version of the specification is used by
29  * Microsoft's Web Services Enhancements (WSE) 3.0, and supported by Axis 1 and 2, and XFire.
30  *
31  * @author Arjen Poutsma
32  * @see <a href="http://www.w3.org/Submission/2004/SUBM-ws-addressing-20040810/">Web Services Addressing, August
33  *        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     @Override
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     @Override
48     public boolean hasRequiredProperties(MessageAddressingProperties map) {
49         if (map.getTo() == null) {
50             return false;
51         }
52         if (map.getAction() == null) {
53             return false;
54         }
55         if (map.getReplyTo() != null || map.getFaultTo() != null) {
56             return map.getMessageId() != null;
57         }
58         return true;
59     }
60
61     @Override
62     protected final URI getAnonymous() {
63         return URI.create(NAMESPACE_URI + "/role/anonymous");
64     }
65
66     @Override
67     protected final String getInvalidAddressingHeaderFaultReason() {
68         return "A message information header is not valid and the message cannot be processed.";
69     }
70
71     @Override
72     protected final QName getInvalidAddressingHeaderFaultSubcode() {
73         return new QName(NAMESPACE_URI, "InvalidMessageInformationHeader",
74                 getNamespacePrefix());
75     }
76
77     @Override
78     protected final String getMessageAddressingHeaderRequiredFaultReason() {
79         return "A required message information header, To, MessageID, or Action, is not present.";
80     }
81
82     @Override
83     protected final QName getMessageAddressingHeaderRequiredFaultSubcode() {
84         return new QName(NAMESPACE_URI, "MessageInformationHeaderRequired",
85                 getNamespacePrefix());
86     }
87
88     @Override
89     protected final String getNamespaceUri() {
90         return NAMESPACE_URI;
91     }
92
93     @Override
94     protected URI getDefaultTo() {
95         return null;
96     }
97
98     @Override
99     protected final EndpointReference getDefaultReplyTo(EndpointReference from) {
100         return from;
101     }
102
103     @Override
104     protected final URI getNone() {
105         return null;
106     }
107
108     public String toString() {
109         return "WS-Addressing August 2004";
110     }
111 }
112