⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookclient.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
字号:
package org.codehaus.xfire.client;

import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.util.Properties;

import org.codehaus.xfire.demo.Book;
import org.codehaus.xfire.demo.IBook;
import org.codehaus.xfire.security.wss4j.WSS4JOutHandler;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.util.dom.DOMOutHandler;

/**
 * <a href="mailto:tsztelak@gmail.com">Tomasz Sztelak</a>
 * Base class for security samples.
 * 
 */
public abstract class BookClient
{
    

    public static final String SERVICE_NAMESPACE = "http://xfire.codehaus.org/BookService";

    public static final String SERVICE_URL = "http://localhost:8080/security/services/";

    /**
     * Setups required security properties for given test.
     * @param properties
     */
    abstract protected void configureOutProperties(Properties properties);
    
    /**
     * @return Name of the client.
     */
    abstract protected String getName();
    /**
     * @param url
     * @throws MalformedURLException
     */
    public void executeClient(String serviceName)
        throws MalformedURLException
    {
        System.out.print("Running client : "+getName()+"\n");
        

        Service serviceModel = new ObjectServiceFactory().create(IBook.class,
                                                                 "BookService",
                                                                 SERVICE_NAMESPACE,
                                                                 null);

        IBook service = (IBook) new XFireProxyFactory().create(serviceModel, SERVICE_URL
                + serviceName);

        Client client = ((XFireProxy) Proxy.getInvocationHandler(service)).getClient();
        
        client.addOutHandler(new DOMOutHandler());
        Properties properties = new Properties();
        configureOutProperties(properties);
        client.addOutHandler(new WSS4JOutHandler(properties));
        
        System.out.print("Looking for isbn : 0123456789 ....");
        Book b = service.findBook("0123456789");
        System.out.print(b.getTitle() + " : " + b.getAuthor() + "\n");

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -