Hi, the ntlm problem from the services provider. They fix the problem but now I take this massage and never connect :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>You are not authorized to view this page</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana } H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color: red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> <h1>You are not authorized to view this page</h1> You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept. <hr> <p>Please try the following:</p> <ul> <li>Contact the Web site administrator if you believe you should be able to view this directory or page.</li> <li>Click the <a href="javascript:location.reload()">Refresh</a> button to try again with different credentials.</li> </ul> <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2> <hr> <p>Technical Information (for support personnel)</p> <ul> <li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>401</b>.</li> <li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr), and search for topics titled <b>About Security</b>, <b>Authentication</b>, and <b>About Custom Error Messages</b>.</li> </ul> </TD></TR></TABLE></BODY></HTML> Thanks Filiz Gökçe On 1 December 2010 12:35, Oleg Kalnichevski <[email protected]> wrote: > On Wed, 2010-12-01 at 10:49 +0200, Filiz Gökçe wrote: > > Hi, > > I have a service that gives xml data. But it didn't connect, I reseach > all > > of documents on internet and you site, I develop my code on you site > exampl= > > e > > > > I give the example of my code : > > > > protected InputStream getInputStream() { > > try { > > SchemeRegistry schemeRegistry =3D new SchemeRegistry(); > > > > // http scheme > > schemeRegistry.register(new Scheme("http", > > PlainSocketFactory. > > getSocketFactory(), 80)); > > // https scheme > > schemeRegistry.register(new Scheme("https", new > EasySSLSocketFactory()= > > , > > 443)); > > > > params =3D new BasicHttpParams(); > > params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 1); > > params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new > > ConnPerRouteBean(1)); > > params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); > > HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); > > HttpProtocolParams.setContentCharset(params, "utf8"); > > > > // ignore that the ssl cert is self signed > > CredentialsProvider credentialsProvider =3D new > > BasicCredentialsProvider(); > > credentialsProvider.setCredentials(new AuthScope(" > www.yemeksepeti.com"= > > , > > AuthScope.ANY_PORT), > > new UsernamePasswordCredentials("cs_basari", "bas0102ari")); > > clientConnectionManager =3D new ThreadSafeClientConnManager(params, > > schemeRegistry); > > > > context =3D new BasicHttpContext(); > > context.setAttribute("http.auth.credentials-provider", > > credentialsProvider); > > > > > System.out.println("----------------yemeksepetiandroid---------------------= > > -- > > > http://www.yemeksepeti.com/YemeksepetiCatalogWebService/CatalogExportMobile= > > .asmx/Mobile_GetCities?"); > > > > > > DefaultHttpClient client =3D new > > DefaultHttpClient(clientConnectionManager, params); > > HttpGet get =3D new HttpGet(" > > > http://www.yemeksepeti.com/YemeksepetiCatalogWebService/CatalogExportMobile= > > .asmx/Mobile_GetCities?"); > > > > HttpResponse response =3D client.execute(get, context); > > HttpEntity entity =3D response.getEntity(); > > System.out.println(response.getStatusLine()); > > if (entity !=3D null) { > > System.out.println("Response content length: " + > > entity.getContentLength()); > > } > > return entity.getContent(); > > } catch (IOException e) { > > throw new RuntimeException(e); > > } > > } > > static class PreemptiveAuth implements HttpRequestInterceptor { > > > > public void process( > > final HttpRequest request, > > final HttpContext context) throws HttpException, > IOExceptio= > > n > > { > > > > AuthState authState =3D (AuthState) context.getAttribute( > > ClientContext.TARGET_AUTH_STATE); > > > > // If no auth scheme avaialble yet, try to initialize it > > preemptively > > if (authState.getAuthScheme() =3D=3D null) { > > AuthScheme authScheme =3D (AuthScheme) > context.getAttribute= > > ( > > "preemptive-auth"); > > CredentialsProvider credsProvider =3D > (CredentialsProvider) > > context.getAttribute( > > ClientContext.CREDS_PROVIDER); > > HttpHost targetHost =3D (HttpHost) context.getAttribute( > > ExecutionContext.HTTP_TARGET_HOST); > > if (authScheme !=3D null) { > > Credentials creds =3D credsProvider.getCredentials( > > new AuthScope( > > targetHost.getHostName(), > > targetHost.getPort())); > > if (creds =3D=3D null) { > > throw new HttpException("No credentials for > > preemptive authentication"); > > } > > authState.setAuthScheme(authScheme); > > authState.setCredentials(creds); > > } > > } > > > > } > > > > > > } > > > > > > > > And it gives these error log: > > > > 11-30 16:41:08.902: WARN/etAuthenticationHandler(629): Authentication > schem= > > e > > ntlm not supported > > 11-30 16:41:08.932: WARN/DefaultRequestDirector(629): Authentication > error: > > Unable to respond to any of these challenges: {ntlm=3DWWW-Authenticate: > NTL= > > M, > > negotiate=3DWWW-Authenticate: Negotiate} > > 11-30 16:41:08.952: INFO/System.out(629): HTTP/1.1 401 Unauthorized > > 11-30 16:41:08.952: INFO/System.out(629): Response content length: 1656 > > > The version of HttpClient shipped with Android does not support NTLM > authentication out of the box > > You can either following this guide [1] to add support for NTLM to the > existing version of HttpClient or upgrade to HttpClient 4.1-beta1 which > supports NTLM out of the box. > > Hope this helps > > Oleg > > [1] http://hc.apache.org/httpcomponents-client-ga/ntlm.html > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
