package com.jiepusoft.jsr181;
import javax.jws.WebService;
import javax.jws.WebResult;
@WebService(targetNamespace = "http://www.jiepusoft.com")
public interface IndexInterface {
/**
* 删除索引一条内容
* @param docId int
* @return boolean
* @throws Exception
*/
@WebResult(name = "index")
public boolean deleteOneIndexByID(int ino,int docId) throws Exception;
/**
*
* @param field String
* @param value String
* @return boolean
* @throws Exception
*/
@WebResult(name = "index_field")
public long deleteOneIndexByField(String field , String value) throws Exception;
}
package com.jiepusoft.jsr181;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
//java使用xfire生成JSR181版WebService客户端,接口化方法
public class HelloJSR181Client {
public static void main(String[] args) {
//这里不是http://127.0.0.1:8080/service/index?wsdl
String url = "http://127.0.0.1:8080/service/index";
try {
Service serviceModel = new ObjectServiceFactory()
.create(IndexInterface.class);
System.out.println(" ----> 初始客户端 <---- ");
IndexInterface client = (IndexInterface) new XFireProxyFactory()
.create(serviceModel, url);
System.out.println(client.deleteOneIndexByID(0, 30361));
System.out.println(client.deleteOneIndexByField("docNo", "76ad"));
System.out.println(" ----> 客户端调用结束 <---- ");
} catch (Exception e) {
e.printStackTrace();
}
}
}