use of javax.xml.soap.SOAPConnection 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.SOAPConnection in project jbossws-cxf by jbossws.
the class WebResultTestCase method testMessageAccess.
@Test
@RunAsClient
public void testMessageAccess() throws Exception {
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
String reqEnv = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + " <env:Header/>" + " <env:Body>" + " <ns1:locateCustomer xmlns:ns1='" + targetNS + "'>" + " <FirstName>Mickey</FirstName>" + " <LastName>Mouse</LastName>" + " <Address>" + " <address>Wall Street</address>" + " </Address>" + " </ns1:locateCustomer>" + " </env:Body>" + "</env:Envelope>";
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
URL epURL = baseURL;
SOAPMessage resMsg = con.call(reqMsg, epURL);
QName qname = new QName(targetNS, "locateCustomerResponse");
SOAPElement soapElement = (SOAPElement) resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement) soapElement.getChildElements(new QName("CustomerRecord")).next();
assertNotNull("Expected CustomerRecord", soapElement);
}
use of javax.xml.soap.SOAPConnection in project jbossws-cxf by jbossws.
the class AbstractClient method performSOAPCall.
protected static void performSOAPCall(String endpointAddress) throws SOAPException, MalformedURLException {
SOAPFactory soapFac = SOAPFactory.newInstance();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
SOAPMessage msg = msgFac.createMessage();
SOAPConnection con = conFac.createConnection();
QName echo = new QName("http://org.jboss.ws/bus", "echo");
SOAPElement element = soapFac.createElement(echo);
element.addTextNode("John");
msg.getSOAPBody().addChildElement(element);
SOAPMessage response = con.call(msg, new URL(endpointAddress));
assert (response != null);
}
use of javax.xml.soap.SOAPConnection 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.SOAPConnection 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());
}
}
}
Aggregations