Search in sources :

Example 1 with MTOMFeature

use of javax.xml.ws.soap.MTOMFeature in project quickstarts by jboss-switchyard.

the class SoapMtomClient method sendMessage.

public static Image sendMessage(String wsdl) throws Exception {
    ImageService imageService = new ImageServiceService(new URL(wsdl)).getImageServicePort(new MTOMFeature());
    // Create the Image bytes and send it to the MTOM endpoint...
    URL fileURL = Classes.getResource("switchyard_icon.jpeg");
    File aFile = new File(new URI(fileURL.toString()));
    long fileSize = aFile.length();
    Holder<byte[]> param = new Holder<byte[]>();
    param.value = new byte[(int) fileSize];
    InputStream in = fileURL.openStream();
    int len = in.read(param.value);
    while (len < fileSize) {
        len += in.read(param.value, len, (int) (fileSize - len));
    }
    byte[] response = imageService.resizeImage(param);
    return ImageIO.read(new ByteArrayInputStream(response));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MTOMFeature(javax.xml.ws.soap.MTOMFeature) Holder(javax.xml.ws.Holder) URI(java.net.URI) URL(java.net.URL) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File)

Example 2 with MTOMFeature

use of javax.xml.ws.soap.MTOMFeature in project nhin-d by DirectProject.

the class DocumentRepositoryProxy method initProxy.

private void initProxy() {
    try {
        URL url = DocumentRepositoryProxy.class.getClassLoader().getResource("XDS.b_DocumentRepositoryWSDLSynchMTOM.wsdl");
        QName qname = new QName("urn:ihe:iti:xds-b:2007", "DocumentRepository_Service");
        DocumentRepositoryService service = new DocumentRepositoryService(url, qname);
        if (handlerResolver != null)
            service.setHandlerResolver(handlerResolver);
        proxy = service.getDocumentRepositoryPortSoap12(new MTOMFeature(true, 1));
        BindingProvider bp = (BindingProvider) proxy;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
    } catch (Exception e) {
        LOGGER.error("Error initializing proxy.", e);
    }
}
Also used : QName(javax.xml.namespace.QName) MTOMFeature(javax.xml.ws.soap.MTOMFeature) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DocumentRepositoryService(ihe.iti.xds_b._2007.DocumentRepositoryService) URL(java.net.URL) OperationNotSupportedException(javax.naming.OperationNotSupportedException)

Example 3 with MTOMFeature

use of javax.xml.ws.soap.MTOMFeature 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;
}
Also used : DocumentRepositoryPortType(ihe.iti.xds_b._2007.DocumentRepositoryPortType) QName(javax.xml.namespace.QName) MTOMFeature(javax.xml.ws.soap.MTOMFeature) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DocumentRepositoryService(ihe.iti.xds_b._2007.DocumentRepositoryService)

Aggregations

MTOMFeature (javax.xml.ws.soap.MTOMFeature)3 DocumentRepositoryService (ihe.iti.xds_b._2007.DocumentRepositoryService)2 URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 BindingProvider (javax.xml.ws.BindingProvider)2 SOAPBinding (javax.xml.ws.soap.SOAPBinding)2 DocumentRepositoryPortType (ihe.iti.xds_b._2007.DocumentRepositoryPortType)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1 Holder (javax.xml.ws.Holder)1