3

Android から .asmx Web サービスを呼び出そうとしています。以下に私のコードを示します。別の Web サービスで使用すると機能しますが、使用する必要があるサービスでは機能しません。問題は「java.io.IOException:HTTP request failed, HTTP status: 500」例外です。まず、問題はWebサービス側にあると思います。ただし、Devexpress と .NET を使用して到達しようとすると機能します。

"contentType: "application/json; を削除すると、Devexpress から同じエラーが発生しようとしました。charset=utf-8"," 行。

注: Web サービス定義にエラーはありません。

プライベート クラス KullaniciServiceAsync は AsyncTask を拡張します {

    protected void onPreExecute(){
        Toast.makeText(getApplicationContext(), "Kullanici Bilgileri Alınıyor...", Toast.LENGTH_SHORT).show();
    }
    @Override
    protected KullaniciBilgisiGetir doInBackground(String... Str) {
        try {
            //ArrayList<HeaderProperty> headerProperty = new ArrayList<HeaderProperty>();  
            //headerProperty.add(new HeaderProperty("Content-Type", "application/json; charset=utf-8")); 
            k = new KullaniciBilgisiGetir();    
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            request.addProperty("UserId","1234567890");
            request.addProperty("Password",Pass);
            request.addProperty("Kod",Kod);
            request.addProperty("Sifre",Sifre);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            Log.e("Request",request.toString());
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.debug = true;
            try{
                 androidHttpTransport.call(SOAP_ACTION, envelope);
                 SoapObject response = (SoapObject) envelope.getResponse();
                 if (response.hasProperty("KResult")) {
                    if (response.getPropertyAsString("KResult") == null) {
                      k.setKullaniciRespond(null);
                    } else {
                      k.setKullaniciRespond(response.getPropertyAsString("KResult"));
                    }
                 }

             }catch(Exception e){
                 Log.e("httpTRYCATCH", e.toString());
             }
        } catch (Exception e) {
          Log.e("ilkTRY",e.toString());
        }              
        return k;
    }

    protected void onPostExecute(KullaniciBilgisiGetir e){
        txt1.setText("ResponseText   ->" + e.getKullaniciRespond());
        //txt2.setText("bu "+e.getResponse());
        //txt3.setText("Count "+count);
    }

}
4

2 に答える 2