android java中的复杂ksoap

发布于 2025-01-08 17:02:34 字数 3102 浏览 0 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

折戟 2025-01-15 17:02:34

我认为时间戳属性不正确。通常 .net webservices 时间戳格式就像

yyyyMMddThhmmss

我不记得确切的语法

I belive that the timestamp property is incorrect. Ususally .net webservices format for timestamp is something like

yyyyMMddThhmmss

i can't remember the exact sintax

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文