0

您好,我正在尝试从 android 调用 Web 服务。代码工作正常,没有错误,但我没有得到输出。我是安卓新手。请帮帮我。

整个教程在这里....

有三个按钮clear button做得很好,但两个都convert to celsius不起作用convert to fahrenheit。实际上在 try 块中它们都有语句

SoapObject result = (SoapObject)envelope.bodyIn;

我猜在这一行应用程序卡住了,因为我将生成器消息放在它提示的每个语句之后,但在此语句之后它没有。请告诉我是什么问题,我真的很担心..

4

1 回答 1

0

尝试使用此类调用 Web 服务:

public class WSRequest {

    public HttpTransportSE androidHttpTransport;
    public SoapSerializationEnvelope envelope; 
    public String methodName;
    public SoapObject request;

    public WSRequest(String methodName)
    {
        this.methodName = methodName;
        this.request = new SoapObject(SRWebServer.NAMESPACE, methodName);
        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.implicitTypes = true;
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        androidHttpTransport = new HttpTransportSE(SRWebServer.URL);
    }

    public void RegisterMarshal()
    {
        MarshalBase64 marshal = new MarshalBase64();
        marshal.register(envelope);
    }

    public SoapObject Send() throws IOException, XmlPullParserException 
    {
        System.setProperty("http.keepAlive", "false");
        new MarshalDate().register(envelope);
        this.androidHttpTransport.call(SRWebServer.NAMESPACE + this.methodName, envelope);
        return (SoapObject) this.envelope.getResponse();
    }



    public void AddProperties(String name, Object value)
    {
        this.request.addProperty(name, value);

    }
        // 

}

并使用这种方式:

WSRequest request =  new WSRequest("method name here");
request.addProperties("property1Name",property1);
request.Send();

requestSend()将返回一个包含从 Web 服务接收到的对象的 SoapObject。

于 2013-01-24T09:38:06.057 回答