java - android client cannot do a post action to a wcf json service -
java - android client cannot do a post action to a wcf json service -
the problem cannot phone call wcf json service android client. able phone call wcf json service c# client , fiddler, same exact request parameter.
everytime seek calling service android client error: "http/1.1 405 method not allowed."
i've done research both here , on google android developer group, still cannot code working correctly.
i don't know problem more, if could, please help.
thank in advance.
// #################################### // android client // #################################### servicerequest servicerequest = new servicerequest(); servicerequest.setaccesskey("ee404d54-ea45-421a-9633-1ea35c0c211e"); servicerequest.setfbaccesstoken("2227470867|2.aqaeyiajuxtmsrqi.3600.1310490000.0-757629911|mz1jfutonif0y84aeutxcwgypzi"); servicerequest.settype("c"); servicerequest.setplatform("a"); // request.setdata(encodeddata); // serialize gson gson = new gson(); string info = gson.tojson(servicerequest); seek { httpclient httpclient = new defaulthttpclient(); httppost request = new httppost("http://simpleapp.dyndns.org:81/voicebook"); stringentity entity = new stringentity(data, "utf-8"); entity.setcontenttype("application/json"); entity.setcontentencoding("utf-8"); request.setentity(entity); request.setheader("content-type", "application/json"); httpresponse response = httpclient.execute(request); textview tvname = (textview) findviewbyid(r.id.tvname); tvname.settext(string.valueof(response.getstatusline())); } grab (unsupportedencodingexception e) { textview tvname = (textview) findviewbyid(r.id.tvname); tvname.settext(e.getmessage()); } grab (clientprotocolexception e) { textview tvname = (textview) findviewbyid(r.id.tvname); tvname.settext(e.getmessage()); } grab (ioexception e) { textview tvname = (textview) findviewbyid(r.id.tvname); tvname.settext(e.getmessage()); } // #################################### // #################################### // here sample serialized json object // #################################### {"accesskey":"ee404d54-ea45-421a-9633-1ea35c0c211e","fbaccesstoken":"2227470867|2.aqa19sonrujqry-y.3600.1310454000.0-757629911|lphibb-ghcpt73zladtwdmocro0","type":"c","platform":"a"} // #################################### // #################################### // #################################### // here's wcf json service signature // #################################### [operationcontract] [webinvoke(uritemplate = "", method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.bare)] public serviceresponse create(servicerequest request) { // } // #################################### // #################################### // #################################### // here's servicerequest object define in json service // #################################### using system.io; using system.runtime.serialization; namespace voicebookservice.request { [datacontract()] public class servicerequest { #region private fellow member [datamember(isrequired = true)] private string accesskey; // access key service [datamember(isrequired = true)] private string fbaccesstoken; // fb live access token [datamember(isrequired = true)] private string type; // c comment : m message [datamember(isrequired = true)] private string platform; // android : ios : w window [datamember(isrequired = false)] private string data; // file save s3 #endregion #region property public string accesskey { set { this.accesskey = value; } { homecoming this.accesskey; } } public string fbaccesstoken { set { this.fbaccesstoken = value; } { homecoming this.fbaccesstoken; } } public string type { set { this.type = value; } { homecoming this.type; } } public string platform { set { this.platform = value; } { homecoming this.platform; } } public string info { set { this.data = value; } { homecoming this.data; } } #endregion } } // #################################### // ####################################
i had similar problem once, in case method not allowed caused missing '/' @ end of url
this post helped me
android httppost returns error "method not allowed."
java android wcf json service
Comments
Post a Comment