client.java

来自「基于ruby的进阶编程,大家可以对照教材<<Ruby on Rail」· Java 代码 · 共 33 行

JAVA
33
字号
package ActionWebService;

import java.net.URL;

public class Client {
    private static int categoryId = 1; 

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            ServiceLocator scLocator = new ServiceLocator();
            
            ItemBindingStub itemClient = new ItemBindingStub(new URL(scLocator
                    .getItemPortAddress()), null);
            Item[] items = itemClient.findAllItems();
            
            CategoryBindingStub categoryClient = new CategoryBindingStub(
                    new URL(scLocator.getCategoryPortAddress()), null);
            Category category = categoryClient.findCategoryById(categoryId);
            
            System.out.println("id:" + items[0].getId() + "; title:"
                    + items[0].getTitle() + ";");
            System.out.println("id:" + category.getId() + "; name:"
                    + category.getName() + ";");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

⌨️ 快捷键说明

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