Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
package com.example.newweb;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.app.Activity;

public class MainActivity extends Activity 
{
    private static final String SOAP_ACTION = "http://tempuri.org/FindName";   
    private static final String OPERATION_NAME = "FindName";
    private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
    private static final String SOAP_ADDRESS = "http://1675.vinna.in/android/Service.asmx";
    
    TextView tvData1;
    EditText edata;
    Button button;
    String studentNo;
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvData1 = (TextView)findViewById(R.id.textView1);
        button=(Button)findViewById(R.id.button1);
        button.setOnClickListener(new OnClickListener() 
        {
            public void onClick(View v) 
            {
                SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
                PropertyInfo propertyInfo=new PropertyInfo();
                propertyInfo.type = PropertyInfo.STRING_CLASS;
                
                propertyInfo.name = "eid";
                edata =(EditText)findViewById(R.id.editText1);
                studentNo=edata.getText().toString();
                request.addProperty(propertyInfo, studentNo);
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.setOutputSoapObject(request);
                HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
                try
                {                    
                    httpTransport.call(SOAP_ACTION, envelope);
                    String s=httpTransport.requestDump;
                    SoapObject response=(SoapObject)envelope.bodyIn;
                    
                    tvData1.setText(response.toString());
                }  
                catch (Exception exception)   
                {
                    tvData1.setText(exception.toString()+"Or enter number is not Available!");                    
                }
                tvData1 = (TextView)findViewById(R.id.textView1);
            }
        });
        //client = new DefaultHttpClient();            
        //new Read().execute("text");
    }
}
Posted
Updated 14-Feb-14 23:10pm
v2
Comments
Richard MacCutchan 15-Feb-14 5:11am    
Please edit your question and explain the exact problem and where it occurs.

Looks like you are doing an invalid cast somewhere in your try block.

Without knowing anything about the library you are using i would suspect
SoapObject response=(SoapObject)envelope.bodyIn;


I somewhere found this:
SoapObject result = (SoapObject) soapEnvelope.getResponse();
 
Share this answer
 
Comments
Member 10495964 17-Feb-14 2:17am    
i used that one also but am getting the same thing
can u please modfiy the code if there is any mistakes
i used internet permissions also
As I said, I know nothing about the library you are using so I will not be able to help.

Have you tried to put a breakpoint in your code just before the try block and then step through the code? This should give you some information as to which statement is really throwing the exception.

Also, put the return value in an object variable and then somehow log the type of it, something like:

Java
object response=envelope.bodyIn;
Log.d("MainActivity", response.getClass().toString());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900