use of javax.xml.soap.SOAPBodyElement in project jbossws-cxf by jbossws.
the class LogHandler method handleOutbound.
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext) {
log.info("handleOutbound");
try {
SOAPMessage soapMessage = msgContext.getMessage();
getFailsafeSOAPHeader(soapMessage);
SOAPBody soapBody = soapMessage.getSOAPBody();
// SOAPFactory soapFactory = SOAPFactory.newInstance();
// Name headerName = soapFactory.createName("LogHandlerOutbound", "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 + "|LogOut");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPBodyElement in project jbossws-cxf by jbossws.
the class LogHandler method handleInbound.
@Override
protected boolean handleInbound(SOAPMessageContext msgContext) {
log.info("handleInbound");
try {
SOAPMessage soapMessage = msgContext.getMessage();
getFailsafeSOAPHeader(soapMessage);
SOAPBody soapBody = soapMessage.getSOAPBody();
// SOAPFactory soapFactory = SOAPFactory.newInstance();
// Name headerName = soapFactory.createName("LogHandlerInbound", "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 + "|LogIn");
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of javax.xml.soap.SOAPBodyElement 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();
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.SOAPBodyElement in project jbossws-cxf by jbossws.
the class MultipartContentTypeTestCase method testSendMultipartSoapMessage.
@Test
@RunAsClient
public void testSendMultipartSoapMessage() throws Exception {
final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
final SOAPMessage msg = msgFactory.createMessage();
final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:ledegen:soap-attachment:1.0", "echoImage"));
bodyElement.addTextNode("cid:" + IN_IMG_NAME);
final AttachmentPart ap = msg.createAttachmentPart();
ap.setDataHandler(getResource("saaj/jbws3857/" + IN_IMG_NAME));
ap.setContentId(IN_IMG_NAME);
msg.addAttachmentPart(ap);
final SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
final SOAPConnection connection = conFactory.createConnection();
final SOAPMessage response = connection.call(msg, new URL("http://" + baseURL.getHost() + ":" + baseURL.getPort() + "/" + PROJECT_NAME + "/testServlet"));
final String contentTypeWeHaveSent = getBodyElementTextValue(response);
assertContentTypeStarts("multipart/related", contentTypeWeHaveSent);
}
use of javax.xml.soap.SOAPBodyElement in project jbossws-cxf by jbossws.
the class SoapMultipartCheckerServlet method replyRequestedContentTypeInResponse.
private void replyRequestedContentTypeInResponse(final String requestedContentType, final HttpServletResponse resp) throws Exception {
final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
final SOAPMessage msg = msgFactory.createMessage();
final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:not-important:1.0", "requestedContentType"));
bodyElement.addTextNode(requestedContentType);
resp.setStatus(HttpServletResponse.SC_OK);
resp.setHeader("Content-Type", "application/soap+xml; charset=utf-8");
final OutputStream os = resp.getOutputStream();
msg.writeTo(os);
os.close();
}
Aggregations