use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class SOAPMsgProvider method invoke.
public SOAPMessage invoke(SOAPMessage msg) {
Iterator it = msg.getAttachments();
if (!it.hasNext()) {
throw new WebServiceException("Service didn't receive any attachments.");
}
AttachmentPart part = (AttachmentPart) it.next();
if (!part.getContentId().equals("<SOAPTestHandler@example.jaxws.sun.com>")) {
throw new WebServiceException("Attachment Content-ID expected=" + "SOAPTestHandler@example.jaxws.sun.com got=" + part.getContentId());
}
try {
// keeping white space in the string is intentional
String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body> <VoidTestResponse xmlns=\"urn:test:types\"></VoidTestResponse></soapenv:Body></soapenv:Envelope>";
Source source = new StreamSource(new ByteArrayInputStream(content.getBytes()));
MessageFactory fact = MessageFactory.newInstance();
SOAPMessage soap = fact.createMessage();
soap.getSOAPPart().setContent(source);
soap.getMimeHeaders().addHeader("foo", "bar");
return soap;
} catch (Exception e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.soap.SOAPMessage 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.SOAPMessage 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.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class EchoClientTest method test1170.
/**
* SOAP 1.1 two-way message with wsa:From.
*/
public void test1170() throws Exception {
SOAPMessage response = invoke(createDispatchWithWSDLWithoutAddressing(), MESSAGES.getFromMustUnderstandEchoMessage(), S11_NS, getAddress(), ECHO_IN_ACTION, "test1170");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.writeTo(baos);
assertXpathExists(ENVELOPE_HEADER, baos.toString());
assertXpathExists(ACTION_HEADER, baos.toString());
assertXpathEvaluatesTo(ACTION_HEADER, baos.toString(), ECHO_OUT_ACTION);
}
use of jakarta.xml.soap.SOAPMessage in project metro-jax-ws by eclipse-ee4j.
the class NonAnonymousClientTest method test1194.
/**
* SOAP 1.1 two-way message with a non-anonymous ReplyTo and FaultTo address.
*/
public void test1194() throws Exception {
invokeAsync(createDispatchForNonAnonymousWithWSDLWithoutAddressing(), MESSAGES.getNonAnonymousReplyToMessage(), S11_NS, getNonAnonymousEndpointAddress(), clientAddress, ECHO_IN_ACTION, "fault-test1194");
// 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****************************");
SOAPFault f = m.getSOAPBody().getFault();
assertNotNull(f);
assertEquals(USER_FAULT_CODE, f.getFaultCodeAsQName());
}
Aggregations