您的位置:首页 > 其它

接口

2014-03-29 13:42 274 查看
public static Map<String,String> getMapValue(String url,String method,ArrayList<Map<String,String>> list){
Map<String,String> param=new HashMap<String, String>();
String detail=null;
String namespace="http://service.itcs.inhua.com/";   //命名空间
String Soap_Action="http://service.itcs.inhua.com/"+method;   //SOAP Action通常为命名空间 + 调用的方法名称。
SoapObject  request = new SoapObject(namespace, method);
for(int i=0;i<list.size();i++){
try{
for (Map.Entry<String, String> entry:list.get(i).entrySet()) {
String key=entry.getKey();
String value=entry.getValue();
request.addProperty(key,value);
}
}catch(Exception e){
e.printStackTrace();
}
}

SoapSerializationEnvelope  envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(url);
ht.debug = true;

try{
ht.call(Soap_Action, envelope);
if( envelope.bodyIn!=null){
SoapObject soapObject = (SoapObject) envelope.bodyIn;
for(int i=0;i<soapObject.getPropertyCount();i++){
SoapObject  soapChilds =(SoapObject) soapObject.getProperty(i);
SoapObject  soapChil=(SoapObject)soapChilds.getProperty("entry");
param.put("message", ""+soapChil.getPropertyAsString("value"));

}
detail=soapObject.getProperty(0).toString();
String[] strs=detail.split("entry");

String[] str=strs[2].split("=");

String  records=str[3].split(";")[0];
param.put("totalRecords", records);
}

}catch(IOException e){
e.printStackTrace();
}catch(XmlPullParserException e){
e.printStackTrace();
}
return param;
}
public static String getRequestInt(String url,String method,ArrayList<Map<String,Integer>> list){
String detail=null;
String namespace="http://service.itcs.inhua.com/";   //命名空间
String Soap_Action="http://service.itcs.inhua.com/"+method;   //SOAP Action通常为命名空间 + 调用的方法名称。
SoapObject  request = new SoapObject(namespace, method);
for(int i=0;i<list.size();i++){
try{
for (Map.Entry<String, Integer> entry:list.get(i).entrySet()) {
String key=entry.getKey();
int value=entry.getValue();
request.addProperty(URLEncoder.encode(key, "UTF-8"),value);
}
}catch(Exception e){
e.printStackTrace();
}
}

SoapSerializationEnvelope  envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(url);
ht.debug = true;

try{
ht.call(Soap_Action, envelope);
if( envelope.bodyIn!=null){
SoapObject so = (SoapObject) envelope.bodyIn;
detail = so.getProperty(0).toString();
}
}catch(IOException e){
e.printStackTrace();
}catch(XmlPullParserException e){
e.printStackTrace();
}
return detail;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: