i've programmed ( followed tutorial ) simple web service in android, using ksoap libary. seems doesn't work well. below simple code:
public class mainactivity extends activity { textview tv; soapprimitive response; final string soap_action = "http://tempuri.org/celsiustofahrenheit"; final string method_name = "celsiustofahrenheit"; final string namespace = "http://www.tempuri.org/"; final string url = "http://www.w3schools.com/webservices/tempconvert.asmx"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tv = (textview) findviewbyid(r.id.tv); final button button = (button) findviewbyid(r.id.button1); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { getvalue(); } }); } private void getvalue() { soapobject soapobject = new soapobject(namespace, method_name); soapobject.addproperty("celsius", "33"); soapserializationenvelope serial = new soapserializationenvelope(soapenvelope.ver11); serial.dotnet = true; serial.setoutputsoapobject(soapobject); httptransportse transport = new httptransportse(url); try { transport.call(soap_action, serial); response = (soapprimitive) serial.getresponse(); tv.settext(response+""); } catch (ioexception e) { e.printstacktrace(); } catch (xmlpullparserexception e) { e.printstacktrace(); } } }
i response "error" in text view. can tell me wrong here?
i found wrong. wrote:
final string namespace = "http://www.tempuri.org/";
instead of
final string namespace = "http://tempuri.org/";
it's working now.
Comments
Post a Comment