Java 在Android中使用webservice

Java 在Android中使用webservice,java,c#,android,web-services,Java,C#,Android,Web Services,我需要将数据发送到用c#net编写的web服务, 如果我使用c #程序,它可以获取web服务的名称和 我想我可以使用的函数是因为它是java它不能做同样的事情 作为c#,如果有人知道如何做到这一点,那就太好了。 谢谢你的帮助 我使用httpURLConnection并编写此代码来发送和获取响应 来自连接 BufferedReader reader = null; try { URL url = new URL(uri); HttpURLConnectio

我需要将数据发送到用c#net编写的web服务, 如果我使用
c #
程序,它可以获取web服务的名称和 我想我可以使用的函数是因为它是
java
它不能做同样的事情 作为
c#
,如果有人知道如何做到这一点,那就太好了。 谢谢你的帮助

我使用
httpURLConnection
并编写此代码来发送和获取响应 来自连接

BufferedReader reader = null;

    try {
        URL url = new URL(uri);
        HttpURLConnection con = (HttpURLConnection) url.openConnection();

        StringBuilder sb = new StringBuilder();
        reader = new BufferedReader(new InputStreamReader(con.getInputStream()));

        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line + '\n');
        }
        Log.i("","here  "+sb.toString());
        return sb.toString();

    } catch (Exception e) {
        Log.i("","problem in connection");
        return null;
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
如果我没有弄错的话,C#web服务使用SOAP协议,因此您可能需要解析SOAP响应,该响应将提供有关web服务api的信息: 检查此线程: