- 论坛徽章:
- 0
|
- /**
- * 查询服务器端的信息
- * @param methodName 调用的方法名称
- * @param params 调用WebService接口需要传入的参数
- * @return
- * @throws Exception
- */
- public static String queryRemoteInfor(String methodName, String params) throws Exception{
- String result = "";
- String soapAction = Constants.NAME_SPACE + methodName;// SOAP Action
- SoapObject rpc = new SoapObject(Constants.NAME_SPACE, methodName);// 指定WebService的命名空间和调用的方法名
- // 设置需调用WebService接口需要传入的参数
- rpc.addProperty("arg0", params);
-
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
- SoapEnvelope.VER10);// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
- envelope.bodyOut = rpc;
- envelope.setOutputSoapObject(rpc);
- HttpTransportSE transport = new HttpTransportSE( Constants.ENDPOINT ,60000);
- // HttpTransportSE transport = SingletonHttpTransportSe.getInstance();
- try {
- transport.call(soapAction, envelope);
- // 获取返回的数据
- Object response = envelope.getResponse();
- result = String.valueOf(response);
- if (null == result ||result.equals("anyType{}") || result.equals("[]")) {
- result="";
- }
- return result;
- } catch (Exception e) {
- e.printStackTrace();
- throw new Exception();
- }
- }
复制代码 |
|