I am trying to get a listview selected item to work. I am trying to see if I can pass the selected value to a wcf and query the database from a selected county to a town. I am just wondering how I can do this?
Here is my onitem click event that I am building at the minute:
public void OnItemClick(AdapterView parent, View view, int position, long id)
{
var selectedValue = parent.GetItemAtPosition(position);
var Intent = new Intent(this, typeof(SelectLocationActivity));
// selectedValue should already be a string but...
Intent.PutExtra("Name", selectedValue.ToString());
StartActivity(Intent);
}
I am just wondering how I can implement the calling of the wcf service app and post the selected value to it. I am using Xamarin by the way
If you have set up your webservice, then just add a Service Reference in your project and all the exposed functions of your ws will be available through the proxy class which will be created when you added the reference.
Related
My WCF contains two methods. The first is simple which returns string and takes string as parameter, but in second method I am passing a class containing properties as parameter and return string.
When I comment second method then I am able to get WCF_Masters.ServiceClient object in client application but after uncommenting 2nd method I am unable to get that object.
I get only CompositeType instead of ServiceClient of My WCF service whose name is WCF_Masters.
Note that I am trying to consume WCF in WPF Windows application.
How can I get rid of this issue?
Edit
My WCF methods are:
public String GetMessage(string vName)
{
return "Hello world from " + vName;
}
public String SaveEmployee(EmployeeMasterSC vEmployeeMasterSC)
{
String mReturnMsg = string.Empty;
EmployeeMasterDAL vEmployeeMasterDAL = null;
vEmployeeMasterDAL = new EmployeeMasterDAL();
mReturnMsg = vEmployeeMasterDAL.SaveEmployee(vEmployeeMasterSC);
//mEmpDset.EmployeeData = Mdset; return mReturnMsg;
}
If I understood you correctly, you should not be adding a reference to your WPF DLL in your WCF service. Define the model in your service and then instantiate that model (by reference) in your WPF application, which is consuming the service.
I believe the reason it works when you comment out the 2nd method is that your 1st method has no reference to class structures defined in the WPF DLL.
Got the solution guys, It was the issue of database name I have Written incorrectly "AirportPortal" instead of "DB_AirportPortal" in WCF while inserting records into database
I have a WP8 Pivot application which contains a Model that is meant to automatically bind against the View/Page.xaml. This is done by the auto-generated NotfifyPropertyChanged code which I have assigned to all of the properties that are spat out on to the page.
The problem as I see it is when the application is installed for the first time, the Model is obviously empty as the application is completely fresh. At this point, I call a web service which successfully retrieves data. Once retrieved, I save the data and assign the data to the Model.
Although I assign the data to the model, the View doesn't update itself. I also noticed that the NotifyPropertyChanged code doesn't fire when doing:
App.ViewModel.Signs = results.Signs
The code for the Model looks like this:
public int ID
{
get { return _id; }
set
{
if (value != _id)
{
_id = value;
NotifyPropertyChanged("ID");
}
}
}
The rest of the properties have the same notion, i.e. NotifyPropertyChanged("objectName");.
When I relaunch the application, the information on the screen successfully appears. It is only when the application fires from beginning or when the user manually asks for the latest data that it fails to update the View/Page.xaml.
Any ideas what I could do to fix this?
Maybe your NotifyPropertyChanged method is broken, or the Signs property does not call the method correctly.
I have a WCF method which have a nested List parameter, like this
public void Method(List<class1> class1Obj, List<List<SomeClass>> someClassObj)
{
// CODE
}
After setting service reference I get this in my client reference method through which I can call my WCF method
public void Method(class1[] class1Obj, SomeClass[][] someClassObj)
{
base.Channel.Method(class1Obj, someClassObj);
}
Now to call this method from my code I can do this
void myServiceCaller()
{
List<class1> class1Obj = new List<class1>();
// Add items to class1Obj
List<List<SomeClass>> someClassObj = List<List<SomeClass>>();
// Add items to someClassObj
ServiceRef.myServiceClient service = new ServiceRef.myServiceClient();
service.Method(
class1Obj.ToArray(), // This one is fine
someClassObj.ToArray() // This gives me compile time error
);
}
How can I resolve this issue to convert List<List<SomeClass>> to SomeClass[][] ?
When you add your Service Reference and the dialog pops up you can click the Advanced... button in the lower left and change the Collection type drop-down from System.Array to System.Collection.GenericList this will then change the proxy that is created and use List<...> instead of [...] when collections are used.
In addition, if you have already added your Service Reference you can right-click on the Service Reference within the Solution tree and click Configure Service Reference... from the context-menu. This will show the same "Advanced" dialog mentioned above.
I am trying to build an silverlight application which takes user first name, last name, pass, email address in text boxes and then add these to the database.
For this i am using WCF Ria Services.
Steps i have followed are :
Added ADO.NET Entity Data Model and then Domain Service class in my project (in web part).
Now i have got some predefined methods in my DomainService Class like Insert, Update methods. I know how to show data in DataGrid but its not what i want.
What i want is to customize all this for :
When user clicks the submit button then there should be method inside this like AddInfo(all parameters) which can add all the data to my sql server database {at present LocalHost}.
In simple words accessing your database through custom methods to add data in sql server using WCF Ria Services
I know it was very simple while working in .net forms and all. But how about Silverlight & WCF ria ?
Please Suggest.
In simple words accessing your database through custom methods to add
data in sql server using WCF Ria Services
What you should do is write a custom method in server-side.
On server-side, you have a DomainService class that should inherit from LinqToEntitiesDomainService<TContext>.
Simply add a method in this class with the Invoke attribute, for example:
[Invoke]
public void AddNewUser(string name, string firstName, int age)
{
// Put logic here to add the user to the DB
}
The logic to add a user to the database is really simple, just create a new Entity, add it to the context and call context.SubmitChanges();
When you compile the client RIA Services project, the auto-generated proxy class that correspond to your DomainService will contain your new method, and you'll be able to call it using:
yourDomainContext ctx = new yourDomainContext();
ctx.AddNewUser("dsd", "ds", 42).Completed += (sender, e) =>
{
// Called asynchronously when the job is done
};
If you already have the Insert method on your Domain Service, you should be able to call from the client:
//add your new data to the context
MyDomainServiceContext.Entity.Add(myEntity); //(where "Entity" is your entity Type)
//send all the changes to the server
MyDomainServiceContext.SubmitChanges();
I'm new to silverlight, I want to add web reference to silverlight application is that possable???
I can only add service reference to the SilverightApplication but i want to add web reference.
I can add web reference to the SilverightApplication.Web, can i use it from SilverightApplication??
I aslo can add service reference to the SilverightApplication but functions of service reference has no return value so i cant recieve the data, here is the code
Service1SoapClient c = new Service1SoapClient();
ServiceReference1.Service1SoapClient a = new ServiceReference1.Service1SoapClient();
a.returnStr_19_9Async("");
the function returnStr_19_9Async("") has no return value can any one please tell me what is teh wrong??
Can you please tell me how, please explain..
Thanks.
The problem you may be striking is that WCF calls are all done asynchronously in Silverlight. This means when you call your initial service function (let's call it GetMyClient(int clientId) ), the proxy that you have generated will have a function called GetMyClientAsync(), and it will also have an event called GetMyClientCompleted which you must subscribe to:
myProxy.GetMyClientCompleted += new EventHandler<GetMyClientCompletedEventArgs>(MyProxy_GetMyClientCompleted);
that event handler will look something like this:
private void MyProxy_GetMyClientCompleted(object sender, GetMyClientCompletedEventArgs e)
{
//e.Result will have your returned values
}
This is just a very brief overview that gives you enough to get started. You could also read more here: Silverlight.net | Data & Networking | Network Services (Soap, REST and More)