0

我是学生和新的 android 我有一个 Web 服务(WFC C#),当我在 Visual Winform 中测试时它没问题.. 我的 android 代码:

    String NAMESPACE="http://tempuri.org/";
    String METHOD_NAME="Hello"; // method public string Hello() [WCF]
    String SOAP_ACTIONS=NAMESPACE+"/"+METHOD_NAME;
    String URL="http://localhost:8732/BookInformationHost/BookService/"; // host Service 
    SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet=true;
    envelope.encodingStyle=SoapSerializationEnvelope.ENC;
    envelope.setOutputSoapObject(request);
    HttpTransportSE transp=new HttpTransportSE(URL);
    try
    {
        Toast.makeText(getApplicationContext(), "Try 1", Toast.LENGTH_SHORT).show();
        transp.call(SOAP_ACTIONS, envelope);
        Toast.makeText(getApplicationContext(), "Try 2", Toast.LENGTH_SHORT).show();
        Object result=(Object)envelope;
        Toast.makeText(getApplicationContext(), result.toString(), Toast.LENGTH_SHORT).show();

    }catch(Exception ex)
    {
        Toast.makeText(getApplicationContext(), "Hello_Error", Toast.LENGTH_SHORT).show();
    } 

吐司秀(“Try 1”)和“Hello_Error”。那么我需要做什么才能从 Webservice 上的函数 String 获取 String .. 非常感谢!!!!!!

4

1 回答 1

0
String URL="http://localhost:8732/BookInformationHost/BookService/"; // host Service 

Android 不明白,localhost所以要么 put10.0.2.2要么你系统的 IP Address。然后再试一次..同时发布异常日志你从中得到什么。

于 2012-06-18T10:24:58.117 回答