Search in sources :

Example 1 with MultipartsService

use of common.attachment.MultipartsService in project tesb-rt-se by Talend.

the class RESTClient method useAttachmentServiceWithProxy.

/**
 * Writes and reads the multipart/mixed attachments using a CXF JAX-RS Proxy
 * Note that a custom JAXB-driven JSONProvider is registered to simpify dealing
 * with one of the parts in the JSON format: it is configured to drop namespace
 * prefixes on the write and add a namespace to the incoming payload so that it
 * can be read into the namespace-qualified JAXB Book bean.
 *
 * @throws Exception
 */
public void useAttachmentServiceWithProxy() throws Exception {
    final String serviceURI = "http://localhost:" + port + "/services/attachments";
    JSONProvider provider = new JSONProvider();
    provider.setIgnoreNamespaces(true);
    provider.setInTransformElements(Collections.singletonMap("Book", "{http://books}Book"));
    MultipartsService client = JAXRSClientFactory.create(serviceURI, MultipartsService.class, Collections.singletonList(provider));
    MultipartBody body = createMultipartBody();
    System.out.println();
    System.out.println("Posting Book attachments with a proxy");
    MultipartBody bodyResponse = client.echoAttachment(body);
    verifyMultipartResponse(bodyResponse);
}
Also used : MultipartsService(common.attachment.MultipartsService) MultipartBody(org.apache.cxf.jaxrs.ext.multipart.MultipartBody) JSONProvider(org.apache.cxf.jaxrs.provider.json.JSONProvider)

Aggregations

MultipartsService (common.attachment.MultipartsService)1 MultipartBody (org.apache.cxf.jaxrs.ext.multipart.MultipartBody)1 JSONProvider (org.apache.cxf.jaxrs.provider.json.JSONProvider)1