Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.net Web服务Android连接Web应用程序_C#_Android_Wordpress_Web Services - Fatal编程技术网

C# ASP.net Web服务Android连接Web应用程序

C# ASP.net Web服务Android连接Web应用程序,c#,android,wordpress,web-services,C#,Android,Wordpress,Web Services,我已将WordPress站点的MySQL数据库与C WebService连接起来 当我在LocalHost中运行Webservice并从我的站点返回值时,但当我发布Webservice并使用Android应用程序发送值并返回null时 当我更改WebService以返回Hello World时,Android应用程序将返回Hello World 我怎样才能解决这个问题 网络服务: [WebMethod] public string GetYazilar(int KategoriID)

我已将WordPress站点的MySQL数据库与C WebService连接起来

当我在LocalHost中运行Webservice并从我的站点返回值时,但当我发布Webservice并使用Android应用程序发送值并返回null时

当我更改WebService以返回Hello World时,Android应用程序将返回Hello World

我怎样才能解决这个问题

网络服务:

[WebMethod]
    public string GetYazilar(int KategoriID)
    {

        string YaziID = "";
        MySqlConnection baglanti = new MySqlConnection("Server=xx.xx.xx.xxx; Database=wordpress_e;Uid=xx;Pwd='xxx';");

        baglanti.Open();

        DataSet ds = null;
        //MySqlCommand cmd = new MySqlCommand("SELECT * FROM 1sbwt_term_taxonomy INNER JOIN 1sbwt_term_relationships ON     1sbwt_term_relationships.term_taxonomy_id = 1sbwt_term_taxonomy.term_id INNER JOIN 1sbwt_posts ON 1sbwt_term_relationships.object_id = 1sbwt_posts.ID WHERE 1sbwt_term_taxonomy.term_id = " + KategoriID + " ");

        MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM 3tkqs_term_taxonomy INNER JOIN 3tkqs_term_relationships ON 3tkqs_term_relationships.term_taxonomy_id = 3tkqs_term_taxonomy.term_id INNER JOIN 3tkqs_posts ON 3tkqs_term_relationships.object_id = 3tkqs_posts.ID WHERE 3tkqs_term_taxonomy.term_id = " + KategoriID + "", baglanti);

        ds = new DataSet();
        da.Fill(ds);

        if (ds != null && ds.Tables != null && ds.Tables.Count > 0 &&
           ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        {
            DataTable tbl = ds.Tables[0];
            for (int i = 0; i < tbl.Rows.Count; i++)
            {

                   YaziID = tbl.Rows[i]["ID"].ToString();
                    }


        }
       return YaziID;

    }
Android应用程序:

public class MainActivity extends Activity {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://swift-programming.net/WebService1.asmx";
private final String SOAP_ACTION = "http://tempuri.org/GetYazilar";
private final String METHOD_NAME = "GetYazilar";
private static String input;
private static String Result;
Button b;
TextView tv;
EditText et;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    et = (EditText) findViewById(R.id.editText1);

    tv = (TextView) findViewById(R.id.tv_result);

    b = (Button) findViewById(R.id.button1);

    b.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            if (et.getText().length() != 0 && et.getText().toString() != "") {

                input = et.getText().toString();

                AsyncCallWS task = new AsyncCallWS();

                task.execute();

            } else {
                tv.setText("Please Enter Input");
            }
        }
    });
}

public void getFahrenheit(String input) {

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    PropertyInfo celsiusPI = new PropertyInfo();

    celsiusPI.setName("Input");

    celsiusPI.setValue(input);

    celsiusPI.setType(double.class);

    request.addProperty(celsiusPI);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;

    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

        Result = response.toString();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

private class AsyncCallWS extends AsyncTask<String, Void, Void> {
    @Override
    protected Void doInBackground(String... params) {

        getFahrenheit(input);
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {

        tv.setText(Result + " :");
    }

    @Override
    protected void onPreExecute() {

        tv.setText("Loading...");
    }

    @Override
    protected void onProgressUpdate(Void... values) {

    }

}

}

这在androidProblem中被称为soap,它将返回空值,但当我更改return时,Hello World将返回Hello World.WebService在LocalHost中工作