1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.wsdl.wsdl11.provider;
18
19 import javax.wsdl.Message;
20
21 import org.springframework.util.Assert;
22
23
24
25
26
27
28
29 public class SuffixBasedPortTypesProvider extends AbstractPortTypesProvider {
30
31
32 public static final String DEFAULT_REQUEST_SUFFIX = "Request";
33
34
35 public static final String DEFAULT_RESPONSE_SUFFIX = "Response";
36
37
38 public static final String DEFAULT_FAULT_SUFFIX = "Fault";
39
40 private String requestSuffix = DEFAULT_REQUEST_SUFFIX;
41
42 private String responseSuffix = DEFAULT_RESPONSE_SUFFIX;
43
44 private String faultSuffix = DEFAULT_FAULT_SUFFIX;
45
46
47
48
49
50
51 public String getRequestSuffix() {
52 return requestSuffix;
53 }
54
55
56
57
58
59
60 public void setRequestSuffix(String requestSuffix) {
61 Assert.hasText(requestSuffix, "'requestSuffix' must not be empty");
62 this.requestSuffix = requestSuffix;
63 }
64
65
66
67
68
69
70 public String getResponseSuffix() {
71 return responseSuffix;
72 }
73
74
75
76
77
78
79 public void setResponseSuffix(String responseSuffix) {
80 Assert.hasText(responseSuffix, "'responseSuffix' must not be empty");
81 this.responseSuffix = responseSuffix;
82 }
83
84
85
86
87
88
89 public String getFaultSuffix() {
90 return faultSuffix;
91 }
92
93
94
95
96
97
98 public void setFaultSuffix(String faultSuffix) {
99 Assert.hasText(faultSuffix, "'faultSuffix' must not be empty");
100 this.faultSuffix = faultSuffix;
101 }
102
103 protected String getOperationName(Message message) {
104 String messageName = getMessageName(message);
105 if (messageName != null) {
106 if (messageName.endsWith(getRequestSuffix())) {
107 return messageName.substring(0, messageName.length() - getRequestSuffix().length());
108 }
109 else if (messageName.endsWith(getResponseSuffix())) {
110 return messageName.substring(0, messageName.length() - getResponseSuffix().length());
111 }
112 else if (messageName.endsWith(getFaultSuffix())) {
113 return messageName.substring(0, messageName.length() - getFaultSuffix().length());
114 }
115 }
116 return null;
117 }
118
119
120
121
122
123
124
125
126
127
128 protected boolean isInputMessage(Message message) {
129 String messageName = getMessageName(message);
130 return messageName != null && messageName.endsWith(getRequestSuffix());
131 }
132
133
134
135
136
137
138
139
140
141
142 protected boolean isOutputMessage(Message message) {
143 String messageName = getMessageName(message);
144 return messageName != null && messageName.endsWith(getResponseSuffix());
145 }
146
147
148
149
150
151
152
153
154
155 protected boolean isFaultMessage(Message message) {
156 String messageName = getMessageName(message);
157 return messageName != null && messageName.endsWith(getFaultSuffix());
158 }
159
160 private String getMessageName(Message message) {
161 return message.getQName().getLocalPart();
162 }
163 }