服务器用的webservice给手机传输的数据,我做的是客户端,通过ksoap接收的数据,最后有一些数据需要上传给服务器,我用什么技术给上传呢,怎么上传。我是新手,希望大侠能给一个比较明确的答案。上传的数据中还要有照片的。

解决方案 »

  1.   

    既然服务器能向手机传数据,那证明手机端是能上网的咯!用HTTP请求咯,跟你在电脑上请求是一样的,拼一个HTTP请求到服务器端就可以了吧!
      

  2.   

    可以用SoapSerializationEnvelope,把照片用Base64编码后,到服务器再转回来就可以了。
      

  3.   


    能具体说一下SoapSerializationEnvelope如何使用吗?
      

  4.   

    麻烦大侠,谁有好的解决方法啊?下载用的是soap协议,上传也得用这个,我以为上传和下载出不多,我用的方法是:
    Test t = new Test();
    t.setId("1");
    t.setContent("上传的内容");
    SoapObject request = new SoapObject(ConstantMany.ServiceNameSpace,methodName);
    request.addProperty("test", t); //t是一个对象
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.bodyOut = request;

    HttpTransport ht = new HttpTransport(ConstantMany.ServiceURL);
    ht.debug = true;
    ht.call(null, envelope);
    这样上传总是报错,不知道为什么。错误:
    java.lang.RuntimeException: Cannot serialize: test.Test@f828ed68
    at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(+88)
    at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(+239)
    at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(+77)
    at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(+36)
    at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(+141)
    at org.ksoap2.SoapEnvelope.write(+110)
    at org.ksoap2.transport.Transport.createRequestData(+40)
    at org.ksoap2.transport.HttpTransport.call(+12)
    at com.kmh.database.LoginRS.login(+106)
    at com.kmh.ui.Login$1.actionPerformed(+56)
    at com.sun.lwuit.util.EventDispatcher.fireActionSync(+24)
    at com.sun.lwuit.util.EventDispatcher.fireActionEvent(+92)
    at com.sun.lwuit.Button.fireActionEvent(+73)
    at com.sun.lwuit.Button.released(+20)
    at com.sun.lwuit.Button.pointerReleased(+4)
    at com.sun.lwuit.Form.pointerReleased(+96)
    at com.sun.lwuit.Component.pointerReleased(+10)
    at com.sun.lwuit.Display.handleEvent(+128)
    at com.sun.lwuit.Display.edtLoopImpl(+118)
    at com.sun.lwuit.Display.mainEDTLoop(+201)
    at com.sun.lwuit.RunnableWrapper.run(+245)