org.ksoap2.serialization.SoapSerializationEnvelope

后端 未结 2 1731
情歌与酒
情歌与酒 2020-12-16 08:34

Can any one help me out to clear this error?

I have done all the settings... Selected the jar file in the java build path also.. my folder also in the name of libs o

相关标签:
2条回答
  • 2020-12-16 09:18
    ((Button)findViewById(R.id.btnData)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                NAMESPACE = "http://tempuri.org/";
                URL = "http://YOURURL/Service.asmx";
                SOAP_ACTION = "http://tempuri.org/SetLoginData";
                METHOD_NAME = "SetLoginData";
                EditText uname = (EditText) findViewById(R.id.editText1);
                EditText pwd = (EditText) findViewById(R.id.editText2);       
    
                String dataToSend="[{'UserID':uname.getText().toString() ,'Password':pwd.getText().toString() }]";
    
                SendData(dataToSend);
            }
        });
    }
    
    public void SendData(String data){
    
        Log.d(TAG, "SendData");
        Log.d(TAG, "URL   : "+URL);
        Log.d(TAG, "ACTION: "+SOAP_ACTION);
    
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    
        Log.d(TAG, "Create");
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        String dataToSend=data;
        Log.d(TAG, "dataToSend: "+dataToSend);
    
        PropertyInfo FromCurrency = new PropertyInfo();
        FromCurrency.setName("strInputData");
        FromCurrency.setValue(dataToSend);
        FromCurrency.setType(String.class);
        request.addProperty(FromCurrency);
    
        Log.d(TAG, "envelope");
        // Create the envelop.Envelop will be used to send the request
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    
        envelope.implicitTypes=true;
        envelope.setAddAdornments(false);
    
        envelope.setOutputSoapObject(request);
        // Says that the soap webservice is a .Net service
        envelope.dotNet = true;
    
        Log.d(TAG, "URL");
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    
        try {
            Log.d(TAG, "call");
            androidHttpTransport.call(SOAP_ACTION, envelope);
            Log.d(TAG, "call1");
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            Log.d(TAG,"response:"+ response.toString());
            TextView v = (TextView) findViewById(R.id.currency);
            v.setText("Retururn Responce" +  "= " + response.toString() ); 
        } catch (Exception e){
            e.printStackTrace();
        }
    }
    

    This webservice will take json data that's why i had passed data in json. so you have to check two three things that namespace is what, xml or json data , FromCurrency.setName("strInputData"); which is #c developer function argument name and internet permision requried.

    0 讨论(0)
  • 2020-12-16 09:28

    Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.

    0 讨论(0)
提交回复
热议问题