WCF: Best practice to send Form Data to a Web Service?

We are using C#, ASP.NET & WCF. I am trying to send form data to a web service which in turn inserts/updates a database with the data from my form. How should I send over my data?

We have the forms populated fine but are having some issues with sending updates back to the web service. We have determined that it is not great practice to use datasets in this situation, it is slow and we have to do too many SELECT *'s for our liking.

I have about 15 fields that need to go across. One team member wants to pass everything as a parameter which I dont think is optimal. We tried sending everything across in an Object[] array but are receiving a weird error "Type 'System.DBNull' with data contract name 'DBNull:http...' is not expected. Add any types not known statically to the list of known types",

Any suggestions are most welcome.

Answers


We use WCF to define our Data Contracts and Data Methods using attributes.

Basically we create an assembly to define all our classes and another assembly to provide the WCF connective bits

OPur class assembly contains a service class and several message classes.

We define an interface for our service and mark it up with relevant WCF markup. This is our Service Contract.

[ServiceContract]
public interface IExampleWebService
{
    [OperationContract]
    CreateAccountResponse CreateAccount(int parameter, CreateAccountArguments another parameter);

    [OperationContract]
    DeleteAccountResponse DeleteAccount(int parameter);
}

We implement this interface in a class and we create various data contracts (our response and argument classes).

[DataContract]
public class CreateAccountResponse
{
    [DataMember]
    public bool CreatedOk { get; set; }

    [DataMember]
    public int AccountId { get; set; }
}

These classes are exposed to our form using the Web Service (We create another assembly as a web service and have a class that inherits from our Service Class (not shown in this example) so we let Visual Studio do all the work setting up the WCF service as we reap the benefits with an easy to use and maintain Web Service.


Need Your Help

Metadata file '.dll' could not be found with LINQ

c# asp.net visual-studio-2010 linq web-applications

I have this method, firstly, it gets all data from database (joined tables), then it filters the result with search property and search keyword, as follow. Everything is fine until I add switch ......

No activity found to handle geo intent in emulator

android android-intent geo

I have following simple method in my main activity.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.