80,359
社区成员
发帖
与我相关
我的任务
分享
private static final String NAMESPACE = " http://tempuri.org/";
private static final String METHOD_NAME = "GetNewsListByColId";
private static String SOAP_ACTION = NAMESPACE + METHOD_NAME;
private static String URL = "http://XXXX/WebService1.asmx";
// 返回的查询结果
String result = null;
// 获得返回请求对象
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// 设置需要返回请求对象的参数
System.out.println("request.addProperty(colId," + colId);
// 设置soap的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// 设置是否调用的是dotNet开发的
envelope.dotNet = true;
envelope.bodyOut = request;
HttpTransportSE ht = new HttpTransportSE(URL,10000);//第二个参数是超时时间 10秒
request.addProperty("colId","29");
//request = request.addProperty("arg0","29");
ht.debug = true;
// web service请求
try {
ht.call(SOAP_ACTION, envelope);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 得到返回结果
Object o =null;
try {
o = envelope.getResponse();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result = o.toString();
return result;
/// <summary>
/// 获取信息信息列表,可以根据新闻类型ID
/// </summary>
/// <param name="colId">新闻类型</param>
/// <returns>新闻标题列表</returns>
[WebMethod]
public string GetNewsListByColId(string colId)
{
}
<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetNewsListByColId xmlns="http://tempuri.org/">
<colId>29</colId>
</GetNewsListByColId>
</soap:Body>
</soap:Envelope>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<GetNewsListByColId xmlns=" http://tempuri.org/" id="o0" c:root="1">
<colId i:type="d:string">29</colId>
</GetNewsListByColId>
</v:Body>
</v:Envelope>