[英]complex ksoap in android java
我正在嘗試使用android上的ksoap java將一些數據上傳到.net中的webservise。 我已經嘗試了,但是沒有成功。 結果為null,我不知道為什么會這樣,正在使用的代碼如下:
xml Web服務
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddBloodPressure xmlns="http://tempuri.org/">
<PatientID>int</PatientID>
<BloodPressure>
<Sistolic>int</Sistolic>
<Distolic>int</Distolic>
</BloodPressure>
<DateTimeStamp>dateTime</DateTimeStamp>
</AddBloodPressure>
</soap:Body>
</soap:Envelope>
KvmSerializable代碼是
public class Category implements KvmSerializable
{
public int Distolic;
public int Sistolic;
public int getDistolic() {
return Distolic;
}
public void setDistolic(int distolic) {
Distolic = distolic;
}
public int getSistolic() {
return Sistolic;
}
public void setSistolic(int sistolic) {
Sistolic = sistolic;
}
public Object getProperty(int arg0) {
switch(arg0)
{
case 0:
return getSistolic();
case 1:
return getDistolic();
}
return null;
}
public int getPropertyCount() {
return 3;
}
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo info) {
switch(arg0)
{
case 0:
info.type = PropertyInfo.INTEGER_CLASS;
info.name = "Sistolic";
break;
case 1:
info.type = PropertyInfo.INTEGER_CLASS;
info.name = "Distolic";
break;
default:break;
}
}
public void setProperty(int arg0, Object arg1) {
switch (arg0)
{
case 0:
this.Sistolic = Integer.parseInt(arg1.toString());
break;
case 1:
this.Distolic=Integer.parseInt(arg1.toString());
break;
}
}
}
我的主要是:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("PatientId", "8");
Category i1=new Category();
i1.setDistolic(100);
i1.setSistolic(100);
PropertyInfo pi=new PropertyInfo();
pi.setName("BloodPressure");
pi.setValue(i1);
pi.setType(i1.getClass());
request.addProperty(pi); request.addProperty("DateTimeStamp","2012-01-13");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Object result=((Object)envelope.getResponse());
String resultString=new String(result.toString());
}
好。 這就是正在使用。 有誰知道如何解決?
我相信timestamp屬性不正確。 通常,.net webservices格式的時間戳類似於
yyyyMMddThhmmss
我不記得確切的罪過
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.