xfire调用示例
xfire调用简单示例。
import java.util.HashMap; import org.codehaus.xfire.XFireFactory; import org.codehaus.xfire.client.XFireProxyFactory; import org.codehaus.xfire.service.binding.ObjectServiceFactory; import org.codehaus.xfire.transport.http.CommonsHttpMessageSender; public class TestXfireCaller { private String ip = "1.1.1.1"; private String param1 = "111"; private String param2 = "222"; private String param3 = "S-Revcore-uncertify"; private int param4 = 5; private MsgDeliveryService msgDeliveryService; public void init() { try { HashMap<String, String> props = new HashMap<String, String>(); props.put(CommonsHttpMessageSender.HTTP_TIMEOUT, "180000"); org.codehaus.xfire.service.Service service = new ObjectServiceFactory() .create(MsgDeliveryService.class, null,"com.xxx.xxx.management.service", props); XFireProxyFactory factory = new XFireProxyFactory(XFireFactory .newInstance().getXFire()); String wsdlUrl2 = "http://" + ip + ":8080/services/msgDeliveryService"; msgDeliveryService = (MsgDeliveryService) factory.create(service, wsdlUrl2); } catch (Exception e) { e.printStackTrace(); } } public boolean remoteInterface() { return msgDeliveryService.isMsgDeliveryDelayed(param1, param2, param3, param4); } public static void main(String[] args) { TestXfireCaller msgbrokerWSCaller = new TestXfireCaller(); msgbrokerWSCaller.init(); System.out.println("xfire调用结果=" + msgbrokerWSCaller.remoteInterface()); } }