Java 8 Dispatch - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Dispatch class.

This code example shows how to use the following methods:getBinding, invoke
                                                                Service.Mode.MESSAGE);
 
        // Use Dispatch as BindingProvider 
        BindingProvider bp = dispatch;
 
        MessageFactory factory = ((SOAPBinding)bp.getBinding()).getMessageFactory();
 
        // Create SOAPMessage Request 
        SOAPMessage request = factory.createMessage();
 
        // Request Body 
        SOAPBody body = request.getSOAPBody();
 
        // Compose the soap:Body payload 
        QName payloadName = new QName("http://apache.org/hello_world_soap_http/types", "greetMe", "ns1");
 
        SOAPBodyElement payload = body.addBodyElement(payloadName);
 
        SOAPElement message = payload.addChildElement("requestType");
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRequestContext, getResponseContext, invoke
 
    public void testDataSourceWithTXTPlusAttachment() throws Exception {
        Dispatch<DataSource> dispatch = getDispatch();
 
        Map attachments = new HashMap();
        Map requestContext = dispatch.getRequestContext();
 
//        requestContext.put(org.apache.axis2.transport.http.HTTPConstants.SO_TIMEOUT , new  
//        Integer(999999)); 
//        requestContext.put(org.apache.axis2.transport.http.HTTPConstants.CONNECTION_TIMEOUT, new  
//        Integer(999999)); 
 
        requestContext.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS,
                attachments);
        attachments.put(UIDGenerator.generateContentId(), new DataHandler(attachmentDS));
 
        DataSource request = txtDS;
        DataSource response = dispatch.invoke(request);
        assertTrue(response != null);
        assertEquals(response.getContentType(),"text/plain");

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRequestContext, invoke
 
        Service service = Service.create(serviceName);
        service.addPort(portName, HTTPBinding.HTTP_BINDING,  endpointAddress);
        Dispatch<DOMSource> dispatcher = service.createDispatch(portName,
                                                                DOMSource.class, Service.Mode.PAYLOAD);
        Map<String, Object> requestContext = dispatcher.getRequestContext();
 
        Client client = new Client();
        InputStream is = client.getClass().getResourceAsStream("/CustomerJohnReq.xml");
        Document doc = StaxUtils.read(is);
        DOMSource reqMsg = new DOMSource(doc);
 
        requestContext.put(MessageContext.HTTP_REQUEST_METHOD, "POST");
        System.out.println("Invoking through HTTP POST to update customer using JAX-WS Dispatch");
        DOMSource result = dispatcher.invoke(reqMsg);
        printSource(result);
 
        System.out.println("Client Invoking succeeded!");
        System.exit(0);
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invoke
        DOMSource reqMsg = new DOMSource(doc);
        assertNotNull(reqMsg);
 
        Dispatch<DOMSource> disp = service.createDispatch(portName,
                DOMSource.class, Service.Mode.PAYLOAD);
        setAddress(disp, ADDRESS);
        DOMSource result = disp.invoke(reqMsg);
        assertNotNull(result);
 
        Node respDoc = result.getNode();
        assertEquals("greetMeResponse", respDoc.getFirstChild().getLocalName());
        assertEquals("TestXMLBindingProviderMessage", respDoc.getFirstChild()
                .getTextContent());
         
        is = getClass().getResourceAsStream(
            "/messages/XML_GreetMeDocLiteralReq_invalid.xml"); 
        doc = StaxUtils.read(is);
        reqMsg = new DOMSource(doc);
        assertNotNull(reqMsg);
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRequestContext, invoke
        DOMSource reqMsg = new DOMSource(doc);
        assertNotNull(reqMsg);
 
        Dispatch<DOMSource> disp = service.createDispatch(PORT_NAME, DOMSource.class,
                                                          Service.Mode.PAYLOAD);
        disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                     "http://localhost:" 
                                     + port
                                     + "/XMLService/XMLDispatchPort"); 
        DOMSource result = disp.invoke(reqMsg);
        assertNotNull(result);
               
        Node respDoc = result.getNode();
        assertEquals("greetMeResponse", respDoc.getFirstChild().getLocalName());
        assertEquals("Hello tli", respDoc.getFirstChild().getTextContent());
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invoke
        URL requestFile = 
            SignatureWhitespaceTest.class.getResource("request-with-trailing-whitespace.xml");
         
        StreamSource request = new StreamSource(new File(requestFile.getPath()));
 
        updateAddressPort(dispatch, PORT);
         
        // Make a successful request 
        StreamSource response = dispatch.invoke(request);
        assertNotNull(response);
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invoke
    @Test
    public void testDispatchClient() throws Exception {
        SOAPServiceRPCLit service = new SOAPServiceRPCLit();
        Dispatch<Source> disp = service.createDispatch(portName, Source.class, 
                                                       javax.xml.ws.Service.Mode.PAYLOAD);
        updateAddressPort(disp, PORT);
 
        String req = "<ns1:sendReceiveData xmlns:ns1=\"http://apache.org/hello_world_rpclit\">"
            + "<in xmlns:ns2=\"http://apache.org/hello_world_rpclit/types\">" 
            + "<ns2:elem1>elem1</ns2:elem1><ns2:elem2>elem2</ns2:elem2><ns2:elem3>45</ns2:elem3>" 
            + "</in></ns1:sendReceiveData>"; 
        Source source = new StreamSource(new StringReader(req));
        Source resp = disp.invoke(source);
        assertNotNull(resp);
         
        Node nd = StaxUtils.read(resp);
        if (nd instanceof Document) {
            nd = ((Document)nd).getDocumentElement();
        } 
        XPathUtils xpu = new XPathUtils(new W3CNamespaceContext((Element)nd));
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBinding, getRequestContext, invoke
        JAXBContext jbc = JAXBContext
                .newInstance("org.apache.axis2.jaxws.samples.mtom");
        Dispatch<Object> dispatch = svc.createDispatch(portNameDispatch, jbc,
                Service.Mode.PAYLOAD);
        BindingProvider bp = (BindingProvider) dispatch;
        bp.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,
                Boolean.TRUE);
        bp.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
                "sendImage"); 
 
        // Set the actual flag to enable MTOM 
        SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
        binding.setMTOMEnabled(true);
 
        // Create the request wrapper bean 
        ObjectFactory factory = new ObjectFactory();
        SendImage request = factory.createSendImage();
        request.setInput(imageDepot);
 
        if (null != result) {

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, invoke
        Service jaxwsService = Service.create(new URL(serviceUrl), serviceName);
	    Dispatch<SOAPMessage> disp = jaxwsService.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
	    FileInputStream fis = new FileInputStream(new File(System.getProperty("user.dir") + "/src/test/resources/galaxyDemoTestMessage.xml"));
	    SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null, fis);
	    assertNotNull(reqMsg);
		SOAPMessage response = disp.invoke(reqMsg);
		logger.debug("Response : " + response.getSOAPBody().getTextContent().trim());
		logger.debug("Demo request sent !"); 
		// Wait for the proxy finish to register services 
		Thread.sleep(10000);
	}	 
	 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getRequestContext, invoke
        String endpointUrl = "Invalid_EPR jms:/queue?destination=jms/SwapQueue&connectionFactory=jms/SwapQCF&targetService=SwapJMSBean&initialContextFactory=com.ibm.websphere.naming.WsnInitialContextFactory&jndiProviderURL=corbaloc:iiop:sat.hursley.ibm.com:9810,iiop:sat.hursley.ibm.com:9811";
        Dispatch<String> dispatch = getDispatch(endpointUrl);
         
        String request = "<invoke>hello world</invoke>";
        try { 
            String response = dispatch.invoke(request);
            fail("Should have caught exception for invalid EPR " + endpointUrl);
        } catch (WebServiceException ex) {
            assertTrue(ex.toString().contains(CANNOT_INFER_EXCEPTION));
        } 
    } 
    private Dispatch<String> getDispatch(String endpointUrl) {
        Service svc = Service.create(serviceName);
        svc.addPort(portName, null, endpointUrl);
         
        Dispatch<String> dispatch = svc
                .createDispatch(portName, String.class, Service.Mode.PAYLOAD);
         
        // Force soap action because we are passing junk over the wire 
        dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 Dispatch Methods: