Android WSDL/SOAP service client

后端 未结 7 2193
北恋
北恋 2020-11-30 22:53

I have some web services that uses WSDL/SOAP for communication. Specifically, I am using PHP and Nusoap to make them. How can I use these web services on Android? I am going

7条回答
  •  广开言路
    2020-11-30 23:09

       public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Set View to register.xml
        setContentView(R.layout.register);
        session = new UserSessionManeger(getApplicationContext());     
    
        login_id= (EditText) findViewById(R.id.loginid);
        Suponser_id= (EditText) findViewById(R.id.sponserid);
        name=(EditText) findViewById(R.id.name);
        pass=(EditText) findViewById(R.id.pass);
        moblie=(EditText) findViewById(R.id.mobile);
        email= (EditText) findViewById(R.id.email);
        placment= (EditText) findViewById(R.id.placement);
        Adress= (EditText) findViewById(R.id.adress);
        State = (EditText) findViewById(R.id.state);
    
        city=(EditText) findViewById(R.id.city);
        pincopde=(EditText) findViewById(R.id.pincode);
        counntry= (EditText) findViewById(R.id.country);
    
        plantype= (EditText) findViewById(R.id.plantype);
    
    
        mRegister = (Button)findViewById(R.id.registration); 
      //  session.createUserLoginSession(info.getCustomerID(),info.getName(),info.getMobile(),info.getEmailID(),info.getAccountType());
        mRegister.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
    
    
                 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);        
    
                    request.addProperty("LoginCustomerID",login_id.getText().toString());
                    request.addProperty("SponsorID",Suponser_id.getText().toString());
                    request.addProperty("Name", name.getText().toString());
                    request.addProperty("LoginPassword",pass.getText().toString() );
                    request.addProperty("MobileNumber",smoblie=moblie.getText().toString());
                    request.addProperty("Email",email.getText().toString() );
                    request.addProperty("Placement", placment.getText().toString()); 
                    request.addProperty("address1",  Adress.getText().toString());
                    request.addProperty("StateID", State.getText().toString());
                    request.addProperty("CityName",city.getText().toString());
    
                    request.addProperty("Pincode",pincopde.getText().toString());
    
    
                    request.addProperty("CountryID",counntry.getText().toString());
                    request.addProperty("PlanType",plantype.getText().toString());
    
    
    
                    //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(SOAP_ACTION1, envelope);
    
    
                        SoapObject result = (SoapObject)envelope.getResponse();  
                        Log.e("value of result", " result"+result);
                        if(result!= null)
                        {
    
    
                            Toast.makeText(getApplicationContext(), "successfully register ", 2000).show()  ;
    
                        }
                        else {
    
                            Toast.makeText(getApplicationContext(), "Try Again..", 2000).show() ;   
                        }
    
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
    
    
    
            }
        });
        }
    
      }
    

提交回复
热议问题