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

📄 wsclient.java

📁 java WebService 调用的一个demo
💻 JAVA
字号:
package com.fubao.testwsclient;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

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.Course;
import com.fubao.testws.HelloService;
import com.fubao.testws.User;

public class WSClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Service srvcModel = new ObjectServiceFactory().create(HelloService.class);
		XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
		String helloWorldURL = "http://localhost:8088/testWS/services/HelloService";
		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());
	       }		  */       	    
	    } catch (MalformedURLException e) {
		   e.printStackTrace();
        }
	}

}

⌨️ 快捷键说明

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