AWS iam create new user returning html instead of xml response android -
i creating new user through android app programatically using amazon web-service. here code(asynctask):
private class s3registernewuser extends asynctask<string, void, string> { progressdialog dialog; string email; public s3registernewuser(string email) { // todo auto-generated constructor stub this.email=email; } protected void onpreexecute() { dialog = new progressdialog(s3uploaderactivity.this); dialog.setmessage(s3uploaderactivity.this .getstring(r.string.plswait)); dialog.setcancelable(false); dialog.show(); } protected string doinbackground(string ...strings) { seek { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(constants.register); //url[0] string result = ""; boolean result_recvd = false; boolean ifallset = false; // sparser = new parsingclass(); seek { // add together info list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("username",email)); namevaluepairs.add(new basicnamevaluepair("path","/")); namevaluepairs.add(new basicnamevaluepair("version","2010-05-08")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request /*httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); binddatatolisting(is);*/ httpresponse resp = httpclient.execute(httppost); httpentity ent = resp.getentity(); ist = ent.getcontent(); result = getstringfrominputstream(ist); if(!result.contains("result")) { toast.maketext(s3uploaderactivity.this, "no connection or info not received server", toast.length_short).show(); //result = "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml><result>0</result><message>"+constants.noconnection+"</message></xml>"; result_recvd = false; }else{ /** result has been received server contains atleast 'result' tag * helps know if info beingness fetched server or not.*/ result_recvd = true; } // ifallset = binddatatolisting(result, result_recvd); if(!result.contains("result")){ toast.maketext(s3uploaderactivity.this, "no connection or info not received server", toast.length_short).show(); } //result = convertstreamtostring(is); log.e("-- parseresultxml: ", ""+result); } grab (clientprotocolexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } } grab (amazonclientexception ace) { system.out.println("caught amazonclientexception, " + "which means client encountered " + "an internal error while trying communicate" + " s3, " + "such not beingness able access network."); system.out.println("error message: " + ace.getmessage()); } homecoming null; } protected void onpostexecute(string file_url) { dialog.dismiss(); } } /** convert input stream string * @param -supply input stream variable here */ private string getstringfrominputstream(inputstream is) { stringbuilder sb = new stringbuilder(); string line; seek { br = new bufferedreader(new inputstreamreader(is)); while ((line = br.readline()) != null) { sb.append(line); } } grab (ioexception e) { e.printstacktrace(); } { if (br != null ) { seek { br.close(); } grab (ioexception e) { e.printstacktrace(); } } } homecoming sb.tostring(); }
constants.register="https://iam.amazonaws.com/"
i next iam documentation.but instead of recieving xml result according documentation recieving html responses below:
06-20 15:05:55.856: e/-- parseresultxml:(665): <!doctype html><!--[if lt ie 7]><html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7 lang-en lang-en_us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"><![endif]--><!--[if ie 7]><html class="no-js lt-ie10 lt-ie9 lt-ie8 lang-en lang-en_us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"><![endif]--><!--[if ie 8]><html class="no-js lt-ie10 lt-ie9 lang-en lang-en_us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"><![endif]--><!--[if ie 9]><html class="no-js lt-ie10 lang-en lang-en_us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"><![endif]--><!--[if gt ie 9]><!--><html class="no-js lang-en lang-en_us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> <!--<![endif]--> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="dns-prefetch" href="//a1.awsstatic.com" /> <link rel="dns-prefetch" href="//a0.awsstatic.com" /> <link rel="dns-prefetch" href="//d0.awsstatic.com" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>aws identity , access management (iam) in cloud</title> <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> <link rel="icon" type="image/ico" href="//a1.awsstatic.com/images/site/favicon.ico" /> <link rel="shortcut icon" type="image/ico" href="//a1.awsstatic.com/images/site/favicon.ico" /> <link rel="apple-touch-icon" sizes="57x57" href="//a1.awsstatic.com/images/site/touch-icon-iphone-114-precomposed.png" /> <link rel="apple-touch-icon" sizes="72x72" href="//a1.awsstatic.com/images/site/touch-icon-ipad-144-precomposed.png" /> <link rel="apple-touch-icon" sizes="114x114" href="//a1.awsstatic.com/images/site/touch-icon-iphone-114-precomposed.png" /> <link rel="apple-touch-icon" sizes="144x144" href="//a1.awsstatic.com/images/site/touch-icon-ipad-144-precomposed.png" /> <meta property="og:title" content="aws identity , access management (iam) in cloud" /> <meta property="og:type" content="company" /> <meta property="og:url" content="//aws.amazon.com/iam/" /> <meta property="og:image" content="//a1.awsstatic.com/images/open-graph/opengraph.gif" /> <meta property="og:site_name" content="amazon web services, inc." /> <meta name="google-site-verification" content="xhghg81ulgiw-3eylgcf48sg28tbw5eh0bnuhgo_dru" /> <meta name="msvalidate.01" content="6f92e52a288e266e30c2797ecb5fccf3" /> <link rel="canonical" href="http://aws.amazon.com/iam/" /> <link rel="alternate" href="//aws.amazon.com/de/iam/" hreflang="de-de" /> <link rel="alternate" href="//aws.amazon.com/es/iam/" hreflang="es-es" /> <link rel="alternate" href="//aws.amazon.com/fr/iam/" hreflang="fr-fr" /> <link rel="alternate" href="//aws.amazon.com/jp/iam/" hreflang="ja-jp" /> <link rel="alternate" href="//aws.amazon.com/pt/iam/" hreflang="pt-br" /> <link rel="alternate" href="//aws.amazon.com/ko/iam/" hreflang="ko-kr" /> <link rel="alternate" href="//aws.amazon.com/cn/iam/" hreflang="zh-cn" /> <link rel="stylesheet" href="//a1.awsstatic.com/css/35/style.css" /> <!--[if lt ie 9]> <script src="//a1.awsstatic.com/js/35/jquery.1.9.js"></script> <![endif]--> <!--[if (gte ie 9) | (!ie)]><!--> <script src="//a1.awsstatic.com/js/35/jquery.2.0.js"></script> <!--<![endif]--> <script src="//a1.awsstatic.com/js/35/aws-target-mediator.js"></script> <script>aws.targetmediator.init();</script> <script src="//a1.awsstatic.com/js/35/modernizr.js"></script> <script> var require = { baseurl: "//a1.awsstatic.com/js/35/", paths: { "jquery": "jquery-amd" }, deps: ["scripts"], shim: { "scripts": ["jquery"], "forms": ["jquery"], "pricing-table": ["jquery"
if doing wrong or sending wrong parameters code must throw exception or stop.but why returning html file??what wrong doing here??
update
the aws sdk android seems bit lacking on getting started front end indeed - seems designed similar aws sdk java though (naturally):
there, every aws service has own service specific client, amazonidentitymanagementclient utilize case. given absent, seems aws sdk android doesn't back upwards iam directly, you'd need resort iam query api indeed (as mentioned on page), i.e. you'll need implement signing [of] aws api requests yourself, unfortunately.
initial answeraws services in general , amazon iam in particular require signing [of] aws api requests, i.e. cannot phone call api endpoint, rather need aws security credentials generate digital signature each request before submitting api.
the request signing process bit complex though , varies between aws services, i'd highly recommend utilize aws sdk android instead, heavy lifting - applies other complexities in dealing aws btw., if can conceptually, i'd never utilize aws without sdk if there isn't specific reason (e.g. beingness on platform not supported 1 of many offical aws sdks yet).
android xml amazon-web-services amazon-s3 amazon-iam
No comments:
Post a Comment