java调用WebService
2016-09-08 00:00
113 查看
Java调用.net的WebService,因为对WebService不熟悉,搞了一天,终于搞完
注意命名空间是 http://tempuri.org
方法名是 GetAuthenticationUser
服务地址是 http://10.16.1.1/portal/sso.asmx
SOAPActionURI是 http://tempuri.org/GetAuthenticationUser
【SOAPActionURI】为啥是这个我也不懂~
package com.pansoft.jbsf.oa.controller; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import com.jf.core.Controller; import com.pansoft.jbsf.bean.JsonResult; import com.pansoft.oa.untils.BussinessUtils; import net.sf.json.JSONObject; public class SSOLoginController extends Controller{ public String getCurrentUserId(){ Object object = this.getRequest().getSession().getAttribute("usercode");//不能为空 if(object!=null){ return object.toString(); }else{ return ""; } } /** * 默认 * @throws Exception * */ public void index() throws Exception{ GetAuthenticationUser(); } /** * 获取单点登录用户Token * 解析用户信息 * 判断用户是否存在 * */ public void GetAuthenticationUser() throws org.apache.soap.SOAPException, ServiceException, RemoteException{ JsonResult result = new JsonResult(); String Token = getPara("Token"); JSONObject object = JSONObject.fromObject(Token); String token = object.getString("Token"); String endpoint = "http://10.16.1.1/portal/sso.asmx"; Service service = new Service(); Call call = (Call) service.createCall(); call.setOperationName(new QName("http://tempuri.org/","GetAuthenticationUser")); call.setTargetEndpointAddress(endpoint); call.setEncodingStyle("UTF-8"); call.setUseSOAPAction(true); call.setSOAPActionURI("http://tempuri.org/GetAuthenticationUser"); call.addParameter("SystemCode", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数 call.addParameter("Secret", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数 call.addParameter("Token", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数 call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 String username = (String)call.invoke(new Object[]{"ZHXZFWPT","",token}); if(BussinessUtils.ifhavaUser(username)){//判读系统是否有该用户 result.setSuccess(true); result.setData(username); }else{ result.setSuccess(false); List<String> message = new ArrayList<String>(); message.add("单点登录用户不存在!"); result.setMessage(message); } //给方法传递参数,并且调用方法 renderJson(result); } }
注意命名空间是 http://tempuri.org
方法名是 GetAuthenticationUser
服务地址是 http://10.16.1.1/portal/sso.asmx
SOAPActionURI是 http://tempuri.org/GetAuthenticationUser
【SOAPActionURI】为啥是这个我也不懂~
相关文章推荐
- .Net调用Java的WebService之亲身体验
- .Net调用Java的WebService实例
- java客户端调用webservice的例子
- webservice系列教学(4)-如何调用webservice(pb,java)
- Java调用.Net写的Webservice
- .Net调用Java的WebService之亲身体验
- 使用Java客户端类调用c# WebService和xml rpc server
- .net与java 使用自定义对象通过WebService调用
- xFire实现Java间自定义类型的WebService调用(二)
- [BTS]Java调用.net webservice
- 用JAVA调用.net的webservice实例
- [转贴]Java客户端调用Https Webservice
- Java动态调用WebService方法
- Java调用DotNet WebService为什么那么难?
- 使用Java客户端类调用c# WebService和xml rpc server(转)
- .Net调用Java的WebService之亲身体验 (转自梦幻Dot Net)
- JAVA如何调用.NET开发的WebService
- [导入]Java调用.net的WebService
- java调用WebService的例子
- 用java写的调用.net写的WebService时,调用成功,参数传不过去的原因