Access C# .net web service in android -
how can use .net web services using android?
my code this...
package webservices.pck; import org.ksoap2.soapenvelope; import org.ksoap2.serialization.soapobject; import org.ksoap2.serialization.soapserializationenvelope; import org.ksoap2.transport.httptransportse; import android.widget.textview; import android.app.activity; import android.os.bundle; public class webservices extends activity { private static final string soap_action = "http://tempuri.org/helloworld"; private static final string method_name = "helloworld"; private static final string namespace = "http://tempuri.org/"; private static final string url = "http://ipaddress/service1.asmx"; //private object resultrequestsoap = null; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview tv = new textview(this); try { soapobject request = new soapobject(namespace, method_name); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); androidhttptransport.debug = true; envelope.dotnet = true; androidhttptransport.call(soap_action, envelope); soapobject resultrequestsoap = (soapobject)envelope.bodyin; string result = (string)resultrequestsoap.getproperty(0).tostring(); tv.settext(result); this.setcontentview(tv); } catch (exception ae) { tv.settext(ae.tostring()); this.setcontentview(tv); } } }
in code using.
string url = "http://ipaddress/service1.asmx";
then error :-- org.xmlpull.v1.xmlpullparserexception: expected:start_tag {http://schemas.xmlsoap.org/soap/envelope/}envelope(position:start_tag<html>@1:6 in java.io.inputstreamreader@4375fda8)
you accessing html page , not soap service. parser exception has told what's wrong.
you got data this
<html><body>... </body></html>
while page should return like
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <soapenv:body> <yourfunctiontocall... /> </soapenv:body> </soapenv:envelope>
maybe have typo in url, or kind of authentication or other kind of error, returned html error instead of soap request/response.
Comments
Post a Comment