Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have trouble log into my webservice Which SOAP based please if u can have look at it and find out the error and tell me.

username for webservice-sushanta
password-123



package com.example.dotnetlogin;

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

public class WebService {

// Namespace of the Webservice - can be found in WSDL
// private static String NAMESPACE = "http://tempuri.org/";
// Webservice URL - WSDL File location
// private static String URL = "http://namastii.co.in/Service.asmx";
// SOAP Action URI again Namespace + Web method name
// private static String SOAP_ACTION = "http://tempuri.org/GetUserDetails";


private static final String SOAP_ACTION = "http://www.namastii.co.in/Service.asmx?op=GetUserDetails";

private static final String OPERATION_NAME = "GetUserDetails";

private static final String WSDL_TARGET_NAMESPACE = "http://namastii.co.in/";

private static final String SOAP_ADDRESS = "http://namastii.co.in/Service.asmx";

public static boolean invokeLoginWS(String username, String passWD,
String webMethName) {



boolean loginStatus = false;
// Create request
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
// Property which holds input parameters
PropertyInfo userName = new PropertyInfo();
PropertyInfo password = new PropertyInfo();
// Set Username
userName.setName("username");
// Set Value
userName.setValue(username);
// Set dataType
userName.setType(String.class);
// Add the property to request object
request.addProperty(userName);
// Set Password
password.setName("password");
// Set dataType
password.setValue(passWD);
// Set dataType
password.setType(String.class);
// Add the property to request object
request.addProperty(password);
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// Set output SOAP object
envelope.setOutputSoapObject(request);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(SOAP_ADDRESS);

try {
// Invoke web service
androidHttpTransport.call(SOAP_ACTION + OPERATION_NAME, envelope);
// Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
// Assign it to boolean variable variable
loginStatus = Boolean.parseBoolean(response.toString());

} catch (Exception e) {
// Assign Error Status true in static variable 'errored'
CheckDNLoginActivity.errored = true;
e.printStackTrace();
}
// Return booleam to calling object
return loginStatus;
}
}
Posted
Updated 12-Aug-14 22:04pm
v2

1 solution

 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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