如何通过ssl连接从android设备获得使用windows身份验证的web服务?
我在某个位置托管了一个Web服务。现在我有了一个android应用程序,它必须连接到该服务。我目前正在使用ksoap2连接到th web服务,这很好。我还通过找到的一些类通过SSL进行连接 web服务使用windows身份验证时出现的问题,尽管我做出了努力,但无法获得身份验证,以下是我的代码:如何通过ssl连接从android设备获得使用windows身份验证的web服务?,android,web-services,ssl,windows-authentication,Android,Web Services,Ssl,Windows Authentication,我在某个位置托管了一个Web服务。现在我有了一个android应用程序,它必须连接到该服务。我目前正在使用ksoap2连接到th web服务,这很好。我还通过找到的一些类通过SSL进行连接 web服务使用windows身份验证时出现的问题,尽管我做出了努力,但无法获得身份验证,以下是我的代码: public class Login_Soap { public final String SOAP_ACTION = "http://www.service.com/AgentLogin";
public class Login_Soap
{
public final String SOAP_ACTION = "http://www.service.com/AgentLogin";
public final String OPERATION_NAME = "AgentLogin";
public final String WSDL_TARGET_NAMESPACE = "http://www.service.com/";
public final String SOAP_ADDRESS = "https://service/Intergration.asmx";
DefaultHttpClient httpclient;
public Login_Soap()
{
//Constructor
}//end Login_Soap()
public String Call(String Username, String Password)
{
Log.d("LoginSoap", "Entered");
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
request.addProperty("Username", Username);//object to pass to web service
request.addProperty("Password", Password);//object to pass to web service
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.dotNet = true;
envelope.implicitTypes= true;
envelope.setOutputSoapObject(request);
allowAllSSL();//for going through SSL
httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register(AuthPolicy.NTLM, new NTLMSchemeFactory());
httpclient.getCredentialsProvider().setCredentials(new AuthScope("https://service/Intergration.asmx", 8080),
new NTCredentials("username", "Password", "workstation", "domain"));
HttpConnectionParams.setConnectionTimeout(httpclient.getParams(), 5000);
NtlmTransport httpTransport = new NtlmTransport();
httpTransport.setCredentials(SOAP_ADDRESS, "username", "Password", "workstation", "domain");
httpTransport.debug = true;
Object response=null;
try
{
Log.d("LoginSoap", "in try");
httpTransport.call(SOAP_ACTION, envelope);
Log.d("About to login","Trying");
response = envelope.getResponse();
Log.d("SendingHttp", httpTransport.requestDump);
Log.d("receivinghttp", httpTransport.responseDump);
Log.d("Soap", response.toString());
}//end try
catch (Exception exception)
{
Log.d("ExceptionDump", httpTransport.requestDump);
Log.d("ExceptionResponse", response.toString());
}//end catch
return response.toString();
}//end Call
如何在android上使用windows身份验证?您有解决方案吗?我也面临同样的问题。@monish kamble不幸的是,我还没有找到解决这个问题的方法。我的项目被定义了这个需求的范围。我的团队能够在服务器端使用JNDI来完成它。我不知道背后的确切逻辑。这是在服务器端处理的,从android我只是传递用户名,密码。