import java.net.URL;
import java.rmi.RemoteException;
import java.sql.Date;
import java.util.Calendar;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
/**
* 加锁
* @author Wangsong
*
*/
@org.springframework.stereotype.Service
public class CheckDogWebserice {
@SuppressWarnings("deprecation")
public static String GetUserPowerOther() {
String url = "http://198.33.5.221:8001/sdrswebservice/sdrsservice.asmx";
String namespace = "http://tempuri.org/";
String methodName = "UserPower";
String soapActionURI = "http://tempuri.org/UserPower";
Service service = new Service();
Call call;
try {
call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionURI);
call.setOperationName(new QName(namespace, methodName));
call.addParameter(new QName(namespace, "strType"), XMLType.XSD_STRING,ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
call.addParameter(new QName(namespace, "strPassWord"), XMLType.XSD_STRING,ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String[] str = new String[2];
str[0] = 1111;
str[1] = 1111;
String obj = (String)call.invoke(str);
return obj;
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
return "调用webService失败";
}
}
本文介绍了一种使用Java通过Apache Axis库调用远程WebService的方法,以获取用户的特定权限信息。示例代码展示了如何设置目标地址、SOAP操作、参数及返回类型,并提供了具体的调用流程。
386

被折叠的 条评论
为什么被折叠?



