001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.api.addressing;
038:
039: import com.sun.istack.NotNull;
040: import com.sun.istack.Nullable;
041: import com.sun.xml.stream.buffer.XMLStreamBuffer;
042: import com.sun.xml.ws.addressing.W3CAddressingConstants;
043: import com.sun.xml.ws.addressing.WsaTubeHelper;
044: import com.sun.xml.ws.addressing.v200408.MemberSubmissionAddressingConstants;
045: import com.sun.xml.ws.api.WSBinding;
046: import com.sun.xml.ws.api.message.Header;
047: import com.sun.xml.ws.api.model.wsdl.WSDLPort;
048: import com.sun.xml.ws.api.model.SEIModel;
049: import com.sun.xml.ws.developer.MemberSubmissionAddressingFeature;
050: import com.sun.xml.ws.developer.MemberSubmissionEndpointReference;
051: import com.sun.xml.ws.message.stream.OutboundStreamHeader;
052:
053: import javax.xml.namespace.QName;
054: import javax.xml.stream.XMLStreamException;
055: import javax.xml.ws.EndpointReference;
056: import javax.xml.ws.WebServiceException;
057: import javax.xml.ws.WebServiceFeature;
058: import javax.xml.ws.soap.AddressingFeature;
059: import javax.xml.ws.wsaddressing.W3CEndpointReference;
060: import java.io.ByteArrayInputStream;
061:
062: /**
063: * 'Traits' object that absorbs differences of WS-Addressing versions.
064: *
065: * @author Arun Gupta
066: */
067: public enum AddressingVersion {
068:
069: W3C("http://www.w3.org/2005/08/addressing",
070: W3CAddressingConstants.ANONYMOUS_EPR,
071: "http://www.w3.org/2006/05/addressing/wsdl",
072: "http://www.w3.org/2006/05/addressing/wsdl",
073: "http://www.w3.org/2005/08/addressing/anonymous",
074: "http://www.w3.org/2005/08/addressing/none", new EPR(
075: W3CEndpointReference.class, "Address",
076: "ServiceName", "EndpointName", "InterfaceName",
077: new QName("http://www.w3.org/2005/08/addressing",
078: "Metadata"), "ReferenceParameters", null)) {
079:
080: /* package */String getActionMismatchLocalName() {
081: return "ActionMismatch";
082: }
083:
084: @Override
085: public boolean isReferenceParameter(String localName) {
086: return localName.equals("ReferenceParameters");
087: }
088:
089: @Override
090: public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort,
091: SEIModel seiModel, WSBinding binding) {
092: return new com.sun.xml.ws.addressing.WsaTubeHelperImpl(
093: wsdlPort, seiModel, binding);
094: }
095:
096: @Override
097: /* package */String getMapRequiredLocalName() {
098: return "MessageAddressingHeaderRequired";
099: }
100:
101: @Override
102: public String getMapRequiredText() {
103: return "A required header representing a Message Addressing Property is not present";
104: }
105:
106: /* package */String getInvalidAddressLocalName() {
107: return "InvalidAddress";
108: }
109:
110: @Override
111: /* package */String getInvalidMapLocalName() {
112: return "InvalidAddressingHeader";
113: }
114:
115: @Override
116: public String getInvalidMapText() {
117: return "A header representing a Message Addressing Property is not valid and the message cannot be processed";
118: }
119:
120: @Override
121: /* package */String getInvalidCardinalityLocalName() {
122: return "InvalidCardinality";
123: }
124:
125: /*package*/Header createReferenceParameterHeader(
126: XMLStreamBuffer mark, String nsUri, String localName) {
127: return new OutboundReferenceParameterHeader(mark, nsUri,
128: localName);
129: }
130:
131: /*package*/String getIsReferenceParameterLocalName() {
132: return "IsReferenceParameter";
133: }
134:
135: /* package */String getWsdlAnonymousLocalName() {
136: return "Anonymous";
137: }
138:
139: public String getPrefix() {
140: return "wsa";
141: }
142:
143: public String getWsdlPrefix() {
144: return "wsaw";
145: }
146:
147: public Class<? extends WebServiceFeature> getFeatureClass() {
148: return AddressingFeature.class;
149: }
150: },
151: MEMBER(
152: "http://schemas.xmlsoap.org/ws/2004/08/addressing",
153: MemberSubmissionAddressingConstants.ANONYMOUS_EPR,
154: "http://schemas.xmlsoap.org/ws/2004/08/addressing",
155: "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy",
156: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
157: "", new EPR(MemberSubmissionEndpointReference.class,
158: "Address", "ServiceName", "PortName", "PortType",
159: MemberSubmissionAddressingConstants.MEX_METADATA,
160: "ReferenceParameters", "ReferenceProperties")) {
161: /* package */String getActionMismatchLocalName() {
162: return "InvalidMessageInformationHeader";
163: }
164:
165: @Override
166: public boolean isReferenceParameter(String localName) {
167: return localName.equals("ReferenceParameters")
168: || localName.equals("ReferenceProperties");
169: }
170:
171: @Override
172: public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort,
173: SEIModel seiModel, WSBinding binding) {
174: return new com.sun.xml.ws.addressing.v200408.WsaTubeHelperImpl(
175: wsdlPort, seiModel, binding);
176: }
177:
178: @Override
179: /* package */String getMapRequiredLocalName() {
180: return "MessageInformationHeaderRequired";
181: }
182:
183: @Override
184: public String getMapRequiredText() {
185: return "A required message information header, To, MessageID, or Action, is not present.";
186: }
187:
188: /* package */String getInvalidAddressLocalName() {
189: return getInvalidMapLocalName();
190: }
191:
192: @Override
193: /* package */String getInvalidMapLocalName() {
194: return "InvalidMessageInformationHeader";
195: }
196:
197: @Override
198: public String getInvalidMapText() {
199: return "A message information header is not valid and the message cannot be processed.";
200: }
201:
202: @Override
203: /* package */String getInvalidCardinalityLocalName() {
204: return getInvalidMapLocalName();
205: }
206:
207: /*package*/Header createReferenceParameterHeader(
208: XMLStreamBuffer mark, String nsUri, String localName) {
209: return new OutboundStreamHeader(mark, nsUri, localName);
210: }
211:
212: /*package*/String getIsReferenceParameterLocalName() {
213: return "";
214: }
215:
216: /* package */String getWsdlAnonymousLocalName() {
217: return "";
218: }
219:
220: public String getPrefix() {
221: return "wsa";
222: }
223:
224: public String getWsdlPrefix() {
225: return "wsaw";
226: }
227:
228: public Class<? extends WebServiceFeature> getFeatureClass() {
229: return MemberSubmissionAddressingFeature.class;
230: }
231: };
232:
233: /**
234: * Namespace URI
235: */
236: public final String nsUri;
237:
238: /**
239: * Namespace URI for the WSDL Binding
240: */
241: public final String wsdlNsUri;
242:
243: /**
244: * Representing either {@link W3CEndpointReference} or
245: * {@link MemberSubmissionEndpointReference}.
246: */
247: public final EPR eprType;
248:
249: /**
250: * Namespace URI for the WSDL Binding
251: */
252: public final String policyNsUri;
253:
254: /**
255: * Gets the anonymous URI value associated with this WS-Addressing version.
256: */
257: public final @NotNull
258: String anonymousUri;
259:
260: /**
261: * Gets the none URI value associated with this WS-Addressing version.
262: */
263: public final @NotNull
264: String noneUri;
265:
266: /**
267: * Represents the anonymous EPR.
268: */
269: public final WSEndpointReference anonymousEpr;
270:
271: /**
272: * Represents the To QName in the SOAP message for a specific WS-Addressing Version.
273: */
274: public final QName toTag;
275:
276: /**
277: * Represents the From QName in the SOAP message for a specific WS-Addressing Version.
278: */
279: public final QName fromTag;
280:
281: /**
282: * Represents the ReplyTo QName in the SOAP message for a specific WS-Addressing Version.
283: */
284: public final QName replyToTag;
285:
286: /**
287: * Represents the FaultTo QName for a specific WS-Addressing Version.
288: */
289: public final QName faultToTag;
290:
291: /**
292: * Represents the Action QName in the SOAP message for a specific WS-Addressing Version.
293: */
294: public final QName actionTag;
295:
296: /**
297: * Represents the MessageID QName in the SOAP message for a specific WS-Addressing Version.
298: */
299: public final QName messageIDTag;
300:
301: /**
302: * Represents the RelatesTo QName in the SOAP message for a specific WS-Addressing Version.
303: */
304: public final QName relatesToTag;
305:
306: /**
307: * Represents the QName of the fault code when a required header representing a
308: * WS-Addressing Message Addressing Property is not present.
309: */
310: public final QName mapRequiredTag;
311:
312: /**
313: * Represents the QName of the fault code when Action is not supported at this endpoint.
314: */
315: public final QName actionMismatchTag;
316:
317: /**
318: * Represents the QName of the fault code when Action is not supported at this endpoint.
319: */
320: public final QName actionNotSupportedTag;
321:
322: /**
323: * Represents the text of the fault when Action is not supported at this endpoint.
324: */
325: public final String actionNotSupportedText;
326:
327: /**
328: * Represents the QName of the fault code when a header representing a
329: * WS-Addressing Message Addressing Property is invalid and cannot be processed.
330: */
331: public final QName invalidMapTag;
332:
333: /**
334: * Represents the QName of the fault code when a header representing a
335: * WS-Addressing Message Addressing Property occurs greater than expected number.
336: */
337: public final QName invalidCardinalityTag;
338:
339: /**
340: * Represents the QName of the fault code when a header representing an
341: * address is not valid.
342: */
343: public final QName invalidAddressTag;
344:
345: /**
346: * Represents the QName of the element that conveys additional information
347: * on the pre-defined WS-Addressing faults.
348: */
349: public final QName problemHeaderQNameTag;
350:
351: /**
352: * Represents the QName of the element that conveys additional information
353: * if Action is not matching with that expected.
354: */
355: public final QName problemActionTag;
356:
357: /**
358: * Represents the QName of the header element that is used to capture the fault detail
359: * if there is a fault processing WS-Addressing Message Addressing Property. This is
360: * only used for SOAP 1.1.
361: */
362: public final QName faultDetailTag;
363:
364: /**
365: * Fault sub-sub-code that represents
366: * "Specifies that the invalid header was expected to be an EPR but did not contain an [address]."
367: */
368: public final QName fault_missingAddressInEpr;
369:
370: /**
371: * Represents the Action QName in the WSDL for a specific WS-Addressing Version.
372: */
373: public final QName wsdlActionTag;
374:
375: /**
376: * Represents the WSDL extension QName for a specific WS-Addressing Version.
377: */
378: public final QName wsdlExtensionTag;
379:
380: /**
381: * Represents the WSDL anonymous QName for a specific WS-Addressing Version.
382: */
383: public final QName wsdlAnonymousTag;
384:
385: /**
386: * Represents the QName of the reference parameter in a SOAP message. This is
387: * only valid for W3C WS-Addressing.
388: */
389: public final QName isReferenceParameterTag;
390:
391: private static final String EXTENDED_FAULT_NAMESPACE = "http://jax-ws.dev.java.net/addressing/fault";
392: public static final String UNSET_OUTPUT_ACTION = "http://jax-ws.dev.java.net/addressing/output-action-not-set";
393: public static final String UNSET_INPUT_ACTION = "http://jax-ws.dev.java.net/addressing/input-action-not-set";
394:
395: /**
396: * Fault sub-sub-code that represents duplicate <Address> element in EPR.
397: * This is a fault code not defined in the spec.
398: */
399: public static final QName fault_duplicateAddressInEpr = new QName(
400: EXTENDED_FAULT_NAMESPACE, "DuplicateAddressInEpr");
401:
402: private AddressingVersion(String nsUri, String anonymousEprString,
403: String wsdlNsUri, String policyNsUri, String anonymousUri,
404: String noneUri, EPR eprType) {
405: this .nsUri = nsUri;
406: this .wsdlNsUri = wsdlNsUri;
407: this .policyNsUri = policyNsUri;
408: this .anonymousUri = anonymousUri;
409: this .noneUri = noneUri;
410: toTag = new QName(nsUri, "To");
411: fromTag = new QName(nsUri, "From");
412: replyToTag = new QName(nsUri, "ReplyTo");
413: faultToTag = new QName(nsUri, "FaultTo");
414: actionTag = new QName(nsUri, "Action");
415: messageIDTag = new QName(nsUri, "MessageID");
416: relatesToTag = new QName(nsUri, "RelatesTo");
417:
418: mapRequiredTag = new QName(nsUri, getMapRequiredLocalName());
419: actionMismatchTag = new QName(nsUri,
420: getActionMismatchLocalName());
421: actionNotSupportedTag = new QName(nsUri, "ActionNotSupported");
422: actionNotSupportedText = "The \"%s\" cannot be processed at the receiver";
423: invalidMapTag = new QName(nsUri, getInvalidMapLocalName());
424: invalidAddressTag = new QName(nsUri,
425: getInvalidAddressLocalName());
426: invalidCardinalityTag = new QName(nsUri,
427: getInvalidCardinalityLocalName());
428: faultDetailTag = new QName(nsUri, "FaultDetail");
429:
430: problemHeaderQNameTag = new QName(nsUri, "ProblemHeaderQName");
431: problemActionTag = new QName(nsUri, "ProblemAction");
432:
433: fault_missingAddressInEpr = new QName(nsUri,
434: "MissingAddressInEPR", "wsa");
435: isReferenceParameterTag = new QName(nsUri,
436: getIsReferenceParameterLocalName());
437:
438: wsdlActionTag = new QName(wsdlNsUri, "Action");
439: wsdlExtensionTag = new QName(wsdlNsUri, "UsingAddressing");
440: wsdlAnonymousTag = new QName(wsdlNsUri,
441: getWsdlAnonymousLocalName());
442:
443: // create stock anonymous EPR
444: try {
445: this .anonymousEpr = new WSEndpointReference(
446: new ByteArrayInputStream(anonymousEprString
447: .getBytes()), this );
448: } catch (XMLStreamException e) {
449: throw new Error(e); // bug in our code as EPR should parse.
450: }
451: this .eprType = eprType;
452: }
453:
454: /**
455: * Gets the local name of the fault when a header representing a WS-Addressing Action is not same as SOAPAction
456: *
457: * @return local name
458: */
459: /* package */abstract String getActionMismatchLocalName();
460:
461: /**
462: * Returns {@link AddressingVersion} whose {@link #nsUri} equals to
463: * the given string.
464: *
465: * This method does not perform input string validation.
466: *
467: * @param nsUri
468: * must not be null.
469: * @return always non-null.
470: */
471: public static AddressingVersion fromNsUri(String nsUri) {
472: if (nsUri.equals(W3C.nsUri))
473: return W3C;
474:
475: if (nsUri.equals(MEMBER.nsUri))
476: return MEMBER;
477:
478: return null;
479: }
480:
481: /**
482: * Gets the {@link AddressingVersion} from a {@link WSBinding}
483: *
484: * @param binding WSDL binding
485: * @return
486: * addresing version enabled, or null if none is enabled.
487: */
488: public static @Nullable
489: AddressingVersion fromBinding(WSBinding binding) {
490: // TODO: who is responsible for reporting an error if both versions
491: // are on?
492: if (binding.isFeatureEnabled(AddressingFeature.class))
493: return W3C;
494:
495: if (binding
496: .isFeatureEnabled(MemberSubmissionAddressingFeature.class))
497: return MEMBER;
498:
499: return null;
500: }
501:
502: /**
503: * Gets the {@link AddressingVersion} from a {@link WSDLPort}
504: *
505: * @param port WSDL port
506: * @return addresing version
507: */
508: public static AddressingVersion fromPort(WSDLPort port) {
509: if (port == null)
510: return null;
511:
512: WebServiceFeature wsf = port
513: .getFeature(AddressingFeature.class);
514: if (wsf == null) {
515: wsf = port
516: .getFeature(MemberSubmissionAddressingFeature.class);
517: }
518: if (wsf == null)
519: return null;
520:
521: return fromFeature(wsf);
522: }
523:
524: /**
525: * Returns {@link #nsUri} associated with this {@link AddressingVersion}
526: *
527: * @return namespace URI
528: * @deprecated
529: * Use {@link #nsUri}.
530: */
531: public String getNsUri() {
532: return nsUri;
533: }
534:
535: /**
536: * Returns true if the given local name is considered as
537: * a reference parameter in EPR.
538: *
539: * For W3C, this means "ReferenceParameters",
540: * and for the member submission version, this means
541: * either "ReferenceParameters" or "ReferenceProperties".
542: */
543: public abstract boolean isReferenceParameter(String localName);
544:
545: /**
546: * Returns WsaTubeHelper for the WS-Addressing version identified by <code>binding</code>
547: * {@link WSBinding} and for the {@link WSDLPort} port.
548: *
549: * @return WS-A version specific helper
550: */
551: public abstract WsaTubeHelper getWsaHelper(WSDLPort wsdlPort,
552: SEIModel seiModel, WSBinding binding);
553:
554: /**
555: * Gets the none URI value associated with this WS-Addressing version.
556: *
557: * @return none URI value
558: * @deprecated
559: * Use {@link #noneUri}.
560: */
561: public final String getNoneUri() {
562: return noneUri;
563: }
564:
565: /**
566: * Gets the anonymous URI value associated with this WS-Addressing version.
567: *
568: * @deprecated
569: * Use {@link #anonymousUri}
570: */
571: public final String getAnonymousUri() {
572: return anonymousUri;
573: }
574:
575: /**
576: * Gets the default fault Action value associated with this WS-Addressing version.
577: *
578: * @return default fault Action value
579: */
580: public String getDefaultFaultAction() {
581: return nsUri + "/fault";
582: }
583:
584: /**
585: * Gets the local name of the fault when a header representing a WS-Addressing Message
586: * Addresing Property is absent.
587: *
588: * @return local name
589: */
590: /* package */abstract String getMapRequiredLocalName();
591:
592: /**
593: * Gets the description text when a required WS-Addressing header representing a
594: * Message Addressing Property is absent.
595: *
596: * @return description text
597: */
598: public abstract String getMapRequiredText();
599:
600: /**
601: * Gets the local name of the fault when a header representing anaddress is invalid.
602: * @return local name
603: */
604: /* package */abstract String getInvalidAddressLocalName();
605:
606: /**
607: * Gets the local name of the fault when a header representing a WS-Addressing Message
608: * Addresing Property is invalid and cannot be processed.
609: *
610: * @return local name
611: */
612: /* package */abstract String getInvalidMapLocalName();
613:
614: /**
615: * Gets the description text when a header representing a WS-Addressing
616: * Message Addressing Property is invalid and cannot be processed.
617: *
618: * @return description text
619: */
620: public abstract String getInvalidMapText();
621:
622: /**
623: * Gets the local name of the fault when a header representing a WS-Addressing Message
624: * Addresing Property occurs greater than expected number.
625: *
626: * @return local name
627: */
628: /* package */abstract String getInvalidCardinalityLocalName();
629:
630: /* package */abstract String getWsdlAnonymousLocalName();
631:
632: public abstract String getPrefix();
633:
634: public abstract String getWsdlPrefix();
635:
636: public abstract Class<? extends WebServiceFeature> getFeatureClass();
637:
638: /**
639: * Creates an outbound {@link Header} from a reference parameter.
640: */
641: /*package*/abstract Header createReferenceParameterHeader(
642: XMLStreamBuffer mark, String nsUri, String localName);
643:
644: /**
645: * Gets the local name for wsa:IsReferenceParameter. This method will return a valid
646: * value only valid for W3C WS-Addressing. For Member Submission WS-Addressing, this method
647: * returns null.
648: */
649: /*package*/abstract String getIsReferenceParameterLocalName();
650:
651: public static AddressingVersion fromFeature(WebServiceFeature af) {
652: if (af.getID().equals(AddressingFeature.ID))
653: return W3C;
654: else if (af.getID()
655: .equals(MemberSubmissionAddressingFeature.ID))
656: return MEMBER;
657: else
658: return null;
659: }
660:
661: /**
662: * Gets the {@link WebServiceFeature} corresponding to the namespace URI of
663: * WS-Addressing policy assertion in the WSDL. <code>enabled</code> and
664: * <code>required</code> are used to initialize the value of the feature.
665: *
666: * @param nsUri namespace URI of the WS-Addressing policy assertion in the WSDL
667: * @param enabled true if feature is to be enabled, false otherwise
668: * @param required true if feature is required, false otherwise. Corresponds
669: * to wsdl:required on the extension/assertion.
670: * @return WebServiceFeature corresponding to the assertion namespace URI
671: * @throws WebServiceException if an unsupported namespace URI is passed
672: */
673: public static @NotNull
674: WebServiceFeature getFeature(String nsUri, boolean enabled,
675: boolean required) {
676: if (nsUri.equals(W3C.policyNsUri))
677: return new AddressingFeature(enabled, required);
678: else if (nsUri.equals(MEMBER.policyNsUri))
679: return new MemberSubmissionAddressingFeature(enabled,
680: required);
681: else
682: throw new WebServiceException("Unsupported namespace URI: "
683: + nsUri);
684: }
685:
686: /**
687: * Gets the corresponding {@link AddressingVersion} instance from the
688: * EPR class.
689: */
690: public static @NotNull
691: AddressingVersion fromSpecClass(
692: Class<? extends EndpointReference> eprClass) {
693: if (eprClass == W3CEndpointReference.class)
694: return W3C;
695: if (eprClass == MemberSubmissionEndpointReference.class)
696: return MEMBER;
697: throw new WebServiceException("Unsupported EPR type: "
698: + eprClass);
699: }
700:
701: /**
702: * Returns true if the WebServiceFeature is either a {@link AddressingFeature} or
703: * {@link MemberSubmissionAddressingFeature} and is required.
704: *
705: * @param wsf The WebServiceFeature encaps
706: * @throws WebServiceException if <code>wsf</code> does not contain either {@link AddressingFeature} or
707: * {@link MemberSubmissionAddressingFeature}
708: * @return true if <code>wsf</code> requires WS-Addressing
709: */
710: public static boolean isRequired(WebServiceFeature wsf) {
711: if (wsf.getID().equals(AddressingFeature.ID)) {
712: return ((AddressingFeature) wsf).isRequired();
713: } else if (wsf.getID().equals(
714: MemberSubmissionAddressingFeature.ID)) {
715: return ((MemberSubmissionAddressingFeature) wsf)
716: .isRequired();
717: } else
718: throw new WebServiceException(
719: "WebServiceFeature not an Addressing feature: "
720: + wsf.getID());
721: }
722:
723: /**
724: * Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
725: * {@link MemberSubmissionAddressingFeature} and is required.
726: *
727: * @param binding The binding
728: * @return true if <code>binding</code> requires WS-Addressing
729: */
730: public static boolean isRequired(WSBinding binding) {
731: AddressingFeature af = binding
732: .getFeature(AddressingFeature.class);
733: if (af != null)
734: return af.isRequired();
735: MemberSubmissionAddressingFeature msaf = binding
736: .getFeature(MemberSubmissionAddressingFeature.class);
737: if (msaf != null)
738: return msaf.isRequired();
739:
740: return false;
741: }
742:
743: /**
744: * Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
745: * {@link MemberSubmissionAddressingFeature} and is enabled.
746: *
747: * @param binding The binding
748: * @return true if WS-Addressing is enabled for <code>binding</code>.
749: */
750: public static boolean isEnabled(WSBinding binding) {
751: return binding
752: .isFeatureEnabled(MemberSubmissionAddressingFeature.class)
753: || binding.isFeatureEnabled(AddressingFeature.class);
754: }
755:
756: public final static class EPR {
757: public final Class<? extends EndpointReference> eprClass;
758: public final String address;
759: public final String serviceName;
760: public final String portName;
761: public final String portTypeName;
762: public final String referenceParameters;
763: /**
764: * Element under which metadata is specified.
765: * In W3C, it is wsa:Metadata
766: * In Member, it is directly under mex:MetadataSection
767: */
768: public final QName wsdlMetadata;
769: public final String referenceProperties;
770:
771: public EPR(Class<? extends EndpointReference> eprClass,
772: String address, String serviceName, String portName,
773: String portTypeName, QName wsdlMetadata,
774: String referenceParameters, String referenceProperties) {
775: this.eprClass = eprClass;
776: this.address = address;
777: this.serviceName = serviceName;
778: this.portName = portName;
779: this.portTypeName = portTypeName;
780: this.referenceParameters = referenceParameters;
781: this.referenceProperties = referenceProperties;
782: this.wsdlMetadata = wsdlMetadata;
783:
784: }
785: }
786:
787: }
|