android通过soap协议调用webserver。方法如下:
public String realBus(int gprsId,int orderNo, int direction, String url) throws WSError {
SoapObject rpc = new SoapObject(REAL_NAMESPACE, "realBus");
// 指定 WebService 的命名空间和调用方法
rpc.addProperty("gprsId", gprsId);
rpc.addProperty("orderNo", orderNo);
rpc.addProperty("direction", direction);
String response = doWebServicesRequest(rpc, url);// 获取响应值
return response;
}
public String doWebServicesRequest(SoapObject rpc,String url) throws WSError{
// 生成调用WebService方法的SOAP请求信息
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.encodingStyle = "UTF-8";
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
// 创建HttpTransportsSE对象
HttpTransportSE ht = new HttpTransportSE(url);
ht.debug = true ;
try {
ht.call(null, envelope);
if (envelope.getResponse() != null) {
String reString = envelope.getResponse().toString();
if(reString.equals("anyType{}") || reString.equals("null")){
reString = "";
}
return reString;
}
} catch (Exception e) {
WSError wsError = new WSError();
wsError.setMessage(e.getLocalizedMessage());
throw wsError;
}
return "";
}
js怎么调用同一个接口啊?
命名空间 方法名 url 怎么传参啊?
求具体代码。拜托拜托。。。。。。
1 个回复
stock2
这个算是插件或封装吗?
帮顶. 我也学习下.
想知道 特定的 Native.JS 有哪些?
如何封装.