Package org.apache.axis.client

Examples of org.apache.axis.client.Call


        PropertyHandler clientHandler = new PropertyHandler();
        SOAPService clientService = new SOAPService(clientHandler, null, null);
        config.deployService("service", clientService);

        Service s = new Service(config);
        Call call = new Call(s);

        // Set a property on the Call which we expect to be available via
        // the MessageContext in the client-side handler.
        call.setScopedProperty(PROP_NAME, CLIENT_VALUE);

        LocalTransport transport = new LocalTransport(server);
        transport.setRemoteService("service");
        call.setTransport(transport);

        // Make the call.
        String result = (String)call.invoke("service",
                                            "testScopedProperty",
                                            new Object [] { });

        assertEquals("Returned scoped property wasn't correct",
                     SERVER_VALUE,
View Full Code Here


        IF1[] beans = null;

        if (category == null)
            throw new Exception("invalid category");

            Call call = getCall();
            call.setTargetEndpointAddress(m_url);
            call.setOperationName(new QName(m_service, "getBeansByCategory"));
            call.setReturnType(m_beanArrayQName);
            call.addParameter("category", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN);
            if (filter == null)
                beans = (IF1[]) call.invoke(new Object[] { category });
            else
            {
                call.addParameter("filter", m_stringArrayQName, ParameterMode.IN);
                beans = (IF1[]) call.invoke(new Object[] { category, filter });
            }

        return beans;
    }
View Full Code Here

     * return the value it sees, which should match.
     */
    public void testMessageContextOverride() throws Exception {
        // Only the server side matters on this one, so don't bother with
        // special client config.
        Call call = new Call(new Service());

        LocalTransport transport = new LocalTransport(server);
        transport.setRemoteService("service");
        call.setTransport(transport);

        // Make the call.
        String result = (String)call.invoke("service",
                                            "testOverrideProperty",
                                            new Object [] { });
        assertEquals("Overriden property value didn't match",
                     OVERRIDE_VALUE,
                     result);
View Full Code Here

     * handler should see the Call value.  Then set the same property to a
     * different value in the client-side service object, and confirm that
     * when we invoke again we see the new value.
     */
    public void testFullClientScopes() throws Exception {
        Call call = new Call(new Service());
        PropertyHandler clientHandler = new PropertyHandler();
        SOAPService clientService = new SOAPService(clientHandler, null, null);

        call.setSOAPService(clientService);

        // Set a property on the Call which we expect to be available via
        // the MessageContext in the client-side handler.
        call.setScopedProperty(PROP_NAME, CLIENT_VALUE);

        LocalTransport transport = new LocalTransport(server);
        transport.setRemoteService("service");
        call.setTransport(transport);

        // First call should get the value from the Call object.
        call.invoke("testOverrideProperty", new Object [] { });
        assertEquals("Client-side scoped property from Call wasn't correct",
                     CLIENT_VALUE,
                     clientHandler.getPropVal());

        // Now set the same option on the client service, which should
        // take precedence over the value in the Call.
        clientService.setOption(PROP_NAME, OVERRIDE_VALUE);

        // Second call should now get the value from the client service.
        call.invoke("testOverrideProperty", new Object [] { });
        assertEquals("Client-side scoped property from service wasn't correct",
                     OVERRIDE_VALUE,
                     clientHandler.getPropVal());
    }
View Full Code Here

        throws SOAPException {
        if(closed){
            throw new SOAPException(org.apache.axis.utils.JavaUtils.getMessage("connectionClosed00"));
        }
        try {
            Call call = new Call(endpoint.toString());
            ((org.apache.axis.Message)request).setMessageContext(call.getMessageContext());
            SOAPEnvelope env = ((org.apache.axis.Message)request).getSOAPEnvelope();
            call.invoke(env);
            return call.getResponseMessage();
        } catch (java.net.MalformedURLException mue){
            throw new SOAPException(mue);
        } catch (org.apache.axis.AxisFault af){
            throw new SOAPException(af);
        } catch (java.rmi.RemoteException re){
View Full Code Here

    public String doit(String[] args) throws Exception {
        Options opts = new Options(args);
        opts.setDefaultURL("http://localhost:8080/axis/services/MessageService");

        Service  service = new Service();
        Call     call    = (Call) service.createCall();

        call.setTargetEndpointAddress( new URL(opts.getURL()) );
        SOAPBodyElement[] input = new SOAPBodyElement[2];

        input[0] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
                                                                "e1", "Hello"));
        input[1] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
                                                                "e1", "World"));

        Vector          elems = (Vector) call.invoke( input );
        SOAPBodyElement elem  = null ;
        Element         e     = null ;

        elem = (SOAPBodyElement) elems.get(0);
        e    = elem.getAsDOM();
