专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Android

Android中调用Webservice是出错,大侠们知道错在哪里吗?该怎么处理

发布时间:2010-05-30 10:55:48 文章来源:www.iduyao.cn 采编人员:星星草
Android中调用Webservice是出错,大侠们知道错在哪里吗?
WSUtils类代码:
Java code

package com.dai.hellows;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.MarshalBase64;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

public class WSUtils {

    public static String getMessage(){
        String message="";
        //命名空间
        String namespace="http://tempuri.org/";
        //请求URL
        String serviceURL="http://www.zhichengtz.com/WebService.asmx";
        //要调用的方法名
        String methodName="HelloWorld";
        
        SoapObject request=new SoapObject(namespace,methodName);
        SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.bodyOut=request;
        (new MarshalBase64()).register(envelope);
        
        HttpTransportSE ht=new HttpTransportSE(serviceURL);
        ht.debug=true;
        try {
            ht.call("http://tempuri.org/HelloWorld", envelope);
            if(envelope.getResponse()!=null){
                message=envelope.bodyIn.toString();
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        return message;
    }
    
    
}




HelloWSActivity类代码:
Java code

package com.dai.hellows;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloWSActivity extends Activity {
    
    private TextView helloTV;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        helloTV=(TextView)findViewById(R.id.helloTV);
        String message=WSUtils.getMessage();
        System.out.println("message="+message);
        helloTV.setText(message);
    }
}





------解决方案--------------------
这个不是你的错误吧,是服务器端的错误,C:WINDOWSTEMPzirsksq.0.cs 服务器端没有这个文件
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: