项目总结-访问WCFService

公司项目服务器是用.net写的,客户端需要调用WCFService,下面用代码说明下android怎么调用WCFService。

public class WebSoapUtil {

private static int timeOut = 10000; // 时限
private static HttpTransportSE androidHttpTransport = null;


public static SoapSerializationEnvelope getEnvelope(
SoapSerializationEnvelope envelope, String url, String soapAction,
SoapObject request, Context mContext) throws HttpResponseException,
IOException, XmlPullParserException {
if(!Tools.checkNetworkAvailable(mContext)){
return null;
}
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true; // 设置.net web service
envelope.headerOut = Tools.buildHeader(url, soapAction);
envelope.setOutputSoapObject(request);// 发送请求
// System.setProperty("http.keepAlive", "false");
androidHttpTransport = new HttpTransportSE(url, timeOut);
// androidHttpTransport.debug = true;
androidHttpTransport.call(soapAction, envelope);
if (envelope.getResponse() == null) {
System.out.println("请求服务器,连接成功但是数据存在问题");
envelope = null;// 连接成功但是数据是空值
}
return envelope;
}

上述文件是调用WCFService 缩写的工具类。调用的时候只需要传入相应参数就可以。

例如:

SoapObject request = new SoapObject(nameSpace, methodName);
request.addProperty("PatientId", PatientId);
request.addProperty("ClinicDate",ClinicDate);
envelope = WebSoapUtil.getEnvelope(envelope, url, soapAction, request, mContext);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值