use of javax.xml.soap.SOAPHeader in project scout.rt by eclipse.
the class WsseUsernameTokenAuthenticationHandler method handleMessage.
@Override
public final boolean handleMessage(final SOAPMessageContext messageContext) {
if (MessageContexts.isInboundMessage(messageContext)) {
return true;
}
SOAPEnvelope envelope;
SOAPHeader header;
try {
envelope = messageContext.getMessage().getSOAPPart().getEnvelope();
header = envelope.getHeader();
if (header == null) {
header = envelope.addHeader();
}
final SOAPElement security = header.addChildElement(WS_SEC, WSSE, NAME_SPACE_URI);
final SOAPElement userToken = security.addChildElement(USERNAME_TOKEN, WSSE);
userToken.addChildElement(USERNAME, WSSE).addTextNode(StringUtility.valueOf(messageContext.get(InvocationContext.PROP_USERNAME)));
userToken.addChildElement(PASSWORD, WSSE).addTextNode(StringUtility.valueOf(messageContext.get(InvocationContext.PROP_PASSWORD)));
return true;
} catch (final SOAPException e) {
throw new WebServiceException("Failed to set SOAP header for WsseUsernameTokenAuthentication", e);
}
}
use of javax.xml.soap.SOAPHeader in project jbossws-cxf by jbossws.
the class RoutingHandler method handleOutbound.
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
log.info("handleOutbound");
try {
SOAPMessage soapMessage = msgContext.getMessage();
SOAPHeader soapHeader = soapMessage.getSOAPHeader();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name headerName = soapFactory.createName("RoutingHandlerOutbound", "ns1", "http://somens");
SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
she.setValue("true");
SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement) soapBodyElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + "|RoutOut");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPHeader in project jbossws-cxf by jbossws.
the class AuthorizationHandler method handleOutbound.
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
log.info("handleOutbound");
try {
SOAPMessage soapMessage = msgContext.getMessage();
SOAPHeader soapHeader = soapMessage.getSOAPHeader();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name headerName = soapFactory.createName("AuthorizationHandlerOutbound", "ns1", "http://somens");
SOAPHeaderElement she = soapHeader.addHeaderElement(headerName);
she.setValue("true");
SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
SOAPElement soapElement = (SOAPElement) soapBodyElement.getChildElements().next();
String value = soapElement.getValue();
soapElement.setValue(value + "|AuthOut");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPHeader in project jbossws-cxf by jbossws.
the class ProviderMessageTestCase method testProviderMessage.
@Test
@RunAsClient
public void testProviderMessage() throws Exception {
SOAPMessage reqMsg = getRequestMessage();
SOAPEnvelope reqEnv = reqMsg.getSOAPPart().getEnvelope();
URL epURL = baseURL;
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage resMsg = con.call(reqMsg, epURL);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
assertEquals(reqEnv, resEnv);
}
use of javax.xml.soap.SOAPHeader in project Java-OCA-OCPP by ChargeTimeEU.
the class SOAPSyncHelper method getHeaderValue.
public static String getHeaderValue(SOAPMessage message, String tagName) {
String value = null;
try {
SOAPHeader header = message.getSOAPPart().getEnvelope().getHeader();
NodeList elements = header.getElementsByTagNameNS("*", tagName);
if (elements.getLength() > 0) {
value = elements.item(0).getChildNodes().item(0).getTextContent();
}
} catch (SOAPException e) {
logger.warn("getHeaderValue() failed", e);
}
return value;
}
Aggregations