Android无法连接到.net Web服务

时间:2012-06-07 06:51:00

标签: android soap

我正在尝试将Web服务与我的Android应用程序连接,但在声明SoapObject时出错。请帮帮我解决!!非常感谢你。这是我的代码:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final String Soap_Action = "http://huroid.com/AndroidGetAllUser";
    final String Soap_MethodName = "AndroidGetAllUser";
    final String Soap_NameSpace = "http://huroid.com/";
    final String Soap_URL = "http://huroid.com/UserService.asmx?op=AndroidGetAllUser";

    //CallService
    try{

        SoapObject request = new SoapObject(Soap_NameSpace, Soap_Action);
    }
    catch(Exception e){
        Toast.makeText(this, "Error", Toast.LENGTH_LONG);
    }

    adpUser.notifyDataSetChanged();


}

此行发生错误:

SoapObject request = new SoapObject(Soap_NameSpace, Soap_Action);

我没有找不到方法来识别soap命名空间和方法。 :(

2 个答案:

答案 0 :(得分:0)

类型 http://huroid.com/UserService.asmx?wsdl

在任何Web浏览器中,您将显示包含方法参数和返回类型的可用方法和soap命名空间信息。

这是你要问的吗?

答案 1 :(得分:0)

您可以尝试以下格式:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

像:

    SoapObject request = new SoapObject(Soap_NameSpace, Soap_MethodName);

注意:

+ replace Soap_Action with Soap_MethodName
+ Soap_Action = Soap_Namespace + Soap_MethodName