Search in sources :

Example 51 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryJaxwsWebServiceIT method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
    String address = "http://localhost:9000/repo";
    try {
        Endpoint.publish(address, new DefaultUnifiedRepositoryJaxwsWebService(repo));
    } catch (Throwable th) {
    // ignore
    }
    Service service = Service.create(new URL("http://localhost:9000/repo?wsdl"), new QName("http://www.pentaho.org/ws/1.0", "unifiedRepository"));
    IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort(IUnifiedRepositoryJaxwsWebService.class);
    // accept cookies to maintain session on server
    ((BindingProvider) repoWebService).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    // support streaming binary data
    ((BindingProvider) repoWebService).getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) repoWebService).getBinding();
    binding.setMTOMEnabled(true);
    repo = new UnifiedRepositoryToWebServiceAdapter(repoWebService);
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Matchers.anyString(org.mockito.Matchers.anyString) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) URL(java.net.URL) Before(org.junit.Before)

Example 52 with SOAPBinding

use of javax.xml.ws.soap.SOAPBinding in project Java-Tutorial by gpcodervn.

the class DocumentClientUpload method main.

public static void main(String[] args) throws Exception {
    // Create URL of .wsdl file
    URL url = new URL(DocumentPublisher.WS_URL + "?wsdl");
    // Create a QName using targetNamespace and name
    QName qname = new QName("http://document.ws.gpcoder.com/", "DocumentServiceImplService");
    // Creates a Service instance with the specified WSDL document location and
    // service qualified name
    Service service = Service.create(url, qname);
    // We need to pass interface and model beans to client
    DocumentService imageServer = service.getPort(DocumentService.class);
    // Enable MTOM in client
    BindingProvider bp = (BindingProvider) imageServer;
    SOAPBinding binding = (SOAPBinding) bp.getBinding();
    binding.setMTOMEnabled(true);
    // Prepare document for upload
    DataHandler dataHandler = DocumentUtils.getFileAsDataHandler("data/test.docx");
    // Perform upload document
    String status = imageServer.upload(dataHandler);
    System.out.println("upload() : " + status);
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) SOAPBinding(javax.xml.ws.soap.SOAPBinding) BindingProvider(javax.xml.ws.BindingProvider) DataHandler(javax.activation.DataHandler) URL(java.net.URL)

Aggregations

SOAPBinding (javax.xml.ws.soap.SOAPBinding)52 URL (java.net.URL)20 BindingProvider (javax.xml.ws.BindingProvider)20 Test (org.junit.Test)20 QName (javax.xml.namespace.QName)19 Service (javax.xml.ws.Service)15 DataHandler (javax.activation.DataHandler)14 WebServiceException (javax.xml.ws.WebServiceException)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 JBossWSTest (org.jboss.wsf.test.JBossWSTest)7 ArrayList (java.util.ArrayList)6 Holder (javax.xml.ws.Holder)6 Image (java.awt.Image)5 IOException (java.io.IOException)5 Binding (javax.xml.ws.Binding)5 File (java.io.File)4 Before (org.junit.Before)4 FileDataSource (javax.activation.FileDataSource)3 Handler (javax.xml.ws.handler.Handler)3 MTOMFeature (javax.xml.ws.soap.MTOMFeature)3