use of javax.xml.ws.soap.SOAPBinding in project eap-additional-testsuite by jboss-set.
the class MtomTestCase method mtomTest.
@Test
public void mtomTest() throws Exception {
URL url = new URL("http://localhost:8080/war-mtom?wsdl");
QName qname = new QName("http://mtom.web.present.jdkall.testsuite.additional.jboss.org/", "ImageServerImplService");
String path = this.getClass().getClassLoader().getResource("").getPath();
FileInputStream inputStream = new FileInputStream(path + "../" + serverLogPath);
try {
String everything = IOUtils.toString(inputStream);
assertFalse("Testing archive has enabled mtom feature", everything.contains("mtomEnabled=true"));
} finally {
inputStream.close();
}
Service service = Service.create(url, qname);
ImageServer imageServer = service.getPort(ImageServer.class);
// enable MTOM in client
BindingProvider bp = (BindingProvider) imageServer;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
Image im = imageServer.downloadImage(path + "rss.png");
if (im == null) {
fail();
}
}
use of javax.xml.ws.soap.SOAPBinding in project csb-sdk by aliyun.
the class Main method testWithProxy.
/**
* Call MTOM/WS with static proxy client
*
* @throws Exception
*/
public void testWithProxy() throws Exception {
// Create the service client endpoint
AttachmentWSService service = new AttachmentWSService(new URL(wsdlAddr));
// Get the proxy port
AttachmentWS port = service.getAttachmentWSPort(new javax.xml.ws.soap.MTOMFeature());
// Set enable MTOM
BindingProvider bp = (BindingProvider) port;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddr);
binding.setMTOMEnabled(true);
// 使用SDK将AK, SK传输的调用client端
port = WSClientSDK.bind(port, ak, sk);
String testString = "this is a mtom String";
String retStr = port.echoBinaryAsString(testString.getBytes());
System.out.println("return Str=" + retStr);
// Assert.assertTrue("Not equal", testString.equals(retStr));
byte[] retBytes = port.echoStringAsBinary(testString);
// Assert.assertTrue("Not equal", testString.equals(new String(retBytes)));
System.out.println("return Str=" + retBytes);
final File f = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "com/alibaba/csb/sdk/ws/mtom/MtomSDKTest.class");
String upFile = "/tmp/a.class";
// file upload
port.fileUpload(upFile, new DataHandler(new FileDataSource(f)));
// file download
upFile = "/tmp/b.class";
DataHandler dh = port.fileDownload(upFile);
OutputStream os = new FileOutputStream(new File(upFile));
dh.writeTo(os);
/**/
}
use of javax.xml.ws.soap.SOAPBinding in project csb-sdk by aliyun.
the class MtomSDKTest method testWithProxy.
@Test
public /**
* Call MTOM/WS with static proxy client
*
* @throws Exception
*/
void testWithProxy() throws Exception {
// Create the service client endpoint
AttachmentWSService service = new AttachmentWSService(new URL(wsdlAddr));
// Get the proxy port
AttachmentWS port = service.getAttachmentWSPort(new javax.xml.ws.soap.MTOMFeature());
// Set enable MTOM
BindingProvider bp = (BindingProvider) port;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddr);
binding.setMTOMEnabled(true);
// 使用SDK将AK, SK传输的调用client端
port = WSClientSDK.bind(port, ak, sk, "ci-ws2ws-mtom-import", "1.0.0");
int times = Integer.getInteger("times", 1);
for (int i = 0; i < times; i++) {
System.out.println("----- Execute the test with #" + i + " time");
String testString = "this is a mtom String";
String retStr = port.echoBinaryAsString(testString.getBytes());
System.out.println("return Str=" + retStr);
Assert.assertTrue("Not equal", testString.equals(retStr));
byte[] retBytes = port.echoStringAsBinary(testString);
Assert.assertTrue("Not equal", testString.equals(new String(retBytes)));
System.out.println("return Str=" + retBytes);
final File f = new File(MtomSDKTest.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "com/alibaba/csb/sdk/ws/mtom/MtomSDKTest.class");
String upFile = "/tmp/new.class";
// file upload
port.fileUpload(upFile, new DataHandler(new FileDataSource(f)));
// file download
DataHandler dh = port.fileDownload(upFile);
OutputStream os = new FileOutputStream(new File(upFile));
dh.writeTo(os);
/**/
}
}
use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.
the class JBWS3250TestCase method testMtomSawpFile.
@Test
@RunAsClient
public void testMtomSawpFile() throws Exception {
URL wsdlURL = new URL(baseURL + "?wsdl");
QName serviceName = new QName("http://ws.jboss.org/jbws3250", "TestEndpointService");
Endpoint port = Service.create(wsdlURL, serviceName).getPort(Endpoint.class);
SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
binding.setMTOMEnabled(true);
URL url = JBossWSTestHelper.getResourceURL("jaxws/jbws3250/wsf.png");
URLDataSource urlDatasource = new URLDataSource(url);
javax.activation.DataHandler dh = new DataHandler(urlDatasource);
MTOMRequest request = new MTOMRequest();
request.setContent(dh);
request.setId("largeSize_mtom_request");
MTOMResponse mtomResponse = port.echo(request);
Assert.assertEquals("Response for requestID:largeSize_mtom_request", mtomResponse.getResponse());
byte[] responseBytes = IOUtils.convertToBytes(mtomResponse.getContent());
Assert.assertTrue(responseBytes.length > 65536);
}
use of javax.xml.ws.soap.SOAPBinding in project jbossws-cxf by jbossws.
the class BusHolder method configure.
/**
* Update the Bus held by the this instance using the provided parameters.
* This basically prepares the bus for being used with JBossWS.
*
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if any
* @param wsmd The current JBossWebservicesMetaData, if any
* @param dep The current deployment
*/
public void configure(ResourceResolver resolver, Configurer configurer, JBossWebservicesMetaData wsmd, Deployment dep) {
if (configured) {
throw Messages.MESSAGES.busAlreadyConfigured(bus);
}
bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
busHolderListener = new BusHolderLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(busHolderListener);
setWSDLManagerStreamWrapper(bus);
if (configurer != null) {
bus.setExtension(configurer, Configurer.class);
}
Map<String, String> props = getProperties(wsmd);
setInterceptors(bus, dep, props);
dep.addAttachment(Bus.class, bus);
try {
final JASPIAuthenticationProvider jaspiProvider = SPIProvider.getInstance().getSPI(JASPIAuthenticationProvider.class, ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
if (jaspiProvider != null && jaspiProvider.enableServerAuthentication(dep, wsmd)) {
bus.getInInterceptors().add(new AuthenticationMgrSubjectCreatingInterceptor());
}
} catch (WSFException e) {
Loggers.DEPLOYMENT_LOGGER.cannotFindJaspiClasses();
}
setResourceResolver(bus, resolver);
if (bus.getExtension(PolicyEngine.class) != null) {
bus.getExtension(PolicyEngine.class).setAlternativeSelector(getAlternativeSelector(props));
}
// *first* enabled cxf management if required, *then* add anything else which could be manageable (e.g. work queues)
setCXFManagement(bus, props);
setAdditionalWorkQueues(bus, props);
setWSDiscovery(bus, props);
AnnotationsInfo ai = dep.getAttachment(AnnotationsInfo.class);
if (ai == null || ai.hasAnnotatedClasses(PolicySets.class.getName())) {
policySetsListener = new PolicySetsAnnotationListener(dep.getClassLoader());
bus.getExtension(FactoryBeanListenerManager.class).addListener(policySetsListener);
}
// default to USE_ORIGINAL_THREAD = true; this can be overridden by simply setting the property in the endpoint or in the message using an interceptor
// this forces one way operation to use original thread, which is required for ejb webserivce endpoints to avoid authorization failures from ejb container
// and is a performance improvement in general when running in-container, as CXF needs to cache the message to free the thread, which is expensive
// (moreover the user can tune the web container thread pool instead of expecting cxf to fork new threads)
bus.setProperty(OneWayProcessorInterceptor.USE_ORIGINAL_THREAD, true);
// [JBWS-3135] enable decoupled faultTo. This is an optional feature in cxf and we need this to be default to make it same behavior with native stack
bus.setProperty("org.apache.cxf.ws.addressing.decoupled_fault_support", true);
FeatureUtils.addFeatures(bus, bus, props);
for (DDEndpoint dde : metadata.getEndpoints()) {
EndpointImpl endpoint = new EndpointImpl(bus, newInstance(dde.getImplementor()));
if (dde.getInvoker() != null)
endpoint.setInvoker(newInvokerInstance(dde.getInvoker(), dep));
endpoint.setAddress(dde.getAddress());
endpoint.setEndpointName(dde.getPortName());
endpoint.setServiceName(dde.getServiceName());
endpoint.setWsdlLocation(dde.getWsdlLocation());
setHandlers(endpoint, dde);
if (dde.getProperties() != null) {
Map<String, Object> p = new HashMap<String, Object>();
p.putAll(dde.getProperties());
endpoint.setProperties(p);
}
if (dde.isAddressingEnabled()) {
WSAddressingFeature addressingFeature = new WSAddressingFeature();
addressingFeature.setAddressingRequired(dde.isAddressingRequired());
addressingFeature.setResponses(dde.getAddressingResponses());
endpoint.getFeatures().add(addressingFeature);
}
endpoint.setPublishedEndpointUrl(dde.getPublishedEndpointUrl());
endpoint.setSOAPAddressRewriteMetadata(dep.getAttachment(SOAPAddressRewriteMetadata.class));
endpoint.publish();
endpoints.add(endpoint);
if (dde.isMtomEnabled()) {
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);
}
}
configured = true;
}
Aggregations