WCF service working on debug but not working when calling from android -
i created wcf service in visual studio 2012 intend consume in xamarin , have save user registration information table in sql server. service works fine when debugging in visual studio, data entries save table in sql. want consume service in xamarin , here code:
using system; using system.collections.generic; using system.data; using system.data.sqlclient; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text; using itusservice; using android.app; using android.locations; using android.os; using android.util; using android.widget; //some code here... public static readonly endpointaddress endpoint = new endpointaddress("http://192.168.1.155:12100/service1.svc"); private service1client service; protected override void oncreate (bundle bundle) { //some code here... initializeservice1client(); } private void initializeservice1client() { basichttpbinding binding = new basichttpbinding (); service = new service1client(binding, endpoint); } async void addressbutton_onclick(object sender, eventargs eventargs) { //some code here... userlocation useraddress = new userlocation (); useraddress.clientid = _client.text = "ddsdfs"; useraddress.fullname = _name.text = "dsffdf"; useraddress.locationcoordinates = _locationtext.text; useraddress.locationaddress = _addresstext.text; useraddress.distresstime = _time.text = "djdsk"; string result = service.tostring (); _resulttxt.text = result; }
i don't know if there missing out because nothing being saved sql table android device. debug using both emulator , device, nothing has been saved using both. have opened port listening, have created reference file using silverlight slsvc tool according xamarin walkthrough http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_wcf/ have tried possibly can. please help.
the general pattern calling wcf method (this general wcf , has nothing xamarin or android)
// create client , bind client = new serviceclient(binding, endpoint); // specify callback client.getlocationcompleted += ongetlocationcompleted; // make request method, passing required parameters client.getlocationasync(useraddress);
because wcf call async, need provide callback method (the naming of eventargs class depend on how service defined)
public void ongetlocationcompleted(object sender, getlocationcompletedeventargs args) { // if bad happend, args.error contain exception // otherwise args.result contain return value method }
Comments
Post a Comment