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