Package org.apache.cxf.endpoint

Examples of org.apache.cxf.endpoint.ClientImpl$EchoContext


        proxyFac.setBus(getBus());

        Object proxyObj = proxyFac.create();
        docClient = (IDocumentService)proxyObj;
        Client client = ClientProxy.getClient(proxyObj);
        ClientImpl clientImpl = (ClientImpl)client;
        clientImpl.setSynchronousTimeout(1000000000);
    }
View Full Code Here


        proxyFac.setBus(getBus());

        Object proxyObj = proxyFac.create(IDocumentService.class);
        docClient = (IDocumentService)proxyObj;
        Client client = ClientProxy.getClient(proxyObj);
        ClientImpl clientImpl = (ClientImpl)client;
        clientImpl.setSynchronousTimeout(1000000000);
    }
View Full Code Here

    }

    public static void main(String args[]) {
        // String serviceURL = "http://localhost:8080/BookService";
        try {
            Client client = new ClientImpl(new URL("http://localhost:6980/BookService?WSDL"));

            Service s = client.getEndpoint().getService();
            AegisDatabinding db = new AegisDatabinding();
            s.setDataBinding(db);
            db.initialize(s);
           
            TypeMapping tm = (TypeMapping) s.get(TypeMapping.class.getName());
            BeanType type = new BeanType();
            type.setSchemaType(new QName("http://org.codehaus.xfire.client", "Book"));
            type.setTypeClass(Book.class);
            type.setTypeMapping(tm);

            System.out.println(type);

            tm.register(type);

            ArrayType aType = new ArrayType();
            aType.setTypeClass(Book[].class);
            aType.setSchemaType(new QName("http://client.xfire.codehaus.org", "ArrayOfBook"));
            aType.setTypeMapping(tm);
            tm.register(aType);

            QName qn = tm.getTypeQName(Book.class);
            System.out.println("QName(" + tm.isRegistered(Book.class) + ") = " + qn);

            Book book = new Book();

            book.setAuthor("Dan");
            book.setIsbn("1");
            book.setTitle("XFire in Action");
            // client.invoke("addBook", new Object[] {book});

            book.setAuthor("Dierk");
            book.setIsbn("2");
            book.setTitle("Groovy in Action");
            // client.invoke("addBook", new Object[] {book});

            Book[] books = (Book[])client.invoke("getBooks", new Object[] {})[0];

            System.out.println("BOOKS:");

            for (int i = 0; i < books.length; i++) {
                System.out.println(books[i].getTitle());
View Full Code Here

        WSDLServiceFactory sf = (service == null)
            ? (new WSDLServiceFactory(bus, wsdlUrl)) : (new WSDLServiceFactory(bus, wsdlUrl, service));
        sf.setAllowElementRefs(allowRefs);
        Service svc = sf.create();

        ClientImpl client = new ClientImpl(bus, svc, port,
                                           getEndpointImplFactory());

        //all SI's should have the same schemas
        SchemaCollection schemas = svc.getServiceInfos().get(0).getXmlSchemaCollection();

        SchemaCompiler compiler =
            JAXBUtils.createSchemaCompilerWithDefaultAllocator(new HashSet<String>());
       
        InnerErrorListener listener = new InnerErrorListener(wsdlUrl);
        Object elForRun = ReflectionInvokationHandler
            .createProxyWrapper(listener,
                                JAXBUtils.getParamClass(compiler, "setErrorListener"));
       
        compiler.setErrorListener(elForRun);
       
        OASISCatalogManager catalog = bus.getExtension(OASISCatalogManager.class);
        hackInNewInternalizationLogic(compiler, catalog);

        addSchemas(compiler.getOptions(), compiler, svc.getServiceInfos(), schemas);
        addBindingFiles(bindingFiles, compiler);
        S2JJAXBModel intermediateModel = compiler.bind();
       
        listener.throwException();
       
        JCodeModel codeModel = intermediateModel.generateCode(null, elForRun);
        StringBuilder sb = new StringBuilder();
        boolean firstnt = false;

        for (Iterator<JPackage> packages = codeModel.packages(); packages.hasNext();) {
            JPackage jpackage = packages.next();
            if (!isValidPackage(jpackage)) {
                continue;
            }
            if (firstnt) {
                sb.append(':');
            } else {
                firstnt = true;
            }
            sb.append(jpackage.name());
        }
        JAXBUtils.logGeneratedClassNames(LOG, codeModel);
       
        String packageList = sb.toString();

        // our hashcode + timestamp ought to be enough.
        String stem = toString() + "-" + System.currentTimeMillis();
        File src = new File(tmpdir, stem + "-src");
        if (!src.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + src.getPath());
        }
        try {
            Object writer = JAXBUtils.createFileCodeWriter(src);
            codeModel.build(writer);
        } catch (Exception e) {
            throw new IllegalStateException("Unable to write generated Java files for schemas: "
                                            + e.getMessage(), e);
        }
        File classes = new File(tmpdir, stem + "-classes");
        if (!classes.mkdir()) {
            throw new IllegalStateException("Unable to create working directory " + classes.getPath());
        }
        StringBuilder classPath = new StringBuilder();
        try {
            setupClasspath(classPath, classLoader);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
       
        List<File> srcFiles = FileUtils.getFilesRecurse(src, ".+\\.java$");
        if (!compileJavaSrc(classPath.toString(), srcFiles, classes.toString())) {
            LOG.log(Level.SEVERE , new Message("COULD_NOT_COMPILE_SRC", LOG, wsdlUrl).toString());
        }
        FileUtils.removeDir(src);
        URLClassLoader cl;
        try {
            cl = new URLClassLoader(new URL[] {classes.toURI().toURL()}, classLoader);
        } catch (MalformedURLException mue) {
            throw new IllegalStateException("Internal error; a directory returns a malformed URL: "
                                            + mue.getMessage(), mue);
        }

        JAXBContext context;
        Map<String, Object> contextProperties = jaxbContextProperties;
       
        if (contextProperties == null) {
            contextProperties = Collections.emptyMap();
        }
       
        try {
            if (StringUtils.isEmpty(packageList)) {
                context = JAXBContext.newInstance(new Class[0], contextProperties);
            } else {
                context = JAXBContext.newInstance(packageList, cl, contextProperties);
            }
        } catch (JAXBException jbe) {
            throw new IllegalStateException("Unable to create JAXBContext for generated packages: "
                                            + jbe.getMessage(), jbe);
        }
        
        JAXBDataBinding databinding = new JAXBDataBinding();
        databinding.setContext(context);
        svc.setDataBinding(databinding);

        ServiceInfo svcfo = client.getEndpoint().getEndpointInfo().getService();

        // Setup the new classloader!
        Thread.currentThread().setContextClassLoader(cl);

        TypeClassInitializer visitor = new TypeClassInitializer(svcfo,
View Full Code Here

        clientBean.setBus(getBus());
        clientBean.getInInterceptors().add(new LoggingInInterceptor());
       
        HelloService client = (HelloService) proxyFactory.create();
       
        ClientImpl c = (ClientImpl)ClientProxy.getClient(client);
        c.getOutInterceptors().add(new LoggingOutInterceptor());
        c.getInInterceptors().add(new LoggingInInterceptor());
       
        assertEquals("hello", client.sayHello());
        assertEquals("hello", client.echo("hello"));
    }
View Full Code Here

        applyFeatures(client);
        return client;
    }

    protected Client createClient(Endpoint ep) {
        Client client = new ClientImpl(getBus(), ep, getConduitSelector());
        this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep);
        return client;
    }
View Full Code Here

        jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
       
        jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
        jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
       
        Client client = new ClientImpl(bus, jaxwsEndpoint);
        InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
        Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] {
            serviceEndpointInterface, BindingProvider.class }, ih);
        return serviceEndpointInterface.cast(obj);
    }
