奇怪的是,object.toString()在android虚拟机上输出的结果和网页打开webservice的结果也不同。求教~~~?

解决方案 »

  1.   

    SoapObject result = (SoapObject)envelope.getResponse();
    System.out.println(result.toString());
    如果说你图片上得结果是在这里打印出来的,说明你的webservice有问题。
      

  2.   

    你确定传回来的是 XML ?!
      

  3.   

    webservice返回单个string输出并没有问题,另外在IE中打开webservice然后直接调用
    是有结果的,内容就是第一个xml code。我也怀疑过,试图将object保存成文件通过文本编辑器查看内容,因为虚拟机问题未果。
    返回的xml 是对的么?我已经贴在1楼了。感谢2位的回答。
      

  4.   

    private List<Course> paserCourse(SoapObject result){
    List<Course> courses = new ArrayList<Course>();
    int iCount = result.getPropertyCount();
    for(int i = 0; i < iCount; i++){
    SoapObject child = (SoapObject)result.getProperty(i);
    Course course = new Course();
    course.courseId = child.getPropertyAsString("kcdm").trim();
    course.teacher = child.getPropertyAsString("xm").trim();
    course.name = child.getPropertyAsString("kcmc").trim();
    course.schoolYear = child.getPropertyAsString("xn").trim();
    course.schoolTerm = child.getPropertyAsString("xq").trim();
    course.department = child.getPropertyAsString("yxmc").trim();
    course.studentID = studentID;
    courses.add(course);
    }
    Log.d(TAG, "获取课程数 :" + courses.size());

    return courses;
    }这事我用来解析webservice返回结果的方法,webservice返回到结果是下面的形式,<?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>
        <M_GetKCInfoByStudentIDResponse xmlns="http://JCWebService.lib.sjtu.edu.cn/">
          <M_GetKCInfoByStudentIDResult>
            <KCInfo>
              <kcdm>string</kcdm>
              <kcmc>string</kcmc>
              <xm>string</xm>
              <xn>string</xn>
              <xq>string</xq>
              <yxmc>string</yxmc>
            </KCInfo>
            <KCInfo>
              <kcdm>string</kcdm>
              <kcmc>string</kcmc>
              <xm>string</xm>
              <xn>string</xn>
              <xq>string</xq>
              <yxmc>string</yxmc>
            </KCInfo>
          </M_GetKCInfoByStudentIDResult>
        </M_GetKCInfoByStudentIDResponse>
      </soap:Body>
    </soap:Envelope>(SoapObject)result.getProperty(i); 这一句获取到第i条<KCInfo>记录
      

  5.   


    我的返回结果是data table,里面并没有见到任何的soap ,envelope字样。不明白。。
      

  6.   


    我的返回结果是data table,里面并没有见到任何的soap ,envelope字样。不明白。。
      

  7.   

    做webservice那边使用data table保存sql结果的,跟这有没有关系?
      

  8.   

      那是webservice的访问示例返回结果, 意思就是返回的是这样的内容,但是你用soapObject是得不到完整的的xml内容的,所以要自己解析,比如你的datatable有8条记录,那么result.getPropertyCount()的值应该是5.(SoapObject)result.getProperty(1) 就得到了第2条table记录,getPropertyAsString("yxmc").trim();可以得到具体的某个属性的值,