use of javax.xml.soap.SOAPException in project jbossws-cxf by jbossws.
the class SOAPHandler method handleInbound.
@Override
protected boolean handleInbound(final SOAPMessageContext msgContext) {
log.info("handleInbound()");
try {
SOAPMessage message = msgContext.getMessage();
SOAPBody body = message.getSOAPBody();
Document document = body.extractContentAsDocument();
Node node = document;
log.info(DOMWriter.printNode(node, true));
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node current = nodes.item(i);
NodeList childNodes = current.getChildNodes();
for (int j = 0; j < childNodes.getLength(); j++) {
Node currentChildNode = childNodes.item(j);
if ("result".equals(currentChildNode.getLocalName())) {
currentChildNode.setTextContent(currentChildNode.getTextContent() + " modified in handler");
}
}
}
log.info(DOMWriter.printNode(node, true));
// Add document back as removed by call to 'extractContentAsDocument()'
body.addDocument(document);
message.saveChanges();
} catch (SOAPException e) {
throw new RuntimeException("Error in Handler", e);
}
log.info("Finished");
return true;
}
use of javax.xml.soap.SOAPException in project jbossws-cxf by jbossws.
the class EndpointHandler method handleOutbound.
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
log.info("handleOutbound");
try {
SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage();
soapMessage.getSOAPHeader();
SOAPBody soapBody = soapMessage.getSOAPBody();
// SOAPFactory soapFactory = SOAPFactory.newInstance();
// Name headerName = soapFactory.createName("EndpointHandlerOutbound", "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 + "|EpOut");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPException in project jbossws-cxf by jbossws.
the class RoutingHandler method handleInbound.
@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
log.info("handleInbound");
try {
SOAPMessage soapMessage = msgContext.getMessage();
soapMessage.getSOAPHeader();
SOAPBody soapBody = soapMessage.getSOAPBody();
// SOAPFactory soapFactory = SOAPFactory.newInstance();
// Name headerName = soapFactory.createName("RoutingHandlerInbound", "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 + "|RoutIn");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPException in project jbossws-cxf by jbossws.
the class ServerHandler method appendContentToRequestElement.
private void appendContentToRequestElement(SOAPMessage message, boolean wsaEnabled) {
try {
Iterator<?> ite = message.getSOAPBody().getChildElements(new QName("http://TestEndpoint.org/xsd", "MtomRequest"));
SOAPElement element = (SOAPElement) ite.next();
SOAPElement requestElement = (SOAPElement) element.getChildElements(new QName("", "request")).next();
if (wsaEnabled) {
requestElement.setTextContent("--ClientAddressingEnabled");
} else {
requestElement.setTextContent("--ClientAddressingNotEnabled");
}
} catch (SOAPException e) {
}
}
use of javax.xml.soap.SOAPException in project jbossws-cxf by jbossws.
the class CustomHandler method handleInbound.
@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
try {
SOAPMessage soapMessage = msgContext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
SOAPBodyElement soapBodyElement = (SOAPBodyElement) soapBody.getChildElements().next();
if (soapBodyElement.getChildElements().hasNext()) {
SOAPElement payload = (SOAPElement) soapBodyElement.getChildElements().next();
String value = payload.getValue();
payload.setValue(value + "World");
}
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
Aggregations