use of javax.xml.soap.MessageFactory in project jbossws-cxf by jbossws.
the class JBWS3084CxfTestCase method testSoapConnectionGet.
@Test
@RunAsClient
public void testSoapConnectionGet() throws Exception {
final String serviceURL = baseURL + "/greetMe";
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
SOAPConnection con = conFac.createConnection();
URL endpoint = new URL(serviceURL);
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPMessage msg = msgFactory.createMessage();
msg.getSOAPBody().addBodyElement(new QName("http://www.jboss.org/jbossws/saaj", "greetMe"));
SOAPMessage response = con.call(msg, endpoint);
QName greetMeResp = new QName("http://www.jboss.org/jbossws/saaj", "greetMeResponse");
Iterator<?> sayHiRespIterator = response.getSOAPBody().getChildElements(greetMeResp);
SOAPElement soapElement = (SOAPElement) sayHiRespIterator.next();
assertNotNull(soapElement);
assertEquals(1, response.countAttachments());
}
use of javax.xml.soap.MessageFactory in project jbossws-cxf by jbossws.
the class ClientSOAPHandler method handleOutbound.
protected boolean handleOutbound(final SOAPMessageContext msgContext) {
try {
SOAPFault fault = null;
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage resMessage = factory.createMessage();
fault = resMessage.getSOAPBody().addFault();
fault.setFaultString("this is an exception thrown by client outbound");
throw new SOAPFaultException(fault);
} catch (SOAPException e) {
// ignore
}
return true;
}
use of javax.xml.soap.MessageFactory in project jbossws-cxf by jbossws.
the class ProviderMessageTestCase method getRequestMessage.
private SOAPMessage getRequestMessage() throws SOAPException, IOException {
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(msgString.getBytes()));
return reqMsg;
}
use of javax.xml.soap.MessageFactory in project jbossws-cxf by jbossws.
the class ProviderMessageTestCase method testProviderMessageNullResponse.
@Test
@RunAsClient
public void testProviderMessageNullResponse() throws Exception {
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(msgStringForNullResponse.getBytes()));
URL epURL = baseURL;
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage resMsg = con.call(reqMsg, epURL);
if (resMsg != null) {
SOAPPart soapPart = resMsg.getSOAPPart();
// verify there's either nothing in the reply or at least the response body is empty
if (soapPart != null && soapPart.getEnvelope() != null && soapPart.getEnvelope().getBody() != null) {
SOAPBody soapBody = soapPart.getEnvelope().getBody();
assertFalse(soapBody.getChildElements().hasNext());
}
}
}
use of javax.xml.soap.MessageFactory in project jbossws-cxf by jbossws.
the class ProviderPayloadTestCase method testProviderMessage.
@Test
@RunAsClient
public void testProviderMessage() throws Exception {
String reqEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + " <env:Body>" + reqString + "</env:Body>" + "</env:Envelope>";
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnvStr.getBytes()));
URL epURL = baseURL;
SOAPMessage resMsg = con.call(reqMsg, epURL);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
Node responseBody = DOMUtils.getFirstChildElement(resEnv.getBody());
assertEquals("wrong namespace: " + responseBody.getNamespaceURI(), "http://org.jboss.ws/provider", responseBody.getNamespaceURI());
assertEquals("wrong localPart: " + responseBody.getLocalName(), "somePayload", responseBody.getLocalName());
String responseString = DOMUtils.getTextContent(responseBody);
assertEquals("wrong content: " + responseString, "Hello:Inbound:LogicalSourceHandler:Outbound:LogicalSourceHandler", responseString);
}
Aggregations