java 调用 .net webservice
1、首先下载Axis2工具包
2、解压之后用cmd命令进入bin目录WSDL2Java.bat -uri http://192.168.20.42:9999/LoginService.asmx?wsdl
3、执行成功后将会在bin目录下生成src目录,将里面的java文件加入项目
4、开始调用:
LoginServiceStub stub = new LoginServiceStub(); stub._getServiceClient().getOptions().setProperty( org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); //DoUrl是里面的方法名称
LoginServiceStub.DoUrl dourl=new LoginServiceStub.DoUrl(); Department dpt= elUser.getDepartment(); //设置参数
dourl.setKey("03d98d487cf247d5aee14fbc52f564b4"); dourl.setUsername(elUser.getUsername()); dourl.setDepid(String.valueOf(dpt.getId())); String strUrl= stub.doUrl(dourl).getDoUrlResult();