use of javax.xml.soap.SOAPConnection in project jbossws-cxf by jbossws.
the class WebMethodTestCase method testLegalMessageAccess.
@Test
@RunAsClient
public void testLegalMessageAccess() 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:echoString xmlns:ns1='" + targetNS + "'>" + " <arg0>Hello</arg0>" + " </ns1:echoString>" + " </env:Body>" + "</env:Envelope>";
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
URL epURL = new URL(baseURL + "/TestService");
SOAPMessage resMsg = con.call(reqMsg, epURL);
QName qname = new QName(targetNS, "echoStringResponse");
SOAPElement soapElement = (SOAPElement) resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement) soapElement.getChildElements(new QName("return")).next();
assertEquals("Hello", soapElement.getValue());
}
use of javax.xml.soap.SOAPConnection in project jbossws-cxf by jbossws.
the class WebMethodTestCase method testIllegalMessageAccess.
@Test
@RunAsClient
public void testIllegalMessageAccess() 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:noWebMethod xmlns:ns1='" + targetNS + "'>" + " <String_1>Hello</String_1>" + " </ns1:noWebMethod>" + " </env:Body>" + "</env:Envelope>";
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
URL epURL = new URL(baseURL + "/TestService");
SOAPMessage resMsg = con.call(reqMsg, epURL);
SOAPFault soapFault = resMsg.getSOAPBody().getFault();
assertNotNull("Expected SOAPFault", soapFault);
String faultString = soapFault.getFaultString();
assertTrue(faultString, faultString.indexOf("noWebMethod") > 0);
}
use of javax.xml.soap.SOAPConnection in project jbossws-cxf by jbossws.
the class SOAPBindingTestCase method testNamespacedDocWrappedServiceMessageAccess.
@Test
@RunAsClient
public void testNamespacedDocWrappedServiceMessageAccess() throws Exception {
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
String purchaseNamespace = "http://namespace/purchase";
String resultNamespace = "http://namespace/result";
String stringNamespace = "http://namespace/string";
String reqEnv = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + " <env:Header/>" + " <env:Body>" + " <ns1:SubmitNamespacedPO xmlns:ns1='" + targetNS + "'>" + " <ns2:NamespacedPurchaseOrder xmlns:ns2='" + purchaseNamespace + "'>Ferrari</ns2:NamespacedPurchaseOrder>" + " <ns3:NamespacedString xmlns:ns3='" + stringNamespace + "'>message</ns3:NamespacedString>" + " </ns1:SubmitNamespacedPO>" + " </env:Body>" + "</env:Envelope>";
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
URL epURL = new URL(baseURL + "/DocWrappedService");
SOAPMessage resMsg = con.call(reqMsg, epURL);
QName qname = new QName(targetNS, "SubmitNamespacedPOResponse");
SOAPElement soapElement = (SOAPElement) resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement) soapElement.getChildElements(new QName(resultNamespace, "NamespacedPurchaseOrderAck")).next();
assertEquals("Ferrari", soapElement.getValue());
}
use of javax.xml.soap.SOAPConnection in project jbossws-cxf by jbossws.
the class JBWS3084TestCase method doTestSoapConnection.
private void doTestSoapConnection(boolean disableChunking) throws Exception {
SOAPFactory soapFac = SOAPFactory.newInstance();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
SOAPMessage msg = msgFac.createMessage();
if (disableChunking) {
// this is the custom header checked by ServiceImpl
msg.getMimeHeaders().addHeader("Transfer-Encoding-Disabled", "true");
// this is a hint to SOAPConnection that the chunked encoding is not needed
msg.getMimeHeaders().addHeader("Transfer-Encoding", "disabled");
}
QName sayHi = new QName("http://www.jboss.org/jbossws/saaj", "sayHello");
msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
AttachmentPart ap1 = msg.createAttachmentPart();
char[] content = new char[16 * 1024];
Arrays.fill(content, 'A');
ap1.setContent(new String(content), "text/plain");
msg.addAttachmentPart(ap1);
AttachmentPart ap2 = msg.createAttachmentPart();
ap2.setContent("Attachment content - Part 2", "text/plain");
msg.addAttachmentPart(ap2);
msg.saveChanges();
SOAPConnection con = conFac.createConnection();
final String serviceURL = baseURL.toString();
URL endpoint = new URL(serviceURL);
SOAPMessage response = con.call(msg, endpoint);
QName sayHiResp = new QName("http://www.jboss.org/jbossws/saaj", "sayHelloResponse");
Iterator<?> sayHiRespIterator = response.getSOAPBody().getChildElements(sayHiResp);
SOAPElement soapElement = (SOAPElement) sayHiRespIterator.next();
assertNotNull(soapElement);
assertEquals(2, response.countAttachments());
String[] values = response.getMimeHeaders().getHeader("Transfer-Encoding-Disabled");
if (disableChunking) {
// this means that the ServiceImpl executed the code branch verifying
// that chunking was disabled
assertNotNull(values);
assertTrue(values.length == 1);
} else {
assertNull(values);
}
}
use of javax.xml.soap.SOAPConnection in project cxf by apache.
the class ProviderRPCClientServerTest method testSWA.
@Test
public void testSWA() throws Exception {
SOAPFactory soapFac = SOAPFactory.newInstance();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
SOAPMessage msg = msgFac.createMessage();
QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach");
msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
AttachmentPart ap1 = msg.createAttachmentPart();
ap1.setContent("Attachment content", "text/plain");
msg.addAttachmentPart(ap1);
AttachmentPart ap2 = msg.createAttachmentPart();
ap2.setContent("Attachment content - Part 2", "text/plain");
msg.addAttachmentPart(ap2);
msg.saveChanges();
SOAPConnection con = conFac.createConnection();
URL endpoint = new URL("http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1");
SOAPMessage response = con.call(msg, endpoint);
QName sayHiResp = new QName("http://apache.org/hello_world_rpclit", "sayHiResponse");
assertNotNull(response.getSOAPBody().getChildElements(sayHiResp));
assertEquals(2, response.countAttachments());
}
Aggregations