use of javax.xml.ws.soap.SOAPBinding in project cxf by apache.
the class ClientMtomXopTest method createPort.
private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM, boolean installInterceptors) throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
Bus bus = getStaticBus();
LoggingFeature lf = new LoggingFeature();
lf.setPrettyLogging(false);
lf.setLogBinary(false);
lf.setLogMultipart(true);
bus.getFeatures().add(lf);
serviceFactory.setBus(bus);
serviceFactory.setServiceName(serviceName);
serviceFactory.setServiceClass(serviceEndpointInterface);
serviceFactory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl"));
Service service = serviceFactory.create();
EndpointInfo ei = service.getEndpointInfo(portName);
JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding(), jaxwsEndpoint);
jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
if (installInterceptors) {
// jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
}
jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor());
jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor());
Client client = new ClientImpl(bus, jaxwsEndpoint);
InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
updateAddressPort(obj, PORT);
return serviceEndpointInterface.cast(obj);
}
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 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 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);
}
Aggregations