0

Visual Studio を介して、Android ユーザーからローカル ホストで実行されている C# Web サービスにログイン資格情報を送信しようとしています。SOAP 通信に KSOAP2 を使用しており、ログイン情報を Web サービスに送信して UI に出力したいと考えていました。私はそれを行うために AsyncTask を使用していますが、Web サービスから情報を取得して Android UI に出力することができませんでした。

私が間違っていたところを誰か助けてもらえますか?????

public class MainActivity extends Activity {

    EditText un,pw;
    TextView tv;
    Button test;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button test=(Button) findViewById(R.id.login);
        un = (EditText) findViewById(R.id.et_un);
        pw = (EditText) findViewById(R.id.et_pw);


            test.setOnClickListener(new View.OnClickListener(){

                @Override
                public void onClick(View v) {
                    FileAsync fleasyn= new FileAsync(null);
                    fleasyn.execute();
                    } 
                }); 
 }
}



class FileAsync extends AsyncTask<String, String, char[]> {
   public FileAsync(String quotes) 
{


}


private char[] resultstring;
private TextView tv;

@Override
protected void onProgressUpdate(String... progress) {


}

protected void onPostExecute(String unused) {
    tv.setText("Status:"+resultstring);
                System.out.println(resultstring);
}


@Override
protected char[] doInBackground(String... params) {

    final String NAMESPACE = "http://sparking.org/login";
    final String METHOD_NAME = "login";
    final String SOAP_ACTION = "http://sparking.org/login";
    final String URL = "http://localhost:63734/service.asmx";

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE transport = new HttpTransportSE(URL);
    try {
    transport.call(SOAP_ACTION, envelope);
    SoapPrimitive resultstring = (SoapPrimitive)envelope.getResponse();

}

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

}

エラーメッセージ:

04-30 04:46:14.689: I/System.out(2453): waiting for debugger to settle...
04-30 04:46:14.885: I/System.out(2453): waiting for debugger to settle...
04-30 04:46:15.086: I/System.out(2453): debugger has settled (1399)
04-30 04:49:00.905: W/System.err(2453): java.net.SocketException: socket failed: EACCES (Permission denied)
04-30 04:49:00.925: W/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:583)
04-30 04:49:00.935: W/System.err(2453):     at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
04-30 04:49:00.945: W/System.err(2453):     at java.net.Socket.checkOpenAndCreate(Socket.java:663)
04-30 04:49:00.955: W/System.err(2453):     at java.net.Socket.connect(Socket.java:807)
04-30 04:49:00.975: W/System.err(2453):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
04-30 04:49:00.975: W/System.err(2453):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
04-30 04:49:01.035: W/System.err(2453):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
04-30 04:49:01.075: W/System.err(2453):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
04-30 04:49:01.155: W/System.err(2453):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
04-30 04:49:01.166: W/System.err(2453):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
04-30 04:49:01.185: W/System.err(2453):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
04-30 04:49:01.185: W/System.err(2453):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
04-30 04:49:01.205: W/System.err(2453):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
04-30 04:49:01.215: W/System.err(2453):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
04-30 04:49:01.225: W/System.err(2453):     at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:46)
04-30 04:49:01.245: W/System.err(2453):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:68)
04-30 04:49:01.255: W/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:171)
04-30 04:49:01.265: W/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:1)
04-30 04:49:01.275: W/System.err(2453):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-30 04:49:01.285: W/System.err(2453):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-30 04:49:01.305: W/System.err(2453):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-30 04:49:01.325: W/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-30 04:49:01.345: W/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-30 04:49:01.345: W/System.err(2453):     at java.lang.Thread.run(Thread.java:856)
04-30 04:49:01.365: W/System.err(2453): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
04-30 04:49:01.545: W/System.err(2453):     at libcore.io.Posix.socket(Native Method)
04-30 04:49:01.758: W/System.err(2453):     at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
04-30 04:49:01.765: W/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:568)
04-30 04:49:01.777: W/System.err(2453):     ... 23 more
04-30 04:50:13.456: W/System.err(2453): java.net.SocketException: socket failed: EACCES (Permission denied)
04-30 04:50:13.465: W/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:583)
04-30 04:50:13.476: W/System.err(2453):     at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
04-30 04:50:13.485: W/System.err(2453):     at java.net.Socket.checkOpenAndCreate(Socket.java:663)
04-30 04:50:13.496: W/System.err(2453):     at java.net.Socket.connect(Socket.java:807)
04-30 04:50:13.505: W/System.err(2453):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
04-30 04:50:13.517: W/System.err(2453):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
04-30 04:50:13.525: W/System.err(2453):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
04-30 04:50:13.545: W/System.err(2453):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
04-30 04:50:13.555: W/System.err(2453):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
04-30 04:50:13.575: W/System.err(2453):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
04-30 04:50:13.585: W/System.err(2453):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
04-30 04:50:13.605: W/System.err(2453):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
04-30 04:50:13.615: W/System.err(2453):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
04-30 04:50:13.625: W/System.err(2453):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
04-30 04:50:13.635: W/System.err(2453):     at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:46)
04-30 04:50:13.655: W/System.err(2453):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:68)
04-30 04:50:13.665: W/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:171)
04-30 04:50:13.685: W/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:1)
04-30 04:50:13.715: W/System.err(2453):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-30 04:50:13.776: W/System.err(2453):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-30 04:50:13.845: W/System.err(2453):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-30 04:50:13.855: W/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-30 04:50:13.875: W/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-30 04:50:13.875: W/System.err(2453):     at java.lang.Thread.run(Thread.java:856)
04-30 04:50:13.885: W/System.err(2453): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
04-30 04:50:13.915: W/System.err(2453):     at libcore.io.Posix.socket(Native Method)
04-30 04:50:13.925: W/System.err(2453):     at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
04-30 04:50:13.945: W/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:568)
04-30 04:50:13.965: W/System.err(2453):     ... 23 more
4

3 に答える 3

1

まず、これらの変数を割り当てる必要があります。

`final String NAMESPACE = "http://xyz.org/";`
`final String METHOD_NAME="";`
`final String SOAP_ACTION="";`
`final String URL = "http://localhost:63734/mywbservice.asmx";**strong text**`

METHOD_NAME と SOAP_ACTION を空にすることはできません。プロジェクトに必要な値は次のとおりです。

<SOAP_ACTION="http://spartansparking.org/login";>
<METHOD_NAME="login";>
<NAMESPACE="http://spartansparking.org/";>
<URL = "http://localhost:63734/parkingservice.asmx";>

WebService .NET を呼び出すために、実際に AsyncTask を使用する必要はありません。ユーザーメインスレッドを使用できます。

于 2013-04-30T04:14:30.513 に答える
0

エミュレーターとローカル ホストで作業している場合は、10.0.2.2 をローカル ホストとして使用してみてください: set URL="http://10.0.2.2/parkingservice.asmx";>

于 2013-04-30T04:28:09.150 に答える