52 public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest"; 53 public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest"; 54 public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest"; 55 public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To"; 56 57 private final @NotNull AddressingVersion addressingVersion; 58 private final @NotNull SOAPVersion soapVersion; 59 /** 60 * We can't store {@link Message} here as those may get replaced as 61 * the packet travels through the pipeline. 62 */ 63 private final @NotNull Packet packet; 64 65 public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) { 66 this.addressingVersion = addressingVersion; 67 this.soapVersion = soapVersion; 68 this.packet = packet; 69 } 70 71 /** 72 * Gets the <tt>wsa:To</tt> header. 73 * 74 * @return 75 * null if the incoming SOAP message didn't have the header. 76 */ 77 @Property(JAXWSProperties.ADDRESSING_TO) 78 public String getTo() throws XMLStreamException { 79 if (packet.getMessage() == null) { 80 return null; 81 } 82 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false); 83 if(h==null) return null; 84 return h.getStringContent(); 85 } 86 87 /** 88 * Gets the <tt>wsa:To</tt> header. 89 * 90 * @return 91 * null if the incoming SOAP message didn't have the header. 92 */ 93 @Property(WSA_TO) 94 public WSEndpointReference getToAsReference() throws XMLStreamException { 95 if (packet.getMessage() == null) { 96 return null; 97 } 98 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false); 99 if(h==null) return null; 100 return new WSEndpointReference(h.getStringContent(),addressingVersion); 101 } 102 103 /** 104 * Gets the <tt>wsa:From</tt> header. 105 * 106 * @return 107 * null if the incoming SOAP message didn't have the header. 108 */ 109 @Property(JAXWSProperties.ADDRESSING_FROM) 110 public WSEndpointReference getFrom() throws XMLStreamException { 111 return getEPR(addressingVersion.fromTag); 112 } 113 114 /** 115 * Gets the <tt>wsa:Action</tt> header content as String. 116 * 117 * @return 118 * null if the incoming SOAP message didn't have the header. 119 */ 120 @Property(JAXWSProperties.ADDRESSING_ACTION) 121 public String getAction() { 122 if (packet.getMessage() == null) { 123 return null; 124 } 125 Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false); 126 if(h==null) return null; 127 return h.getStringContent(); 128 } 129 130 /** 131 * Gets the <tt>wsa:MessageID</tt> header content as String. 132 * 133 * @return 134 * null if the incoming SOAP message didn't have the header. 135 */ 136 // WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1 137 @Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID}) 138 public String getMessageID() { 139 if (packet.getMessage() == null) { 140 return null; 141 } 142 return AddressingUtils.getMessageID(packet.getMessage().getHeaders(), addressingVersion,soapVersion); 143 } 144 145 private WSEndpointReference getEPR(QName tag) throws XMLStreamException { 146 if (packet.getMessage() == null) { 147 return null; 148 } 149 Header h = packet.getMessage().getHeaders().get(tag, false); 150 if(h==null) return null; 151 return h.readAsEPR(addressingVersion); | 52 public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest"; 53 public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest"; 54 public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest"; 55 public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To"; 56 57 private final @NotNull AddressingVersion addressingVersion; 58 private final @NotNull SOAPVersion soapVersion; 59 /** 60 * We can't store {@link Message} here as those may get replaced as 61 * the packet travels through the pipeline. 62 */ 63 private final @NotNull Packet packet; 64 65 public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) { 66 this.addressingVersion = addressingVersion; 67 this.soapVersion = soapVersion; 68 this.packet = packet; 69 } 70 71 /** 72 * Gets the {@code wsa:To} header. 73 * 74 * @return 75 * null if the incoming SOAP message didn't have the header. 76 */ 77 @Property(JAXWSProperties.ADDRESSING_TO) 78 public String getTo() throws XMLStreamException { 79 if (packet.getMessage() == null) { 80 return null; 81 } 82 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false); 83 if(h==null) return null; 84 return h.getStringContent(); 85 } 86 87 /** 88 * Gets the {@code wsa:To} header. 89 * 90 * @return 91 * null if the incoming SOAP message didn't have the header. 92 */ 93 @Property(WSA_TO) 94 public WSEndpointReference getToAsReference() throws XMLStreamException { 95 if (packet.getMessage() == null) { 96 return null; 97 } 98 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false); 99 if(h==null) return null; 100 return new WSEndpointReference(h.getStringContent(),addressingVersion); 101 } 102 103 /** 104 * Gets the {@code wsa:From} header. 105 * 106 * @return 107 * null if the incoming SOAP message didn't have the header. 108 */ 109 @Property(JAXWSProperties.ADDRESSING_FROM) 110 public WSEndpointReference getFrom() throws XMLStreamException { 111 return getEPR(addressingVersion.fromTag); 112 } 113 114 /** 115 * Gets the {@code wsa:Action} header content as String. 116 * 117 * @return 118 * null if the incoming SOAP message didn't have the header. 119 */ 120 @Property(JAXWSProperties.ADDRESSING_ACTION) 121 public String getAction() { 122 if (packet.getMessage() == null) { 123 return null; 124 } 125 Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false); 126 if(h==null) return null; 127 return h.getStringContent(); 128 } 129 130 /** 131 * Gets the {@code wsa:MessageID} header content as String. 132 * 133 * @return 134 * null if the incoming SOAP message didn't have the header. 135 */ 136 // WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1 137 @Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID}) 138 public String getMessageID() { 139 if (packet.getMessage() == null) { 140 return null; 141 } 142 return AddressingUtils.getMessageID(packet.getMessage().getHeaders(), addressingVersion,soapVersion); 143 } 144 145 private WSEndpointReference getEPR(QName tag) throws XMLStreamException { 146 if (packet.getMessage() == null) { 147 return null; 148 } 149 Header h = packet.getMessage().getHeaders().get(tag, false); 150 if(h==null) return null; 151 return h.readAsEPR(addressingVersion); |