根据wsdl文件,Java工程自动生成webservice客户端调用
1,工具:带有webservice插件的myeclips
2,步骤:
(1),新建一个Java工程:relationship
(2),在myeclipse的新建工程中的“其他“中找到webservice client:
(3),建议选择:JAX-WS,然后输入wsdl地址:
生成后得到目录:
(4),创建测试代码:
package nc.xyzq.client; import java.util.ArrayList; import java.util.List; import nc.xyzq.uuib.service.impl.FrServiceImpl; import nc.xyzq.uuib.service.impl.FrServiceImplService; import nc.xyzq.uuib.service.impl.MessageBean; import nc.xyzq.uuib.service.impl.SysTokenBean; import nc.xyzq.uuib.service.impl.UserRoleBean; /** * ClassName:Client * Function: TODO * Reason: TODO * Date: 2018年11月20日 下午15:59:31 * @author lizm * @since JDK 1.6 * */ public class Client { public static void main(String[] args) { // TODO Auto-generated method stub FrServiceImplService service = new FrServiceImplService(); java.net.URL url; try { FrServiceImpl frServiceImpl = service.getFrServiceImplPort(); List<UserRoleBean> list = new ArrayList(); UserRoleBean userRoleBean = new UserRoleBean(); userRoleBean.setUserCode("60236"); userRoleBean.setRoleid("12432"); userRoleBean.setIsflag("1"); list.add(userRoleBean); MessageBean msgBean = new MessageBean(); msgBean = frServiceImpl.doUserRole(list); System.out.println("return>>>"+msgBean.getCode() + " " +msgBean.getMessage()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
(5)点击运行测试类,测试结果:
说明已经成功调用到wsdl;