View Full Code Here

            factory.setDataBinding(dataBinding);
            Service service = factory.create();
            service.setDataBinding(dataBinding);
            EndpointInfo ei = service.getEndpointInfo(endpointName);
            Endpoint endpoint = new EndpointImpl(bus, service, ei);
            client = new ClientImpl(bus, endpoint);
        } else {
            Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion,
                                                           policy, endpointName);

            client = new ClientImpl(bus, endpoint);
        }
       
        client.getInFaultInterceptors().addAll(inFault);
        client.getInInterceptors().addAll(in);
        client.getOutInterceptors().addAll(out);
View Full Code Here

        }
       
        jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor());
        jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor());

        Client client = new ClientImpl(bus, jaxwsEndpoint);
        InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
        Object obj = Proxy
            .newProxyInstance(serviceEndpointInterface.getClassLoader(),
                              new Class[] {serviceEndpointInterface, BindingProvider.class}, ih);
        updateAddressPort(obj, PORT);
View Full Code Here

        //CXF-3956
        hc.addAll(handlerResolver.getHandlerChain(portInfos.get(portName)));       
        endpoint.getJaxwsBinding().setHandlerChain(hc);
       
        // create the client object, then initialize the endpoint features against it
        Client client = new ClientImpl(clientBus, endpoint, clientFac.getConduitSelector());
        for (AbstractFeature af : endpoint.getFeatures()) {
            af.initialize(client, clientBus);
        }
        //CXF-2822
        initIntercepors(client, clientFac);
        if (executor != null) {
            client.getEndpoint().setExecutor(executor);
        }
        // if the client factory has an address specified, use that, if not
        // then try to get it from the wsdl
        if (!StringUtils.isEmpty(clientFac.getAddress())) {
            client.getEndpoint().getEndpointInfo().setAddress(clientFac.getAddress());
        } else {
            //Set the the EPR's address in EndpointInfo
            PortInfoImpl portInfo = portInfos.get(portName);
            if (portInfo != null && !StringUtils.isEmpty(portInfo.getAddress())) {
                client.getEndpoint().getEndpointInfo().setAddress(portInfo.getAddress());
            }
        }

        Dispatch<T> disp = new DispatchImpl<T>(client, mode, context, type);
        configureObject(disp);
View Full Code Here

TOP

Related Classes of org.apache.cxf.endpoint.ClientImpl$EchoContext

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.