2017-04-06 26 views
0

私は初心者ですが、Androidのasp.net Webサービスメソッド(SignUp)を呼び出す際に問題が発生しています。私は、ブラウザからそれをしようとすると、それが正常に動作しますが、私はアンドロイドからそれを行うとき、それは私に 「Webサービスを呼び出す際に例外が発生する

にSoapFaultのようないくつかの例外を与える - のfaultcode: 『石鹸:クライアント』 faultStringの「System.Web.Services.Protocols .SoapException:サーバーがHTTPヘッダーSOAPAction:SignUp。 (System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest())の値を認識しませんでした。System.Web.Services.Protocols.SoapServerProtocol.Initialize()の システムで HttpRequestリクエスト、HttpResponseレスポンス) at System.Web.Services.Protocols.ServerProtocolFactory.Create(タイプタイプ、HttpContextコンテキスト、HttpRequest r equest、HttpResponse response、Boolean & abortProcessing) 'faultactor:' null '詳細:org.kxml2.kdom。

この

は、これは私のJava Webサービスクラス

private static String NAMESPACE = "http://tempuri.org/"; 
private static String URL = "http://192.168.0.102/MyWebService/WebService1.asmx?WSDL"; 
protected String doInBackground(String... params) { 
    String s=""; 
    String whichmethodcall = params[0]; 
    switch(whichmethodcall){ 
     case "SignUp": 
      s = signup(params); 
      break; 
     case "SignIn": 
      s = signin(params); 
      break; 
    } 
    return s; 
} 
public String signup(String[] arr){ 
    String s = ""; 
    SoapObject request = new SoapObject(NAMESPACE, arr[1]); 
    //Use this to add parameters 
    request.addProperty("cname",arr[2]); 
    request.addProperty("cemail",arr[3]); 
    request.addProperty("cpwd",arr[4]); 
    request.addProperty("caddress",arr[5]); 
    request.addProperty("cdob",arr[6]); 
    request.addProperty("caccount",arr[7]); 
    request.addProperty("cCnic",arr[8]); 
    request.addProperty("cpobox",arr[9]); 
    request.addProperty("cCity",arr[10]); 
    request.addProperty("cstatus",arr[11]); 

    //Declare the version of the SOAP request 
    SoapSerializationEnvelope envelope = new 
    SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.setOutputSoapObject(request); 
    envelope.dotNet = true; 

    try { 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     //this is the actual part that will call the webservice 
     androidHttpTransport.call(arr[0], envelope); 

     // Get the SoapResult from the envelope body. 
     // SoapObject result = (SoapObject)envelope.bodyIn; 
     // SoapObject result = (SoapObject) envelope.getResponse(); 
     if (envelope.bodyIn instanceof SoapFault) { 
      final SoapFault result = (SoapFault) envelope.bodyIn; 
      if (result != null) { 
       //Get the first property and change the label text 
        s = result.toString(); 
      } else 
       s = "No response";    
     } 
    } catch (Exception e) { 
     e.printStackTrace(); 
     s=e.getMessage().toString(); 
    } 
    return s; 
} 

である私のJavaの申し込みクラス

String SOAP_ACTION1 = "http://tempuri.org/SignUp"; 
String METHOD_NAME1 = "SignUp"; 
btn = (Button)findViewById(R.id.btn_signup); 
    btn.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      new WebService().execute(METHOD_NAME1,SOAP_ACTION1,txt_name.getText().toString(),     txt_email.getText().toString(),txt_password.getText().toString(), 
        txt_address.getText().toString(), 
        txt_dob.getText().toString(), 
        txt_account.getText().toString(),      
       txt_cnic.getText().toString(),txt_pobox.getText().toString(),      
       txt_city.getText().toString(),txt_status.getText().toString()); 

であり、これは私のasp.netのWebサービスメソッド

public string SignUp(string cname, string caddress, string cdob, long caccount, long cCnic, int cpobox, string cCity, string cstatus,string cemail, string cpass) 
    { 
     bool check = ConnectDB();   // Opens the Connection to Insert The new User 
     string msg = ""; 
     //DateTime dob = DateTime.ParseExact(cdob, "dd/mm/yyyy", null); 
     string query = "INSERT INTO Customers values('" + cname + "','" + caddress + "','" + cdob + "','" + caccount + "','" + cCnic + "','" + cpobox + "','" + cCity + "','" + cstatus + "','"+ cemail + "','"+ cpass + "')"; 
     SqlCommand comm = new SqlCommand(query, con); 
     try{ 
      if (check == true){ 
       if (comm.ExecuteNonQuery() > 0) 
        msg = "you've signed up !"; 
       else 
        msg = "sign up error";     
      } 
      else    
       msg = "Database not Connected";    
     }catch (SqlException ex){ 
      msg = ex.Message.ToString(); 
      con.Close(); 
     }finally{ 
      con.Close(); 
     } 
     return msg; 
    } 
+0

ksoap2を使用しているようです。トランスポートには、デバッグに非常に役立つ2つのフィールドrequestDumpとresponseDumpがあります。最終節の –

+0

に次のようなものを追加できますか?(transport.requestDump!= null){ Log.d(getClass()。getName()、methodId + "transport.requestDump); } else { Log.d(getClass()。getName()、 "no method dump" + methodId); (transport.responseDump!= null){ Log.d(getClass } else { Log.d(getClass()。getName()、 "+ methodId"に対する応答ダンプなし); } –

答えて

0

あなたができることです試してみてください

SoapObjectの代わりに要求=新しいSoapObject(NAMESPACE、arr [1]); use

SoapObject request = new SoapObject(NAMESPACE、arr [0]);

soapオブジェクトでは、http://を使わずにメソッド名だけを渡す必要があります。

+0

arr [2]にはcustnameが含まれています。これでメソッド名を渡すはずです。いいえ? –

+0

私の解決策を編集しました。使用arr [0] –

+0

ええ、ちょうど見た..何も変わりませんまだ同じ例外を取得しています –

関連する問題