Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
ohair@286 | 1 | /* |
alanb@368 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package com.sun.xml.internal.ws.api.addressing; |
ohair@286 | 27 | |
ohair@286 | 28 | import com.sun.istack.internal.NotNull; |
ohair@286 | 29 | import com.sun.istack.internal.Nullable; |
ohair@286 | 30 | import com.sun.xml.internal.stream.buffer.XMLStreamBuffer; |
ohair@286 | 31 | import com.sun.xml.internal.ws.addressing.W3CAddressingConstants; |
ohair@286 | 32 | import com.sun.xml.internal.ws.addressing.WsaTubeHelper; |
ohair@286 | 33 | import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants; |
ohair@286 | 34 | import com.sun.xml.internal.ws.api.WSBinding; |
ohair@286 | 35 | import com.sun.xml.internal.ws.api.message.Header; |
ohair@286 | 36 | import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
ohair@286 | 37 | import com.sun.xml.internal.ws.api.model.SEIModel; |
ohair@286 | 38 | import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; |
ohair@286 | 39 | import com.sun.xml.internal.ws.developer.MemberSubmissionEndpointReference; |
ohair@286 | 40 | import com.sun.xml.internal.ws.message.stream.OutboundStreamHeader; |
ohair@286 | 41 | |
ohair@286 | 42 | import javax.xml.namespace.QName; |
ohair@286 | 43 | import javax.xml.stream.XMLStreamException; |
ohair@286 | 44 | import javax.xml.ws.EndpointReference; |
ohair@286 | 45 | import javax.xml.ws.WebServiceException; |
ohair@286 | 46 | import javax.xml.ws.WebServiceFeature; |
ohair@286 | 47 | import javax.xml.ws.soap.AddressingFeature; |
ohair@286 | 48 | import javax.xml.ws.wsaddressing.W3CEndpointReference; |
ohair@286 | 49 | import java.io.ByteArrayInputStream; |
ohair@286 | 50 | import java.io.UnsupportedEncodingException; |
ohair@286 | 51 | |
ohair@286 | 52 | /** |
ohair@286 | 53 | * 'Traits' object that absorbs differences of WS-Addressing versions. |
ohair@286 | 54 | * |
ohair@286 | 55 | * @author Arun Gupta |
ohair@286 | 56 | */ |
ohair@286 | 57 | public enum AddressingVersion { |
ohair@286 | 58 | |
ohair@286 | 59 | W3C("http://www.w3.org/2005/08/addressing", |
ohair@286 | 60 | "wsa", |
ohair@286 | 61 | W3CAddressingConstants.ANONYMOUS_EPR, |
ohair@286 | 62 | "http://www.w3.org/2006/05/addressing/wsdl", |
ohair@286 | 63 | "http://www.w3.org/2006/05/addressing/wsdl", |
ohair@286 | 64 | "http://www.w3.org/2005/08/addressing/anonymous", |
ohair@286 | 65 | "http://www.w3.org/2005/08/addressing/none", |
ohair@286 | 66 | new EPR(W3CEndpointReference.class, |
ohair@286 | 67 | "Address", |
ohair@286 | 68 | "ServiceName", |
ohair@286 | 69 | "EndpointName", |
ohair@286 | 70 | "InterfaceName", |
ohair@286 | 71 | new QName("http://www.w3.org/2005/08/addressing","Metadata","wsa"), |
ohair@286 | 72 | "ReferenceParameters", |
ohair@286 | 73 | null )) { |
ohair@286 | 74 | |
ohair@286 | 75 | /* package */ String getActionMismatchLocalName() { |
ohair@286 | 76 | return "ActionMismatch"; |
ohair@286 | 77 | } |
ohair@286 | 78 | @Override |
ohair@286 | 79 | public boolean isReferenceParameter(String localName) { |
ohair@286 | 80 | return localName.equals("ReferenceParameters"); |
ohair@286 | 81 | } |
ohair@286 | 82 | |
ohair@286 | 83 | @Override |
ohair@286 | 84 | public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) { |
ohair@286 | 85 | return new com.sun.xml.internal.ws.addressing.WsaTubeHelperImpl(wsdlPort, seiModel, binding); |
ohair@286 | 86 | } |
ohair@286 | 87 | |
ohair@286 | 88 | @Override |
ohair@286 | 89 | /* package */ String getMapRequiredLocalName() { |
ohair@286 | 90 | return "MessageAddressingHeaderRequired"; |
ohair@286 | 91 | } |
ohair@286 | 92 | |
ohair@286 | 93 | @Override |
ohair@286 | 94 | public String getMapRequiredText() { |
ohair@286 | 95 | return "A required header representing a Message Addressing Property is not present"; |
ohair@286 | 96 | } |
ohair@286 | 97 | |
ohair@286 | 98 | /* package */ String getInvalidAddressLocalName() { |
ohair@286 | 99 | return "InvalidAddress"; |
ohair@286 | 100 | } |
ohair@286 | 101 | |
ohair@286 | 102 | @Override |
ohair@286 | 103 | /* package */ String getInvalidMapLocalName() { |
ohair@286 | 104 | return "InvalidAddressingHeader"; |
ohair@286 | 105 | } |
ohair@286 | 106 | |
ohair@286 | 107 | @Override |
ohair@286 | 108 | public String getInvalidMapText() { |
ohair@286 | 109 | return "A header representing a Message Addressing Property is not valid and the message cannot be processed"; |
ohair@286 | 110 | } |
ohair@286 | 111 | |
ohair@286 | 112 | @Override |
ohair@286 | 113 | /* package */ String getInvalidCardinalityLocalName() { |
ohair@286 | 114 | return "InvalidCardinality"; |
ohair@286 | 115 | } |
ohair@286 | 116 | |
ohair@286 | 117 | /*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) { |
ohair@286 | 118 | return new OutboundReferenceParameterHeader(mark,nsUri,localName); |
ohair@286 | 119 | } |
ohair@286 | 120 | |
ohair@286 | 121 | /*package*/ String getIsReferenceParameterLocalName() { |
ohair@286 | 122 | return "IsReferenceParameter"; |
ohair@286 | 123 | } |
ohair@286 | 124 | |
ohair@286 | 125 | /* package */ String getWsdlAnonymousLocalName() { |
ohair@286 | 126 | return "Anonymous"; |
ohair@286 | 127 | } |
ohair@286 | 128 | |
ohair@286 | 129 | public String getPrefix() { |
ohair@286 | 130 | return "wsa"; |
ohair@286 | 131 | } |
ohair@286 | 132 | |
ohair@286 | 133 | public String getWsdlPrefix() { |
ohair@286 | 134 | return "wsaw"; |
ohair@286 | 135 | } |
ohair@286 | 136 | |
ohair@286 | 137 | public Class<? extends WebServiceFeature> getFeatureClass() { |
ohair@286 | 138 | return AddressingFeature.class; |
ohair@286 | 139 | } |
ohair@286 | 140 | }, |
ohair@286 | 141 | MEMBER("http://schemas.xmlsoap.org/ws/2004/08/addressing", |
ohair@286 | 142 | "wsa", |
ohair@286 | 143 | MemberSubmissionAddressingConstants.ANONYMOUS_EPR, |
ohair@286 | 144 | "http://schemas.xmlsoap.org/ws/2004/08/addressing", |
ohair@286 | 145 | "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy", |
ohair@286 | 146 | "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous", |
ohair@286 | 147 | "", |
ohair@286 | 148 | new EPR(MemberSubmissionEndpointReference.class, |
ohair@286 | 149 | "Address", |
ohair@286 | 150 | "ServiceName", |
ohair@286 | 151 | "PortName", |
ohair@286 | 152 | "PortType", |
ohair@286 | 153 | MemberSubmissionAddressingConstants.MEX_METADATA, |
ohair@286 | 154 | "ReferenceParameters", |
ohair@286 | 155 | "ReferenceProperties")) { |
ohair@286 | 156 | /* package */ String getActionMismatchLocalName() { |
ohair@286 | 157 | return "InvalidMessageInformationHeader"; |
ohair@286 | 158 | } |
ohair@286 | 159 | @Override |
ohair@286 | 160 | public boolean isReferenceParameter(String localName) { |
ohair@286 | 161 | return localName.equals("ReferenceParameters") || localName.equals("ReferenceProperties"); |
ohair@286 | 162 | } |
ohair@286 | 163 | |
ohair@286 | 164 | @Override |
ohair@286 | 165 | public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) { |
ohair@286 | 166 | return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, seiModel, binding); |
ohair@286 | 167 | } |
ohair@286 | 168 | |
ohair@286 | 169 | @Override |
ohair@286 | 170 | /* package */ String getMapRequiredLocalName() { |
ohair@286 | 171 | return "MessageInformationHeaderRequired"; |
ohair@286 | 172 | } |
ohair@286 | 173 | |
ohair@286 | 174 | @Override |
ohair@286 | 175 | public String getMapRequiredText() { |
ohair@286 | 176 | return "A required message information header, To, MessageID, or Action, is not present."; |
ohair@286 | 177 | } |
ohair@286 | 178 | |
ohair@286 | 179 | /* package */ String getInvalidAddressLocalName() { |
ohair@286 | 180 | return getInvalidMapLocalName(); |
ohair@286 | 181 | } |
ohair@286 | 182 | |
ohair@286 | 183 | @Override |
ohair@286 | 184 | /* package */ String getInvalidMapLocalName() { |
ohair@286 | 185 | return "InvalidMessageInformationHeader"; |
ohair@286 | 186 | } |
ohair@286 | 187 | |
ohair@286 | 188 | @Override |
ohair@286 | 189 | public String getInvalidMapText() { |
ohair@286 | 190 | return "A message information header is not valid and the message cannot be processed."; |
ohair@286 | 191 | } |
ohair@286 | 192 | |
ohair@286 | 193 | @Override |
ohair@286 | 194 | /* package */ String getInvalidCardinalityLocalName() { |
ohair@286 | 195 | return getInvalidMapLocalName(); |
ohair@286 | 196 | } |
ohair@286 | 197 | |
ohair@286 | 198 | /*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) { |
ohair@286 | 199 | return new OutboundStreamHeader(mark,nsUri,localName); |
ohair@286 | 200 | } |
ohair@286 | 201 | |
ohair@286 | 202 | /*package*/ String getIsReferenceParameterLocalName() { |
ohair@286 | 203 | return ""; |
ohair@286 | 204 | } |
ohair@286 | 205 | |
ohair@286 | 206 | /* package */ String getWsdlAnonymousLocalName() { |
ohair@286 | 207 | return ""; |
ohair@286 | 208 | } |
ohair@286 | 209 | |
ohair@286 | 210 | public String getPrefix() { |
ohair@286 | 211 | return "wsa"; |
ohair@286 | 212 | } |
ohair@286 | 213 | |
ohair@286 | 214 | public String getWsdlPrefix() { |
ohair@286 | 215 | return "wsaw"; |
ohair@286 | 216 | } |
ohair@286 | 217 | |
ohair@286 | 218 | public Class<? extends WebServiceFeature> getFeatureClass() { |
ohair@286 | 219 | return MemberSubmissionAddressingFeature.class; |
ohair@286 | 220 | } |
ohair@286 | 221 | }; |
ohair@286 | 222 | |
ohair@286 | 223 | /** |
ohair@286 | 224 | * Namespace URI |
ohair@286 | 225 | */ |
ohair@286 | 226 | public final String nsUri; |
ohair@286 | 227 | |
ohair@286 | 228 | /** |
ohair@286 | 229 | * Namespace URI for the WSDL Binding |
ohair@286 | 230 | */ |
ohair@286 | 231 | public final String wsdlNsUri; |
ohair@286 | 232 | |
ohair@286 | 233 | /** |
ohair@286 | 234 | * Representing either {@link W3CEndpointReference} or |
ohair@286 | 235 | * {@link MemberSubmissionEndpointReference}. |
ohair@286 | 236 | */ |
ohair@286 | 237 | public final EPR eprType; |
ohair@286 | 238 | |
ohair@286 | 239 | /** |
ohair@286 | 240 | * Namespace URI for the WSDL Binding |
ohair@286 | 241 | */ |
ohair@286 | 242 | public final String policyNsUri; |
ohair@286 | 243 | |
ohair@286 | 244 | /** |
ohair@286 | 245 | * Gets the anonymous URI value associated with this WS-Addressing version. |
ohair@286 | 246 | */ |
ohair@286 | 247 | public final @NotNull String anonymousUri; |
ohair@286 | 248 | |
ohair@286 | 249 | /** |
ohair@286 | 250 | * Gets the none URI value associated with this WS-Addressing version. |
ohair@286 | 251 | */ |
ohair@286 | 252 | public final @NotNull String noneUri; |
ohair@286 | 253 | |
ohair@286 | 254 | /** |
ohair@286 | 255 | * Represents the anonymous EPR. |
ohair@286 | 256 | */ |
ohair@286 | 257 | public final WSEndpointReference anonymousEpr; |
ohair@286 | 258 | |
ohair@286 | 259 | /** |
ohair@286 | 260 | * Represents the To QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 261 | */ |
ohair@286 | 262 | public final QName toTag; |
ohair@286 | 263 | |
ohair@286 | 264 | /** |
ohair@286 | 265 | * Represents the From QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 266 | */ |
ohair@286 | 267 | public final QName fromTag; |
ohair@286 | 268 | |
ohair@286 | 269 | /** |
ohair@286 | 270 | * Represents the ReplyTo QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 271 | */ |
ohair@286 | 272 | public final QName replyToTag; |
ohair@286 | 273 | |
ohair@286 | 274 | /** |
ohair@286 | 275 | * Represents the FaultTo QName for a specific WS-Addressing Version. |
ohair@286 | 276 | */ |
ohair@286 | 277 | public final QName faultToTag; |
ohair@286 | 278 | |
ohair@286 | 279 | /** |
ohair@286 | 280 | * Represents the Action QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 281 | */ |
ohair@286 | 282 | public final QName actionTag; |
ohair@286 | 283 | |
ohair@286 | 284 | /** |
ohair@286 | 285 | * Represents the MessageID QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 286 | */ |
ohair@286 | 287 | public final QName messageIDTag; |
ohair@286 | 288 | |
ohair@286 | 289 | /** |
ohair@286 | 290 | * Represents the RelatesTo QName in the SOAP message for a specific WS-Addressing Version. |
ohair@286 | 291 | */ |
ohair@286 | 292 | public final QName relatesToTag; |
ohair@286 | 293 | |
ohair@286 | 294 | /** |
ohair@286 | 295 | * Represents the QName of the fault code when a required header representing a |
ohair@286 | 296 | * WS-Addressing Message Addressing Property is not present. |
ohair@286 | 297 | */ |
ohair@286 | 298 | public final QName mapRequiredTag; |
ohair@286 | 299 | |
ohair@286 | 300 | /** |
ohair@286 | 301 | * Represents the QName of the fault code when Action is not supported at this endpoint. |
ohair@286 | 302 | */ |
ohair@286 | 303 | public final QName actionMismatchTag; |
ohair@286 | 304 | |
ohair@286 | 305 | /** |
ohair@286 | 306 | * Represents the QName of the fault code when Action is not supported at this endpoint. |
ohair@286 | 307 | */ |
ohair@286 | 308 | public final QName actionNotSupportedTag; |
ohair@286 | 309 | |
ohair@286 | 310 | /** |
ohair@286 | 311 | * Represents the text of the fault when Action is not supported at this endpoint. |
ohair@286 | 312 | */ |
ohair@286 | 313 | public final String actionNotSupportedText; |
ohair@286 | 314 | |
ohair@286 | 315 | /** |
ohair@286 | 316 | * Represents the QName of the fault code when a header representing a |
ohair@286 | 317 | * WS-Addressing Message Addressing Property is invalid and cannot be processed. |
ohair@286 | 318 | */ |
ohair@286 | 319 | public final QName invalidMapTag; |
ohair@286 | 320 | |
ohair@286 | 321 | /** |
ohair@286 | 322 | * Represents the QName of the fault code when a header representing a |
ohair@286 | 323 | * WS-Addressing Message Addressing Property occurs greater than expected number. |
ohair@286 | 324 | */ |
ohair@286 | 325 | public final QName invalidCardinalityTag; |
ohair@286 | 326 | |
ohair@286 | 327 | /** |
ohair@286 | 328 | * Represents the QName of the fault code when a header representing an |
ohair@286 | 329 | * address is not valid. |
ohair@286 | 330 | */ |
ohair@286 | 331 | public final QName invalidAddressTag; |
ohair@286 | 332 | |
ohair@286 | 333 | /** |
ohair@286 | 334 | * Represents the QName of the element that conveys additional information |
ohair@286 | 335 | * on the pre-defined WS-Addressing faults. |
ohair@286 | 336 | */ |
ohair@286 | 337 | public final QName problemHeaderQNameTag; |
ohair@286 | 338 | |
ohair@286 | 339 | /** |
ohair@286 | 340 | * Represents the QName of the element that conveys additional information |
ohair@286 | 341 | * if Action is not matching with that expected. |
ohair@286 | 342 | */ |
ohair@286 | 343 | public final QName problemActionTag; |
ohair@286 | 344 | |
ohair@286 | 345 | /** |
ohair@286 | 346 | * Represents the QName of the header element that is used to capture the fault detail |
ohair@286 | 347 | * if there is a fault processing WS-Addressing Message Addressing Property. This is |
ohair@286 | 348 | * only used for SOAP 1.1. |
ohair@286 | 349 | */ |
ohair@286 | 350 | public final QName faultDetailTag; |
ohair@286 | 351 | |
ohair@286 | 352 | /** |
ohair@286 | 353 | * Fault sub-sub-code that represents |
ohair@286 | 354 | * "Specifies that the invalid header was expected to be an EPR but did not contain an [address]." |
ohair@286 | 355 | */ |
ohair@286 | 356 | public final QName fault_missingAddressInEpr; |
ohair@286 | 357 | |
ohair@286 | 358 | /** |
ohair@286 | 359 | * Represents the Action QName in the WSDL for a specific WS-Addressing Version. |
ohair@286 | 360 | */ |
ohair@286 | 361 | public final QName wsdlActionTag; |
ohair@286 | 362 | |
ohair@286 | 363 | /** |
ohair@286 | 364 | * Represents the WSDL extension QName for a specific WS-Addressing Version. |
ohair@286 | 365 | */ |
ohair@286 | 366 | public final QName wsdlExtensionTag; |
ohair@286 | 367 | |
ohair@286 | 368 | /** |
ohair@286 | 369 | * Represents the WSDL anonymous QName for a specific WS-Addressing Version. |
ohair@286 | 370 | */ |
ohair@286 | 371 | public final QName wsdlAnonymousTag; |
ohair@286 | 372 | |
ohair@286 | 373 | /** |
ohair@286 | 374 | * Represents the QName of the reference parameter in a SOAP message. This is |
ohair@286 | 375 | * only valid for W3C WS-Addressing. |
ohair@286 | 376 | */ |
ohair@286 | 377 | public final QName isReferenceParameterTag; |
ohair@286 | 378 | |
ohair@286 | 379 | private static final String EXTENDED_FAULT_NAMESPACE = "http://jax-ws.dev.java.net/addressing/fault"; |
ohair@286 | 380 | public static final String UNSET_OUTPUT_ACTION = "http://jax-ws.dev.java.net/addressing/output-action-not-set"; |
ohair@286 | 381 | public static final String UNSET_INPUT_ACTION = "http://jax-ws.dev.java.net/addressing/input-action-not-set"; |
ohair@286 | 382 | |
ohair@286 | 383 | /** |
ohair@286 | 384 | * Fault sub-sub-code that represents duplicate <Address> element in EPR. |
ohair@286 | 385 | * This is a fault code not defined in the spec. |
ohair@286 | 386 | */ |
ohair@286 | 387 | public static final QName fault_duplicateAddressInEpr = new QName( |
ohair@286 | 388 | EXTENDED_FAULT_NAMESPACE, "DuplicateAddressInEpr", "wsa" |
ohair@286 | 389 | ); |
ohair@286 | 390 | |
ohair@286 | 391 | private AddressingVersion(String nsUri, String prefix, String anonymousEprString, String wsdlNsUri, String policyNsUri, |
ohair@286 | 392 | String anonymousUri, String noneUri, |
ohair@286 | 393 | EPR eprType ) { |
ohair@286 | 394 | this.nsUri = nsUri; |
ohair@286 | 395 | this.wsdlNsUri = wsdlNsUri; |
ohair@286 | 396 | this.policyNsUri = policyNsUri; |
ohair@286 | 397 | this.anonymousUri = anonymousUri; |
ohair@286 | 398 | this.noneUri = noneUri; |
ohair@286 | 399 | toTag = new QName(nsUri,"To", prefix); |
ohair@286 | 400 | fromTag = new QName(nsUri,"From", prefix); |
ohair@286 | 401 | replyToTag = new QName(nsUri,"ReplyTo", prefix); |
ohair@286 | 402 | faultToTag = new QName(nsUri,"FaultTo", prefix); |
ohair@286 | 403 | actionTag = new QName(nsUri,"Action", prefix); |
ohair@286 | 404 | messageIDTag = new QName(nsUri,"MessageID", prefix); |
ohair@286 | 405 | relatesToTag = new QName(nsUri,"RelatesTo", prefix); |
ohair@286 | 406 | |
ohair@286 | 407 | mapRequiredTag = new QName(nsUri,getMapRequiredLocalName(), prefix); |
ohair@286 | 408 | actionMismatchTag = new QName(nsUri,getActionMismatchLocalName(), prefix); |
ohair@286 | 409 | actionNotSupportedTag = new QName(nsUri,"ActionNotSupported", prefix); |
ohair@286 | 410 | actionNotSupportedText = "The \"%s\" cannot be processed at the receiver"; |
ohair@286 | 411 | invalidMapTag = new QName(nsUri,getInvalidMapLocalName(), prefix); |
ohair@286 | 412 | invalidAddressTag = new QName(nsUri,getInvalidAddressLocalName(), prefix); |
ohair@286 | 413 | invalidCardinalityTag = new QName(nsUri,getInvalidCardinalityLocalName(), prefix); |
ohair@286 | 414 | faultDetailTag = new QName(nsUri,"FaultDetail", prefix); |
ohair@286 | 415 | |
ohair@286 | 416 | problemHeaderQNameTag = new QName(nsUri,"ProblemHeaderQName", prefix); |
ohair@286 | 417 | problemActionTag = new QName(nsUri, "ProblemAction", prefix); |
ohair@286 | 418 | |
ohair@286 | 419 | fault_missingAddressInEpr = new QName(nsUri,"MissingAddressInEPR", prefix); |
ohair@286 | 420 | isReferenceParameterTag = new QName(nsUri,getIsReferenceParameterLocalName(), prefix); |
ohair@286 | 421 | |
ohair@286 | 422 | wsdlActionTag = new QName(wsdlNsUri,"Action", prefix); |
ohair@286 | 423 | wsdlExtensionTag = new QName(wsdlNsUri, "UsingAddressing", prefix); |
ohair@286 | 424 | wsdlAnonymousTag = new QName(wsdlNsUri, getWsdlAnonymousLocalName(), prefix); |
ohair@286 | 425 | |
ohair@286 | 426 | // create stock anonymous EPR |
ohair@286 | 427 | try { |
ohair@286 | 428 | this.anonymousEpr = new WSEndpointReference(new ByteArrayInputStream(anonymousEprString.getBytes("UTF-8")),this); |
ohair@286 | 429 | } catch (XMLStreamException e) { |
ohair@286 | 430 | throw new Error(e); // bug in our code as EPR should parse. |
ohair@286 | 431 | } catch (UnsupportedEncodingException e) { |
ohair@286 | 432 | throw new Error(e); |
ohair@286 | 433 | } |
ohair@286 | 434 | this.eprType = eprType; |
ohair@286 | 435 | } |
ohair@286 | 436 | |
ohair@286 | 437 | /** |
ohair@286 | 438 | * Gets the local name of the fault when a header representing a WS-Addressing Action is not same as SOAPAction |
ohair@286 | 439 | * |
ohair@286 | 440 | * @return local name |
ohair@286 | 441 | */ |
ohair@286 | 442 | /* package */ abstract String getActionMismatchLocalName(); |
ohair@286 | 443 | |
ohair@286 | 444 | /** |
ohair@286 | 445 | * Returns {@link AddressingVersion} whose {@link #nsUri} equals to |
ohair@286 | 446 | * the given string. |
ohair@286 | 447 | * |
ohair@286 | 448 | * This method does not perform input string validation. |
ohair@286 | 449 | * |
ohair@286 | 450 | * @param nsUri |
ohair@286 | 451 | * must not be null. |
ohair@286 | 452 | * @return always non-null. |
ohair@286 | 453 | */ |
ohair@286 | 454 | public static AddressingVersion fromNsUri(String nsUri) { |
ohair@286 | 455 | if (nsUri.equals(W3C.nsUri)) |
ohair@286 | 456 | return W3C; |
ohair@286 | 457 | |
ohair@286 | 458 | if (nsUri.equals(MEMBER.nsUri)) |
ohair@286 | 459 | return MEMBER; |
ohair@286 | 460 | |
ohair@286 | 461 | return null; |
ohair@286 | 462 | } |
ohair@286 | 463 | |
ohair@286 | 464 | /** |
ohair@286 | 465 | * Gets the {@link AddressingVersion} from a {@link WSBinding} |
ohair@286 | 466 | * |
ohair@286 | 467 | * @param binding WSDL binding |
ohair@286 | 468 | * @return |
ohair@286 | 469 | * addresing version enabled, or null if none is enabled. |
ohair@286 | 470 | */ |
ohair@286 | 471 | public static @Nullable |
ohair@286 | 472 | AddressingVersion fromBinding(WSBinding binding) { |
ohair@286 | 473 | // TODO: who is responsible for reporting an error if both versions |
ohair@286 | 474 | // are on? |
ohair@286 | 475 | if (binding.isFeatureEnabled(AddressingFeature.class)) |
ohair@286 | 476 | return W3C; |
ohair@286 | 477 | |
ohair@286 | 478 | if (binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class)) |
ohair@286 | 479 | return MEMBER; |
ohair@286 | 480 | |
ohair@286 | 481 | return null; |
ohair@286 | 482 | } |
ohair@286 | 483 | |
ohair@286 | 484 | /** |
ohair@286 | 485 | * Gets the {@link AddressingVersion} from a {@link WSDLPort} |
ohair@286 | 486 | * |
ohair@286 | 487 | * @param port WSDL port |
ohair@286 | 488 | * @return addresing version |
ohair@286 | 489 | */ |
ohair@286 | 490 | public static AddressingVersion fromPort(WSDLPort port) { |
ohair@286 | 491 | if (port == null) |
ohair@286 | 492 | return null; |
ohair@286 | 493 | |
ohair@286 | 494 | WebServiceFeature wsf = port.getFeature(AddressingFeature.class); |
ohair@286 | 495 | if (wsf == null) { |
ohair@286 | 496 | wsf = port.getFeature(MemberSubmissionAddressingFeature.class); |
ohair@286 | 497 | } |
ohair@286 | 498 | if (wsf == null) |
ohair@286 | 499 | return null; |
ohair@286 | 500 | |
ohair@286 | 501 | return fromFeature(wsf); |
ohair@286 | 502 | } |
ohair@286 | 503 | |
ohair@286 | 504 | /** |
ohair@286 | 505 | * Returns {@link #nsUri} associated with this {@link AddressingVersion} |
ohair@286 | 506 | * |
ohair@286 | 507 | * @return namespace URI |
ohair@286 | 508 | * @deprecated |
ohair@286 | 509 | * Use {@link #nsUri}. |
ohair@286 | 510 | */ |
ohair@286 | 511 | public String getNsUri() { |
ohair@286 | 512 | return nsUri; |
ohair@286 | 513 | } |
ohair@286 | 514 | |
ohair@286 | 515 | /** |
ohair@286 | 516 | * Returns true if the given local name is considered as |
ohair@286 | 517 | * a reference parameter in EPR. |
ohair@286 | 518 | * |
ohair@286 | 519 | * For W3C, this means "ReferenceParameters", |
ohair@286 | 520 | * and for the member submission version, this means |
ohair@286 | 521 | * either "ReferenceParameters" or "ReferenceProperties". |
ohair@286 | 522 | */ |
ohair@286 | 523 | public abstract boolean isReferenceParameter(String localName); |
ohair@286 | 524 | |
ohair@286 | 525 | /** |
ohair@286 | 526 | * Returns WsaTubeHelper for the WS-Addressing version identified by <code>binding</code> |
ohair@286 | 527 | * {@link WSBinding} and for the {@link WSDLPort} port. |
ohair@286 | 528 | * |
ohair@286 | 529 | * @return WS-A version specific helper |
ohair@286 | 530 | * |
ohair@286 | 531 | * @deprecated |
ohair@286 | 532 | * TODO why are we exposing implementation specificc class through api? |
ohair@286 | 533 | * TODO Remove it if no one elase uses it. |
ohair@286 | 534 | */ |
ohair@286 | 535 | public abstract WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding); |
ohair@286 | 536 | |
ohair@286 | 537 | /** |
ohair@286 | 538 | * Gets the none URI value associated with this WS-Addressing version. |
ohair@286 | 539 | * |
ohair@286 | 540 | * @return none URI value |
ohair@286 | 541 | * @deprecated |
ohair@286 | 542 | * Use {@link #noneUri}. |
ohair@286 | 543 | */ |
ohair@286 | 544 | public final String getNoneUri() { |
ohair@286 | 545 | return noneUri; |
ohair@286 | 546 | } |
ohair@286 | 547 | |
ohair@286 | 548 | /** |
ohair@286 | 549 | * Gets the anonymous URI value associated with this WS-Addressing version. |
ohair@286 | 550 | * |
ohair@286 | 551 | * @deprecated |
ohair@286 | 552 | * Use {@link #anonymousUri} |
ohair@286 | 553 | */ |
ohair@286 | 554 | public final String getAnonymousUri() { |
ohair@286 | 555 | return anonymousUri; |
ohair@286 | 556 | } |
ohair@286 | 557 | |
ohair@286 | 558 | /** |
ohair@286 | 559 | * Gets the default fault Action value associated with this WS-Addressing version. |
ohair@286 | 560 | * |
ohair@286 | 561 | * @return default fault Action value |
ohair@286 | 562 | */ |
ohair@286 | 563 | public String getDefaultFaultAction() { |
ohair@286 | 564 | return nsUri + "/fault"; |
ohair@286 | 565 | } |
ohair@286 | 566 | |
ohair@286 | 567 | /** |
ohair@286 | 568 | * Gets the local name of the fault when a header representing a WS-Addressing Message |
ohair@286 | 569 | * Addresing Property is absent. |
ohair@286 | 570 | * |
ohair@286 | 571 | * @return local name |
ohair@286 | 572 | */ |
ohair@286 | 573 | /* package */ abstract String getMapRequiredLocalName(); |
ohair@286 | 574 | |
ohair@286 | 575 | /** |
ohair@286 | 576 | * Gets the description text when a required WS-Addressing header representing a |
ohair@286 | 577 | * Message Addressing Property is absent. |
ohair@286 | 578 | * |
ohair@286 | 579 | * @return description text |
ohair@286 | 580 | */ |
ohair@286 | 581 | public abstract String getMapRequiredText(); |
ohair@286 | 582 | |
ohair@286 | 583 | /** |
ohair@286 | 584 | * Gets the local name of the fault when a header representing anaddress is invalid. |
ohair@286 | 585 | * @return local name |
ohair@286 | 586 | */ |
ohair@286 | 587 | /* package */ abstract String getInvalidAddressLocalName(); |
ohair@286 | 588 | |
ohair@286 | 589 | |
ohair@286 | 590 | /** |
ohair@286 | 591 | * Gets the local name of the fault when a header representing a WS-Addressing Message |
ohair@286 | 592 | * Addresing Property is invalid and cannot be processed. |
ohair@286 | 593 | * |
ohair@286 | 594 | * @return local name |
ohair@286 | 595 | */ |
ohair@286 | 596 | /* package */ abstract String getInvalidMapLocalName(); |
ohair@286 | 597 | |
ohair@286 | 598 | /** |
ohair@286 | 599 | * Gets the description text when a header representing a WS-Addressing |
ohair@286 | 600 | * Message Addressing Property is invalid and cannot be processed. |
ohair@286 | 601 | * |
ohair@286 | 602 | * @return description text |
ohair@286 | 603 | */ |
ohair@286 | 604 | public abstract String getInvalidMapText(); |
ohair@286 | 605 | |
ohair@286 | 606 | /** |
ohair@286 | 607 | * Gets the local name of the fault when a header representing a WS-Addressing Message |
ohair@286 | 608 | * Addresing Property occurs greater than expected number. |
ohair@286 | 609 | * |
ohair@286 | 610 | * @return local name |
ohair@286 | 611 | */ |
ohair@286 | 612 | /* package */ abstract String getInvalidCardinalityLocalName(); |
ohair@286 | 613 | |
ohair@286 | 614 | /* package */ abstract String getWsdlAnonymousLocalName(); |
ohair@286 | 615 | |
ohair@286 | 616 | public abstract String getPrefix(); |
ohair@286 | 617 | |
ohair@286 | 618 | public abstract String getWsdlPrefix(); |
ohair@286 | 619 | |
ohair@286 | 620 | public abstract Class<? extends WebServiceFeature> getFeatureClass(); |
ohair@286 | 621 | /** |
ohair@286 | 622 | * Creates an outbound {@link Header} from a reference parameter. |
ohair@286 | 623 | */ |
ohair@286 | 624 | /*package*/ abstract Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName); |
ohair@286 | 625 | |
ohair@286 | 626 | /** |
ohair@286 | 627 | * Gets the local name for wsa:IsReferenceParameter. This method will return a valid |
ohair@286 | 628 | * value only valid for W3C WS-Addressing. For Member Submission WS-Addressing, this method |
ohair@286 | 629 | * returns null. |
ohair@286 | 630 | */ |
ohair@286 | 631 | /*package*/ abstract String getIsReferenceParameterLocalName(); |
ohair@286 | 632 | |
ohair@286 | 633 | public static AddressingVersion fromFeature(WebServiceFeature af) { |
ohair@286 | 634 | if (af.getID().equals(AddressingFeature.ID)) |
ohair@286 | 635 | return W3C; |
ohair@286 | 636 | else if (af.getID().equals(MemberSubmissionAddressingFeature.ID)) |
ohair@286 | 637 | return MEMBER; |
ohair@286 | 638 | else |
ohair@286 | 639 | return null; |
ohair@286 | 640 | } |
ohair@286 | 641 | |
ohair@286 | 642 | /** |
ohair@286 | 643 | * Gets the {@link WebServiceFeature} corresponding to the namespace URI of |
ohair@286 | 644 | * WS-Addressing policy assertion in the WSDL. <code>enabled</code> and |
ohair@286 | 645 | * <code>required</code> are used to initialize the value of the feature. |
ohair@286 | 646 | * |
ohair@286 | 647 | * @param nsUri namespace URI of the WS-Addressing policy assertion in the WSDL |
ohair@286 | 648 | * @param enabled true if feature is to be enabled, false otherwise |
ohair@286 | 649 | * @param required true if feature is required, false otherwise. Corresponds |
ohair@286 | 650 | * to wsdl:required on the extension/assertion. |
ohair@286 | 651 | * @return WebServiceFeature corresponding to the assertion namespace URI |
ohair@286 | 652 | * @throws WebServiceException if an unsupported namespace URI is passed |
ohair@286 | 653 | */ |
ohair@286 | 654 | public static @NotNull WebServiceFeature getFeature(String nsUri, boolean enabled, boolean required) { |
ohair@286 | 655 | if (nsUri.equals(W3C.policyNsUri)) |
ohair@286 | 656 | return new AddressingFeature(enabled, required); |
ohair@286 | 657 | else if (nsUri.equals(MEMBER.policyNsUri)) |
ohair@286 | 658 | return new MemberSubmissionAddressingFeature(enabled, required); |
ohair@286 | 659 | else |
ohair@286 | 660 | throw new WebServiceException("Unsupported namespace URI: " + nsUri); |
ohair@286 | 661 | } |
ohair@286 | 662 | |
ohair@286 | 663 | /** |
ohair@286 | 664 | * Gets the corresponding {@link AddressingVersion} instance from the |
ohair@286 | 665 | * EPR class. |
ohair@286 | 666 | */ |
ohair@286 | 667 | public static @NotNull AddressingVersion fromSpecClass(Class<? extends EndpointReference> eprClass) { |
ohair@286 | 668 | if(eprClass==W3CEndpointReference.class) |
ohair@286 | 669 | return W3C; |
ohair@286 | 670 | if(eprClass==MemberSubmissionEndpointReference.class) |
ohair@286 | 671 | return MEMBER; |
ohair@286 | 672 | throw new WebServiceException("Unsupported EPR type: "+eprClass); |
ohair@286 | 673 | } |
ohair@286 | 674 | |
ohair@286 | 675 | /** |
ohair@286 | 676 | * Returns true if the WebServiceFeature is either a {@link AddressingFeature} or |
ohair@286 | 677 | * {@link MemberSubmissionAddressingFeature} and is required. |
ohair@286 | 678 | * |
ohair@286 | 679 | * @param wsf The WebServiceFeature encaps |
ohair@286 | 680 | * @throws WebServiceException if <code>wsf</code> does not contain either {@link AddressingFeature} or |
ohair@286 | 681 | * {@link MemberSubmissionAddressingFeature} |
ohair@286 | 682 | * @return true if <code>wsf</code> requires WS-Addressing |
ohair@286 | 683 | */ |
ohair@286 | 684 | public static boolean isRequired(WebServiceFeature wsf) { |
ohair@286 | 685 | if (wsf.getID().equals(AddressingFeature.ID)) { |
ohair@286 | 686 | return ((AddressingFeature)wsf).isRequired(); |
ohair@286 | 687 | } else if (wsf.getID().equals(MemberSubmissionAddressingFeature.ID)) { |
ohair@286 | 688 | return ((MemberSubmissionAddressingFeature)wsf).isRequired(); |
ohair@286 | 689 | } else |
ohair@286 | 690 | throw new WebServiceException("WebServiceFeature not an Addressing feature: "+ wsf.getID()); |
ohair@286 | 691 | } |
ohair@286 | 692 | |
ohair@286 | 693 | /** |
ohair@286 | 694 | * Returns true if <code>binding</code> contains either a {@link AddressingFeature} or |
ohair@286 | 695 | * {@link MemberSubmissionAddressingFeature} and is required. |
ohair@286 | 696 | * |
ohair@286 | 697 | * @param binding The binding |
ohair@286 | 698 | * @return true if <code>binding</code> requires WS-Addressing |
ohair@286 | 699 | */ |
ohair@286 | 700 | public static boolean isRequired(WSBinding binding) { |
ohair@286 | 701 | AddressingFeature af = binding.getFeature(AddressingFeature.class); |
ohair@286 | 702 | if (af != null) |
ohair@286 | 703 | return af.isRequired(); |
ohair@286 | 704 | MemberSubmissionAddressingFeature msaf = binding.getFeature(MemberSubmissionAddressingFeature.class); |
ohair@286 | 705 | if(msaf != null) |
ohair@286 | 706 | return msaf.isRequired(); |
ohair@286 | 707 | |
ohair@286 | 708 | return false; |
ohair@286 | 709 | } |
ohair@286 | 710 | |
ohair@286 | 711 | /** |
ohair@286 | 712 | * Returns true if <code>binding</code> contains either a {@link AddressingFeature} or |
ohair@286 | 713 | * {@link MemberSubmissionAddressingFeature} and is enabled. |
ohair@286 | 714 | * |
ohair@286 | 715 | * @param binding The binding |
ohair@286 | 716 | * @return true if WS-Addressing is enabled for <code>binding</code>. |
ohair@286 | 717 | */ |
ohair@286 | 718 | public static boolean isEnabled(WSBinding binding) { |
ohair@286 | 719 | return binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class) || |
ohair@286 | 720 | binding.isFeatureEnabled(AddressingFeature.class); |
ohair@286 | 721 | } |
ohair@286 | 722 | |
ohair@286 | 723 | public final static class EPR { |
ohair@286 | 724 | public final Class<? extends EndpointReference> eprClass; |
ohair@286 | 725 | public final String address; |
ohair@286 | 726 | public final String serviceName; |
ohair@286 | 727 | public final String portName; |
ohair@286 | 728 | public final String portTypeName; |
ohair@286 | 729 | public final String referenceParameters; |
ohair@286 | 730 | /** |
ohair@286 | 731 | * Element under which metadata is specified. |
ohair@286 | 732 | * In W3C, it is wsa:Metadata |
ohair@286 | 733 | * In Member, it is directly under mex:MetadataSection |
ohair@286 | 734 | */ |
ohair@286 | 735 | public final QName wsdlMetadata; |
ohair@286 | 736 | public final String referenceProperties; |
ohair@286 | 737 | |
ohair@286 | 738 | public EPR(Class<? extends EndpointReference> eprClass, String address, String serviceName, String portName, |
ohair@286 | 739 | String portTypeName, QName wsdlMetadata, |
ohair@286 | 740 | String referenceParameters, String referenceProperties) { |
ohair@286 | 741 | this.eprClass = eprClass; |
ohair@286 | 742 | this.address = address; |
ohair@286 | 743 | this.serviceName = serviceName; |
ohair@286 | 744 | this.portName = portName; |
ohair@286 | 745 | this.portTypeName = portTypeName; |
ohair@286 | 746 | this.referenceParameters = referenceParameters; |
ohair@286 | 747 | this.referenceProperties = referenceProperties; |
ohair@286 | 748 | this.wsdlMetadata = wsdlMetadata; |
ohair@286 | 749 | |
ohair@286 | 750 | } |
ohair@286 | 751 | } |
ohair@286 | 752 | |
ohair@286 | 753 | } |