Xfire webservice 簡單應用

import java.net.MalformedURLException; import java.util.Date; import org.codehaus.xfire.XFire; 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 org.codehaus.xfire.transport.http.CommonsHttpMessageSender; import cn.com.cpit.service.RTXWebservice; import cn.com.cpit.vo.Person; public class RTXTest { public static void main(String[] args) { String endpoint = "http://localhost:8080/RTXProWebservice/services/RTXProWebservice"; XFire xfire = XFireFactory.newInstance().getXFire(); XFireProxyFactory factory = new XFireProxyFactory(xfire); Service serviceModel = new ObjectServiceFactory().create(RTXWebservice.class,null, "http://vivianj.org/RTXWebservice", null); serviceModel.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "true"); RTXWebservice stub = null; try { stub = (RTXWebservice) factory.create(serviceModel, endpoint); } catch (MalformedURLException e) { e.printStackTrace(); } Person person = new Person(); person.setUserName("ruzh"); person.setChsName("用戶"); person.setEmail("mail@mail.com"); person.setMobile("13622222222"); person.setPhone("00"); person.setGender("1"); int check = stub.userIsExist("ruzh"); System.out.println(check); int result = -1; if (check == 0) { result = stub.updateUser(person); System.out.println(result); } }
相關文章
相關標籤/搜索