use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class SaajMessageTest method testBodyAttr.
public void testBodyAttr() throws Exception {
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
Source src = new StreamSource(new ByteArrayInputStream(MESSAGE_535.getBytes()));
message.getSOAPPart().setContent(src);
SAAJMessage saajMsg = new SAAJMessage(message);
// breaks the underlying SOAPMessage
saajMsg.hasHeaders();
Source source = saajMsg.readEnvelopeAsSource();
SOAPMessage newMsg = factory.createMessage();
newMsg.getSOAPPart().setContent(source);
SOAPBody body = newMsg.getSOAPBody();
assertEquals("value", body.getAttribute("attr"));
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class SaajMessageTest method testBodyAttr.
/**
* Test for body attribute after SAAJMessage.copy()
*
* @throws Exception - error
*/
public void testBodyAttr() throws Exception {
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapMessage = factory.createMessage();
Source src = new StreamSource(new ByteArrayInputStream(MESSAGE.getBytes()));
soapMessage.getSOAPPart().setContent(src);
SAAJMessage saajMsg = new SAAJMessage(soapMessage);
// breaks the underlying SOAPMessage
saajMsg.hasHeaders();
saajMsg = (SAAJMessage) saajMsg.copy();
SOAPBody soapBody = saajMsg.readAsSOAPMessage().getSOAPBody();
assertEquals("value", soapBody.getAttribute("attr"));
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class NonAnonymousClientTest method test1150.
/**
* SOAP 1.1 two-way message with a non-anonymous ReplyTo address.
*/
public void test1150() throws Exception {
invokeAsync(createDispatchForNonAnonymousWithWSDLWithoutAddressing(), MESSAGES.getNonAnonymousReplyToMessage(), S11_NS, getNonAnonymousEndpointAddress(), clientAddress, ECHO_IN_ACTION, "test1150");
// Lets see we get a response in 60 s
SOAPMessage m = respMsgExchanger.exchange(null, TestConstants.CLIENT_MAX_TIMEOUT, TimeUnit.SECONDS);
// System.out.println("****************************");
// m.writeTo(System.out);
// System.out.println("\n****************************");
SOAPBody sb = m.getSOAPBody();
Iterator itr = sb.getChildElements(new QName("http://example.org/echo", "echoOut"));
assertTrue(itr.hasNext());
}
use of jakarta.xml.soap.SOAPBody in project openmq by eclipse-ee4j.
the class SOAPtoJMSServlet method generateResponseMessage.
/**
* Add a MessageStatus element with the value of "published" to
* the soapMessage.
*/
public SOAPMessage generateResponseMessage(SOAPMessage soapMessage) {
try {
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody soapBody = envelope.getBody();
soapBody.addChildElement("MessageStatus").addTextNode("published");
soapMessage.saveChanges();
} catch (SOAPException soape) {
soape.printStackTrace();
}
return soapMessage;
}
use of jakarta.xml.soap.SOAPBody in project tomee by apache.
the class Inflate method handleMessage.
public boolean handleMessage(SOAPMessageContext mc) {
try {
final SOAPMessage message = mc.getMessage();
final SOAPBody body = message.getSOAPBody();
final String localName = body.getFirstChild().getLocalName();
if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) {
final Node responseNode = body.getFirstChild();
final Node returnNode = responseNode.getFirstChild();
final Node intNode = returnNode.getFirstChild();
final int value = new Integer(intNode.getNodeValue());
intNode.setNodeValue(Integer.toString(value * 1000));
}
return true;
} catch (SOAPException e) {
return false;
}
}
Aggregations