I have the following WCF webservice
I want to consume it in android client.My code so far is
public class SOAP_TestActivity extends Activity {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://50.19.226.15/Office365Admin/MsOnline.svc";
private final String SOAP_ACTION = "http://tempuri.org/IMsOnline/ValidateUser";
private final String METHOD_NAME = "ValidateUser";
private final String user_id= "khurram@office365trial.com.au";
private final String password= "friday@123";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button signin = (Button) findViewById(R.id.regsubmitbtn);
signin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
boolean auth=doLogin();
System.out.println(auth);
Toast.makeText(getApplicationContext(), String.valueOf(auth), Toast.LENGTH_SHORT).show();
}
});
}
private boolean doLogin() {
boolean result=false;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("userid", user_id);
request.addProperty("password",password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
Log.d("myApp", request.toString());
System.out.println(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive soapPrimitiveResults = (SoapPrimitive)envelope.getResponse();
Log.d("myApp", soapPrimitiveResults.toString());
System.out.println("myApp" +soapPrimitiveResults);
if(soapPrimitiveResults.toString().equalsIgnoreCase("true"))
{
result = true;
}
}catch(SocketException ex)
{
Log.e("Error : " , "Error on soapPrimitiveData() " + ex.getMessage());
ex.printStackTrace();
}
catch (Exception e) {
Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage());
e.printStackTrace();
}
return result;
}
}
This code works without any exception but I am not able to login into my application as the method ValidateUser
always return false.This same webservice has been consumed in Windows Phone and is working without any problem.Also the username and password are 100% correct.
Looks like there is some problem in the NAMESPACE
and SOAP_ACTION
. I have gone through some tutorials and they say that the SOAP_ACTION
is made by concatenating NAMESPACE
with METHOD_NAME
.So if I follow the tutorials my SOAP_ACTION
should be
"http://tempuri.org/ValidateUser"
but the SOAP_ACTION
given in the WSDL link
for the method "ValidateUser"
is
"http://tempuri.org/IMsOnline/ValidateUser"
.
I am new to WCF Webservices and SOAP.Can anybody please tell me how to implement the methods given in WSDL Document(link is at the top)
.
Looks like missing something important but don't know what.