java - HttpTransportSE .call() method has no action -
i'm trying make android app gets weather based off zipcode enter, , displays time in est , gmt format. using webservices (wsdls) , have code written access it, code below:
public void sendmessage(view view) { soap_action = "http://ws.cdyne.com/weatherws/getcityweatherbyzip"; namespace = "http://ws.cdyne.com/weatherws/"; method_name = "getcityweatherbyzip"; url = "http://wsf.cdyne.com/weatherws/weather.asmx?wsdl"; txtzip = (edittext) findviewbyid(r.id.zipcode); temp = (textview) findviewbyid(r.id.displaytemp); soapobject request = new soapobject(namespace, method_name); propertyinfo property = new propertyinfo(); { property.name = "zipcode"; property.setnamespace(namespace); property.type = propertyinfo.string_class; property.setvalue(txtzip.gettext().tostring()); } request.addproperty(property); //request.addproperty("zipcode", txtzip.gettext().tostring()); toast.maketext(getapplicationcontext(), "btnzip pressed", toast.length_long).show(); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver10); envelope.setoutputsoapobject(request); envelope.implicittypes = true; envelope.dotnet = true; httptransportse androidhttp = new httptransportse(url, 600); try { toast.maketext(getapplicationcontext(), "in try statement", toast.length_long).show(); androidhttp.call(soap_action, envelope); // soapprimitive resp = (soapprimitive) envelope.getresponse(); soapobject result = (soapobject) envelope.bodyin; if(result != null) { toast.maketext(getapplicationcontext(), "in if statement", toast.length_long).show(); //temp.append("in if statement, result not null"); } else { toast.maketext(getapplicationcontext(), "in else statement", toast.length_long).show(); //temp.append("in if statement, result null"); } } catch (httpresponseexception e) { toast.maketext(getapplicationcontext(), "no response", toast.length_long).show(); e.printstacktrace(); } catch (xmlpullparserexception e){ toast.maketext(getapplicationcontext(), "xml pull exe", toast.length_long).show(); e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } catch (exception e) { e.printstacktrace(); } }
now, problem androidhttp.call(soap_action, envelope);
method, nothing happening. have toast methods show being executed, , furthest try block, never if statement.
i have tried looking around seeing might cause , solution, can't seem find specific problem. i've extended time-out server 600 , made implicittype true, nothing working. know using soapenvelope.ver10 method, have 2 other methods used ver11 , ver12 , there's no change. if might have idea might going on, i'd appreciate help. also, androidmanifest.xml has necessary uses-permission line access internet.
!!!! working confirmed !!!
main
public class mainactivity extends activity{ public static string rslt,thread; soapmiddleman c; edittext txtzip; textview weather; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); txtzip = (edittext)findviewbyid(r.id.zipcode); weather = (textview)findviewbyid(r.id.weather); } public void sendmessage(view view) { try{ // condition keeping main thread asleep thread = "start"; // create new webservice caller thread c = new soapmiddleman(); // join new thread, start , select webservice want access c.join();c.setzip(txtzip.gettext().tostring()); c.start(); // keep thread asleep while service thread running while(thread=="start") { try { thread.sleep(10); } catch(exception e) { rslt="failed2"; } } } catch(exception e) { e.printstacktrace(); } weather.settext(rslt); } }
middleman
public class soapmiddleman extends thread { private string zip; private soapsenderclass cs; public void run(){ try{ cs=new soapsenderclass(); string resp=cs.getweather(zip); mainactivity.rslt=resp; //public string in calling activity system.out.println("reached 2 \n"); }catch(exception ex) { mainactivity.rslt=ex.tostring(); } mainactivity.thread = "done"; } public void setzip(string searchzip) { zip = searchzip; } }
caller
public class soapsenderclass{ string soap_action = "http://ws.cdyne.com/weatherws/getcityweatherbyzip"; string namespace = "http://ws.cdyne.com/weatherws/"; string method_name = "getcityweatherbyzip"; string url = "http://wsf.cdyne.com/weatherws/weather.asmx?wsdl"; public string getweather(string zipcode) { try{ soapobject request = new soapobject(namespace, method_name); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.dotnet = true; propertyinfo property = new propertyinfo(); property.setname("zip"); property.settype(string.class); property.setvalue(zipcode); request.addproperty(property); envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); androidhttptransport.call(soap_action, envelope); soapobject response = (soapobject)envelope.getresponse(); string resultvalue = response.tostring(); return resultvalue; } catch (exception e) { e.printstacktrace(); return "failed id"; } } }
i have simplified caller code , changed name of addproperty zip looks input called in wsdl. removed brackets property calls removed namespace isnt needed far can tell.
Comments
Post a Comment