c# - Consuming WCF Soap Service running on Mono from Android KSoap2 -


i working on android/c# project. need able have wcf soap service can either run on windows or linux (mono).

its working fine on windows , can access wcf service on mono wcf test client provided in visual studio , works fine when accessing android using ksoap2 error http request failed, http status: 415

below how soap service started

string methodinfo = classdetails + methodinfo.getcurrentmethod().name;             try             {                 if (environment.getenvironmentvariable("mono_strict_ms_compliant") != "yes")                 {                     environment.setenvironmentvariable("mono_strict_ms_compliant", "yes");                 }                 if (string.isnullorempty(soapserverurl))                 {                     string message = "not starting soap server: url or port number not set in config file";                     library.logging(methodinfo, message);                     library.setalarm(message, commontasks.alarmstatus.medium, methodinfo);                     return;                 }                 console.writeline("soap server url: {0}", soapserverurl);                 baseaddress = new uri(soapserverurl);                 host = new servicehost(soaphandlertype, baseaddress);                 basichttpbinding basichttpbinding = new basichttpbinding();                  //basichttpbinding.namespace = "http://tempuri.org/";                    var meta = new servicemetadatabehavior()                 {                     httpgetenabled = true,                     httpgeturl = new uri("", urikind.relative),                     //httpgetbinding = basichttpbinding,                 };                 //meta.metadataexporter.policyversion = policyversion.policy15;                  host.description.behaviors.add(meta);                  host.addserviceendpoint(soapmanagerinterface, basichttpbinding, soapserverurl);                 host.addserviceendpoint(typeof(imetadataexchange), metadataexchangebindings.createmexhttpbinding(), "mex");                  var debugbehaviour = new servicedebugbehavior()                 {                     httphelppageenabled = true,                     httphelppageurl = new uri("", urikind.relative),                     includeexceptiondetailinfaults = true,                     //httphelppagebinding = basichttpbinding,                 };                  host.description.behaviors.remove(typeof(servicedebugbehavior));                 host.description.behaviors.add(debugbehaviour);                 host.opened += new eventhandler(host_opened);                 host.faulted += new eventhandler(host_faulted);                 host.closed += new eventhandler(host_closed);                 host.unknownmessagereceived += new eventhandler<unknownmessagereceivedeventargs>(host_unknownmessagereceived);                 host.open();             } 

the soapserverurl http://192.168.1.74:8000/critimon.

below how trying call soap service android using ksoap2.

final string soapaction = "http://tempuri.org/isoapinterface/testsoapfunction";         final string namespace = "http://tempuri.org/";         final string methodname = "testsoapfunction";         final string url = "http://192.168.1.74:8000/critimon?wsdl";         string resultdata = "";          new thread(new runnable() {              @override             public void run() {                 soapserializationenvelope envelope = null;                 try                 {                 //string resultdata = "";                      soapobject request = new soapobject(namespace, methodname);                     //request.addproperty("firstname", "chris");                     //request.addproperty("lastname", "board");                     envelope = new soapserializationenvelope(soapenvelope.ver11);                     envelope.dotnet = true;                     envelope.setoutputsoapobject(request);                      httptransportse http = new httptransportse(url);                      http.call(soapaction, envelope);                     soapprimitive result = (soapprimitive)envelope.getresponse();                      string resultdata = result.tostring();                     log.d("soap result", resultdata);                  }                 catch (exception ex)                 {                     log.e("soap error 2", ex.getmessage()); } 

i have no idea can make work on mono android. appreciated.

firstly, want catch actual soap request on wire. can using fiddler or soapui - both act proxies through local requests passed, allowing inspect actual xml request anomalies. might discover obvious doing this, or can @ least update question more information.

following that, , without further information, can offer memorable experience talking wcf services non-.net applications:

wcf specifies xml request expects, requires object properties in specific order. can declared order in datacontract, or can implicit alphabetical order. either way, if don't provide object properties in specified order stung , things won't work.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -