android java中的复杂ksoap
我正在尝试使用 android 上的 ksoap java 将一些数据上传到 .net 中的网络服务。 我尝试过但没有成功。结果为空,我不知道为什么会发生这种情况 我使用的代码如下:
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>
KvmSerialized 代码是
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());
}
好的。这是我正在使用的。有谁知道如何解决这个问题?
am trying to upload some data to a webservise in .net using ksoap java on android.
i have try to work it but with no success. the result is null and i have no idea why this is happen
the code that am using is the follow:
xml web service
<?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>
the KvmSerializable code is
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;
}
}
}
and my main is:
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());
}
ok. this is that am using. does anyone know how this can be fixed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为时间戳属性不正确。通常 .net webservices 时间戳格式就像
我不记得确切的语法
I belive that the timestamp property is incorrect. Ususally .net webservices format for timestamp is something like
i can't remember the exact sintax