View Full Code Here

     * is the length of the string (doubled if the doubled arg is true).
     */
    public boolean runTest(SOAPHeaderElement header,
                           boolean doubled) throws Exception
    {
        Call call = new Call(new Service());
        call.setTransport(localTransport);
       
        call.addHeader(header);
       
        String str = "a";
        int maxChars = new Random().nextInt(50);
        for (int i = 0; i < maxChars; i++) {
            str += "a";
        }

        Integer i = (Integer)call.invoke("countChars", new Object [] { str });
       
        int desiredResult = str.length();
        if (doubled) desiredResult = desiredResult * 2;
       
        return (i.intValue() == desiredResult);
View Full Code Here

    public static void main(String[] args) {
        if (args.length != 1)
            System.out.println(getVersion());
        else
            try {
                Call call = new Call(args[0]);
                String result = (String)call.invoke("Version", "getVersion",
                                                    null);
                System.out.println(result);
            } catch (Exception e) {
                e.printStackTrace();
            }
View Full Code Here

        Options opts = new Options(args);
        opts.setDefaultURL(address);

        Service service = new Service();
        Call call = (Call) service.createCall();
        call.setTargetEndpointAddress(opts.getURL());

        SOAPEnvelope env = new SOAPEnvelope();
        Document doc = env.getAsDocument();
        WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();

        // Create a new request object passing an XML document for element creation and the RequestType (in this case issue)
        RequestSecurityToken tokenRequest = new RequestSecurityToken(doc, TrustConstants.REQUEST_ISSUE);
   
        // Setting the context and the token type we want to be returned
        tokenRequest.setContext(new URI("http://context.context"));
        tokenRequest.setTokenType(TokenTypes.X509);
   
        // Construct a bunch of username tokens to be used as <Base> and <Supporting> elements
        UsernameToken userToken = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
        userToken.setName("bob");
        userToken.setPassword("bobspass");
        tokenRequest.setBase(new SecurityTokenOrReference(userToken));

        UsernameToken user2Token = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
        user2Token.setName("joe");
        user2Token.setPassword("bobspass");
        tokenRequest.addSupporting(new SecurityTokenOrReference(user2Token));

        UsernameToken user3Token = new UsernameToken(wssConfig.isPrecisionInMilliSeconds(), doc);
        user3Token.setName("mike");
        user3Token.setPassword("bobspass");
        tokenRequest.addSupporting(new SecurityTokenOrReference(user3Token));

        // Set the desired Lifetime of the token being requested in this case to 250 seconds
        Date start = new Date();
        Date end = new Date();
        end.setTime(start.getTime() + 250 * 1000);
        tokenRequest.setLifetime(new Lifetime(wssConfig, doc, start, end));

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
        // as its only child
        SOAPBodyElement sbe = new SOAPBodyElement(tokenRequest.getElement());

        // Add the body element to the SOAP envelope
        env.addBodyElement(sbe);

        System.out.println("\n============= Request ==============");
        System.out.println(XMLUtils.DocumentToString(env.getAsDocument()));
   
        // This is where we actually invoke the service, sending the request we've constructed
        // Assuming we did everything right, it will return to us a SOAP envelope containing the response
        SOAPEnvelope response = call.invoke(env);

        System.out.println("\n============= Response ==============");
        XMLUtils.PrettyElementToStream(response.getAsDOM(), System.out);
   
        // Find the <RequestSecurityTokenResponse> element the SOAP body should contain
View Full Code Here

public class SampleSecurityTokenServiceClient {

    // First arg passed should be the URL of the service. If none is specified, client tries localhost.
    public static void main(String[] args) throws DOMException, TrustException, Exception {
        Service service = new Service();
        Call call = (Call) service.createCall();
   
        // The default service location
        String url = "http://localhost:8080/JavaTrust/services/SampleSecurityTokenService";
        // Or the user-specified location
        if (args.length > 0)
            url = args[0];
        call.setTargetEndpointAddress(new java.net.URL(url));

        SOAPEnvelope env = new SOAPEnvelope();
        Document doc = env.getAsDocument();
        WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();

        // Create a new request object passing an XML document for element creation and the RequestType (in this case issue)
        RequestSecurityToken tokenRequest = new RequestSecurityToken(doc, TrustConstants.REQUEST_ISSUE);
   
        // Setting the context and the token type we want to be returned
        tokenRequest.setContext(new URI("http://context.context"));
        tokenRequest.setTokenType(TokenTypes.X509);
   
        // Construct a bunch of username tokens to be used as <Base> and <Supporting> elements
        UsernameToken userToken = new UsernameToken(wssConfig, doc);
        userToken.setName("bob");
        userToken.setPassword("bobspass");
        tokenRequest.setBase(new SecurityTokenOrReference(userToken));

        UsernameToken user2Token = new UsernameToken(wssConfig, doc);
        user2Token.setName("joe");
        user2Token.setPassword("bobspass");
        tokenRequest.addSupporting(new SecurityTokenOrReference(user2Token));

        UsernameToken user3Token = new UsernameToken(wssConfig, doc);
        user3Token.setName("mike");
        user3Token.setPassword("bobspass");
        tokenRequest.addSupporting(new SecurityTokenOrReference(user3Token));

        // Set the desired Lifetime of the token being requested in this case to 250 seconds
        Date start = new Date();
        Date end = new Date();
        end.setTime(start.getTime() + 250 * 1000);
        tokenRequest.setLifetime(new Lifetime(wssConfig, doc, start, end));

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
        // as its only child
        SOAPBodyElement sbe = new SOAPBodyElement(tokenRequest.getElement());

        // Add the body element to the SOAP envelope
        env.addBodyElement(sbe);

        System.out.println("\n============= Request ==============");
        System.out.println(XMLUtils.DocumentToString(env.getAsDocument()));
   
        // This is where we actually invoke the service, sending the request we've constructed
        // Assuming we did everything right, it will return to us a SOAP envelope containing the response
        SOAPEnvelope response = call.invoke(env);

        System.out.println("\n============= Response ==============");
        XMLUtils.PrettyElementToStream(response.getAsDOM(), System.out);
   
        // Find the <RequestSecurityTokenResponse> element the SOAP body should contain
View Full Code Here

TOP

Related Classes of org.apache.axis.client.Call

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.