use of com.sun.xml.ws.api.message.MessageHeaders in project metro-jax-ws by eclipse-ee4j.
the class ActionBasedOperationFinder method getWSDLOperationMapping.
public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
MessageHeaders hl = request.getMessage().getHeaders();
String action = AddressingUtils.getAction(hl, av, binding.getSOAPVersion());
if (action == null)
// Addressing is not enagaged, return null to use other ways to dispatch.
return null;
Message message = request.getMessage();
QName payloadName;
String localPart = message.getPayloadLocalPart();
if (localPart == null) {
payloadName = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD;
} else {
String nsUri = message.getPayloadNamespaceURI();
if (nsUri == null)
nsUri = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD_NSURI;
payloadName = new QName(nsUri, localPart);
}
WSDLOperationMapping opMapping = uniqueOpSignatureMap.get(new ActionBasedOperationSignature(action, payloadName));
if (opMapping != null)
return opMapping;
// Seems like in Wstrust STS wsdls, the payload does not match what is specified in the wsdl leading to incorrect
// wsdl operation resolution. Use just wsa:Action to dispatch as a last resort.
// try just with wsa:Action
opMapping = actionMap.get(action);
if (opMapping != null)
return opMapping;
// invalid action header
Message result = Messages.create(action, av, binding.getSOAPVersion());
throw new DispatchException(result);
}
use of com.sun.xml.ws.api.message.MessageHeaders in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method writeTo.
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
if (envelopeReader != null)
readEnvelope(this);
contentHandler.setDocumentLocator(NULL_LOCATOR);
contentHandler.startDocument();
envelopeTag.writeStart(contentHandler);
if (hasHeaders() && headerTag == null)
headerTag = new TagInfoset(envelopeTag.nsUri, "Header", envelopeTag.prefix, EMPTY_ATTS);
if (headerTag != null) {
headerTag.writeStart(contentHandler);
if (hasHeaders()) {
MessageHeaders headers = getHeaders();
for (Header h : headers.asList()) {
// shouldn't JDK be smart enough to use array-style indexing for this foreach!?
h.writeTo(contentHandler, errorHandler);
}
}
headerTag.writeEnd(contentHandler);
}
bodyTag.writeStart(contentHandler);
writePayloadTo(contentHandler, errorHandler, true);
bodyTag.writeEnd(contentHandler);
envelopeTag.writeEnd(contentHandler);
contentHandler.endDocument();
}
use of com.sun.xml.ws.api.message.MessageHeaders in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageHeadersTest method testMustUnderstand.
public void testMustUnderstand() throws Exception {
SOAPMessage sm = makeSOAPMessage(MESSAGE);
// SAAJMessage saajMsg = new SAAJMessage(sm);
MessageHeaders hdrs = new SAAJMessageHeaders(sm, SOAPVersion.SOAP_11);
// new must understand header
Header newHdr = new StringHeader(new QName("myNs", "stringHeader1"), "stringHeaderValue1", SOAPVersion.SOAP_11, true);
hdrs.add(newHdr);
Set<QName> notUnderstoods = hdrs.getNotUnderstoodHeaders(null, null, null);
assertNotNull(notUnderstoods);
assertEquals(1, notUnderstoods.size());
// verify the understood headers list
Set<QName> understoods = hdrs.getUnderstoodHeaders();
// none of the headers is marked understood
assertNull(understoods);
// assertEquals(1, understoods.size());
// the new header should not be understood yet
assertFalse(hdrs.isUnderstood(newHdr));
// now "understand" the header
hdrs.understood(newHdr);
// the new header should be understood now
assertTrue(hdrs.isUnderstood(newHdr));
notUnderstoods = hdrs.getNotUnderstoodHeaders(null, null, null);
assertNotNull(notUnderstoods);
assertEquals(0, notUnderstoods.size());
// make sure the newly understood header now shows up in the understoodHeaders
understoods = hdrs.getUnderstoodHeaders();
assertNotNull(understoods);
assertEquals(1, understoods.size());
}
use of com.sun.xml.ws.api.message.MessageHeaders in project metro-jax-ws by eclipse-ee4j.
the class StatefulInstanceResolver method resolve.
@Override
@NotNull
public T resolve(Packet request) {
MessageHeaders headers = request.getMessage().getHeaders();
Header header = headers.get(COOKIE_TAG, true);
String id = null;
if (header != null) {
// find the instance
id = header.getStringContent();
Instance o = haMap.get(id);
if (o != null) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Restarting timer for objectId/Instance = [ {0} / {1} ]", new Object[] { id, o });
}
o.restartTimer();
return o.instance;
}
// huh? what is this ID?
logger.log(Level.INFO, "Request had an unrecognized object ID {0}", id);
} else {
logger.fine("No objectId header received");
}
// need to fallback
T flbk = this.fallback;
if (flbk != null) {
return flbk;
}
if (id == null) {
throw new WebServiceException(ServerMessages.STATEFUL_COOKIE_HEADER_REQUIRED(COOKIE_TAG));
} else {
throw new WebServiceException(ServerMessages.STATEFUL_COOKIE_HEADER_INCORRECT(COOKIE_TAG, id));
}
}
use of com.sun.xml.ws.api.message.MessageHeaders in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method writeToBodyStart.
public void writeToBodyStart(XMLStreamWriter writer) throws XMLStreamException {
if (envelopeReader != null)
readEnvelope(this);
writer.writeStartDocument();
envelopeTag.writeStart(writer);
// write headers
MessageHeaders hl = getHeaders();
if (hl.hasHeaders() && headerTag == null)
headerTag = new TagInfoset(envelopeTag.nsUri, "Header", envelopeTag.prefix, EMPTY_ATTS);
if (headerTag != null) {
headerTag.writeStart(writer);
if (hl.hasHeaders()) {
for (Header h : hl.asList()) {
h.writeTo(writer);
}
}
writer.writeEndElement();
}
bodyTag.writeStart(writer);
}
Aggregations