axisclient.java

来自「java WebService 调用的一个demo」· Java 代码 · 共 47 行

JAVA
47
字号
package com.fubao.testwsclient;

import java.net.MalformedURLException;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

import com.fubao.testws.AxisHelloInterface;

public class AxisClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Service srvcModel = new ObjectServiceFactory().create(AxisHelloInterface.class);
		XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
		String helloWorldURL = "http://localhost:8088/testAxis/services/Hello";
		try {
		   //HelloService srvc = ((HelloService) factory.create(srvcModel,helloWorldURL));
		   //String hellostring = ((HelloService) factory.create(srvcModel,helloWorldURL)).sayHello("lifubao");
          // System.out.println(hellostring);
		   /*System.out.println(srvc.sayHello("Robin"));  
		   User u=new User();
		   u.setName("RRRRR");
	       Course c=srvc.choose(u);
		   System.out.println(c.getName());
		   List al=new ArrayList();
		   al.add("1212");
		   al.add("2222");
		   List t=srvc.test(al);
		   for (int i = 0; i < t.size(); i++) {
		       Course co=(Course)t.get(i);
		       System.out.println(co.getName());
	       }		  */ 
           AxisHelloInterface hello = (AxisHelloInterface) factory.create(srvcModel,helloWorldURL);
           System.out.println(hello.sayHello("fubaohello"));
           
	    } catch (MalformedURLException e) {
		   e.printStackTrace();
        }
	}

}

⌨️ 快捷键说明

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