hello all,
subrat here.im struggling with android soap which not getting any respone from
axis server.currently i want 2 authenticate the username & password.
im sending my client code.
help me, plz.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
public class TestPreference extends PreferenceActivity  {
        private static final String SOAP_ACTION 
="http://localhost:8084/webservice1/MyWebService?wsdl";;

        private static final String METHOD_NAME="validate";
        private static final String NAMESPACE ="MyWebServiceService";
        
        private static final String URL = 
"http://localhost:8084/webservice1/MyWebService";;
        private Object resultRequestSOAP = null;
                
        private static final int MENU_ID_CONNECT_TO_SERVER = Menu.FIRST;

protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                
                // Load the preferences from an XML resource
                addPreferencesFromResource(R.xml.testpreference);
}


@Override
            public boolean onCreateOptionsMenu(Menu pObjMainMenu) {
                        super.onCreateOptionsMenu(pObjMainMenu);
                        pObjMainMenu.add(1, MENU_ID_CONNECT_TO_SERVER, 1, 
"Connect to Server");
                        
                        return true;
            }
            
            public boolean onOptionsItemSelected(MenuItem pObjMenuItem) {
                        boolean lRetVal = true; // The system to process the 
event

                        switch (pObjMenuItem.getItemId()) {
                        case MENU_ID_CONNECT_TO_SERVER:
                                String lResCode = connectToServer();
                                Toast.makeText(this, lResCode, 
Toast.LENGTH_SHORT).show();
                                break;
                        default:
                                lRetVal = false;
                        }
                        return lRetVal;
            }

private String connectToServer(){
                
                String lRetVal = null;
                try{
                        //Request Body String..
                        String lStr = "Requested Body String to Server";
                        byte requestData[] = lStr.getBytes("UTF-8");
                        //Server Communication URL(Change according your server 
URL)
                                String lURLStr = 
"http://192.168.1.105:8084/webservice1/MyWebService";;
                                //Communication Processing...
                                  AndroidServiceConnection lConnection = new 
AndroidServiceConnection(lURLStr);
                              lConnection.connect();
                                
                                SoapObject request = new 
SoapObject(NAMESPACE,METHOD_NAME);
                                //SoapObject
                                request.addProperty("username", "satya");
                                request.addProperty("password", "satya");
                                SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
                                envelope.setOutputSoapObject(request);
                                AndroidHttpTransport androidHttpTransport = new 
AndroidHttpTransport(lURLStr);
                                try{
                                        //This sends a soap request and 
response will be in envelope only.

                                androidHttpTransport.call(SOAP_ACTION, 
envelope);
                                resultRequestSOAP = envelope.getResponse();
                        //      String[]results =(String[]) resultRequestSOAP;
                                BufferedReader br = new BufferedReader(new 
InputStreamReader(lConnection.openInputStream()));
                                StringBuilder sb = new StringBuilder();
                                String line;
                                while((line = br.readLine()) != null){
                                        sb.append(line);
                                        
                                }
                                br.close();
                                lConnection.disconnect();
                                //Return the response value to a toast message
                                lRetVal=(String) resultRequestSOAP;
                                lRetVal = sb.toString();
                                
}catch(Exception pEx){
                                System.out.println(pEx.toString());
                        }   
                        
                        return lRetVal;
            }catch(Exception x){
                
            }
                        return lRetVal; 
                
                        
        } 
}

Reply via email to