use of javax.xml.ws.soap.SOAPBinding in project camel by apache.
the class Client method invoke.
public String invoke() throws Exception {
// Service Qname as defined in the WSDL.
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
// Port QName as defined in the WSDL.
QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapOverHttpRouter");
// Create a dynamic Service instance
Service service = Service.create(serviceName);
// Add a port to the Service
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
// Create a dispatch instance
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
// Use Dispatch as BindingProvider
BindingProvider bp = dispatch;
MessageFactory factory = ((SOAPBinding) bp.getBinding()).getMessageFactory();
// Create SOAPMessage Request
SOAPMessage request = factory.createMessage();
// Request Body
SOAPBody body = request.getSOAPBody();
// Compose the soap:Body payload
QName payloadName = new QName("http://apache.org/hello_world_soap_http/types", "greetMe", "ns1");
SOAPBodyElement payload = body.addBodyElement(payloadName);
SOAPElement message = payload.addChildElement("requestType");
message.addTextNode("Hello Camel!!");
System.out.println("Send out the request: Hello Camel!!");
// Invoke the endpoint synchronously
// Invoke endpoint operation and read response
SOAPMessage reply = dispatch.invoke(request);
// process the reply
body = reply.getSOAPBody();
QName responseName = new QName("http://apache.org/hello_world_soap_http/types", "greetMeResponse");
SOAPElement bodyElement = (SOAPElement) body.getChildElements(responseName).next();
String responseMessageText = bodyElement.getTextContent();
System.out.println("Get the response: " + responseMessageText);
return responseMessageText;
}
use of javax.xml.ws.soap.SOAPBinding in project camel by apache.
the class CxfMtomRouterPayloadModeTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
if (MtomTestHelper.isAwtHeadless(logger, null)) {
return;
}
Holder<byte[]> photo = new Holder<byte[]>(MtomTestHelper.REQ_PHOTO_DATA);
Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));
Hello port = getPort();
SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
binding.setMTOMEnabled(true);
port.detail(photo, image);
MtomTestHelper.assertEquals(MtomTestHelper.RESP_PHOTO_DATA, photo.value);
Assert.assertNotNull(image.value);
if (image.value instanceof BufferedImage) {
Assert.assertEquals(560, ((BufferedImage) image.value).getWidth());
Assert.assertEquals(300, ((BufferedImage) image.value).getHeight());
}
}
use of javax.xml.ws.soap.SOAPBinding in project camel by apache.
the class CxfMtomPOJOProducerTest method setUp.
@Before
public void setUp() throws Exception {
endpoint = Endpoint.publish("http://localhost:" + port + "/CxfMtomPOJOProducerTest/jaxws-mtom/hello", getImpl());
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);
}
use of javax.xml.ws.soap.SOAPBinding in project nhin-d by DirectProject.
the class DocumentRepositoryUtils method getDocumentRepositoryPortType.
/**
* Construct a DocumentRepositoryPortType object using the provided
* endpoint.
*
* @param endpoint
* The XDR endpoint.
* @param wsdlPath
* The path to the WSDL.
* @return a DocumentRepositoryPortType object.
* @throws Exception
*/
public static DocumentRepositoryPortType getDocumentRepositoryPortType(String endpoint, URL wsdlPath) throws Exception {
QName qname = new QName("urn:ihe:iti:xds-b:2007", "DocumentRepository_Service");
DocumentRepositoryService service = new DocumentRepositoryService(wsdlPath, qname);
service.setHandlerResolver(new RepositoryHandlerResolver());
DocumentRepositoryPortType port = service.getDocumentRepositoryPortSoap12(new MTOMFeature(true, 1));
BindingProvider bp = (BindingProvider) port;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
return port;
}
use of javax.xml.ws.soap.SOAPBinding in project tomee by apache.
the class AttachmentTest method testAttachmentViaWsInterface.
//END SNIPPET: setup
/**
* Create a webservice client using wsdl url
*
* @throws Exception
*/
//START SNIPPET: webservice
public void testAttachmentViaWsInterface() throws Exception {
Service service = Service.create(new URL("http://localhost:" + port + "/webservice-attachments/AttachmentImpl?wsdl"), new QName("http://superbiz.org/wsdl", "AttachmentWsService"));
assertNotNull(service);
AttachmentWs ws = service.getPort(AttachmentWs.class);
// retrieve the SOAPBinding
SOAPBinding binding = (SOAPBinding) ((BindingProvider) ws).getBinding();
binding.setMTOMEnabled(true);
String request = "tsztelak@gmail.com";
// Byte array
String response = ws.stringFromBytes(request.getBytes());
assertEquals(request, response);
// Data Source
DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");
// not yet supported !
// response = ws.stringFromDataSource(source);
// assertEquals(request, response);
// Data Handler
response = ws.stringFromDataHandler(new DataHandler(source));
assertEquals(request, response);
}
Aggregations