use of javax.xml.ws.Binding in project cxf by apache.
the class JMSTestMtom method testMTOM.
@Test
public void testMTOM() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");
URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
JMSMTOMService service = new JMSMTOMService(wsdl, serviceName);
JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
Binding binding = ((BindingProvider) mtom).getBinding();
((SOAPBinding) binding).setMTOMEnabled(true);
Holder<String> name = new Holder<>("Sam");
URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
Holder<DataHandler> handler1 = new Holder<>();
handler1.value = new DataHandler(fileURL);
int size = handler1.value.getInputStream().available();
mtom.testDataHandler(name, handler1);
byte[] bytes = IOUtils.readBytesFromStream(handler1.value.getInputStream());
Assert.assertEquals("The response file is not same with the sent file.", size, bytes.length);
((Closeable) mtom).close();
}
use of javax.xml.ws.Binding in project Payara by payara.
the class PortCreationCallbackImpl method postCreateProxy.
public void postCreateProxy(WSBindingProvider bp, Class<?> serviceEndpointInterface) {
ServiceRefPortInfo portInfo = ref.getPortInfoBySEI(serviceEndpointInterface.getName());
if (portInfo != null) {
// Set MTOM for this port
boolean mtomEnabled = false;
if (portInfo.getMtomEnabled() != null && Boolean.valueOf(portInfo.getMtomEnabled())) {
mtomEnabled = true;
}
if (mtomEnabled) {
Binding bType = bp.getBinding();
// enable mtom valid only for SOAPBindings
if (SOAPBinding.class.isAssignableFrom(bType.getClass())) {
((SOAPBinding) bType).setMTOMEnabled(true);
} else {
logger.log(Level.SEVERE, LogUtils.INVALID_MTOM, portInfo.getName());
}
}
// Set stub properties
Set properties = portInfo.getStubProperties();
for (Iterator iter = properties.iterator(); iter.hasNext(); ) {
NameValuePairDescriptor next = (NameValuePairDescriptor) iter.next();
bp.getRequestContext().put(next.getName(), next.getValue());
}
}
}
use of javax.xml.ws.Binding in project uavstack by uavorg.
the class JaxWSHookIT method createDispatch.
@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {
Binding binding = ((BindingProvider) d).getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(this.handler);
binding.setHandlerChain(handlerChain);
final String wsdlLocation = getServiceURL(s);
Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Dispatch.class }, new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
return tProxy;
}
use of javax.xml.ws.Binding in project nimbus by nimbus-org.
the class WsPortFactoryService method getPort.
public Object getPort(String portAlias) throws PortException {
String portNameClassName = portAliasProp.getProperty(portAlias);
String[] names = portNameClassName.split(SEPARATOR);
if (names.length < 2) {
return new PortException("port name or endpoint interface name is illegal : " + portNameClassName);
}
try {
Class endpointInterface = Class.forName(names[ENDPOINT_INTERFACE_NAME]);
QName portQN = new QName(nameSpace, names[PORT_NAME]);
Object port = wsService.getPort(portQN, endpointInterface);
if ((handlerList != null && handlerList.size() > 0) && (port instanceof BindingProvider)) {
BindingProvider bindingProvider = ((BindingProvider) port);
bindingProvider.getRequestContext().putAll(requestContext);
Binding binding = bindingProvider.getBinding();
List list = binding.getHandlerChain();
for (int i = 0; i < handlerList.size(); i++) {
Handler handler = (Handler) handlerList.get(i);
list.add(handler);
}
binding.setHandlerChain(list);
}
return endpointInterface.cast(port);
} catch (Exception e) {
throw new PortException(e);
}
}
Aggregations