views:

256

answers:

2

This might be very easy, but What I am trying to do here is, I am trying to pass a Customer Object to a Web Service Method. Customer class is on Entity namespace and it is serializable, and I am adding reference to both of my ASP.NET application which calls web service and pass Entity.Customer Object and also in WebService which accepts Enity.Customer Object.

Web Service Method

[WebMethod]
public void AddCustomer(Entity.Customer c)
{}

ASP.NET Applcation

Entity.Customer c = new Entity.Customer;
webservice.AddCustomer(c);

Error

The best overloaded method match for 'TestApplication.localhost.Service1.AddCustomer(TestApplication.localhost.Customer)' has some invalid arguments

I tried changing the web service to accept Object and later cast that object to Customer.Entity, the Application compiles but I was getting XML generation errors.

A: 

Often the helper methods generated through a service method expect the local generated objects - this is because some elements of the server-side objects aren't serialized, or are handled slightly differently because of the serialization.

Try:

TestApplication.localhost.Customer c = new TestApplication.localhost.Customer();
webservice.AddCustomer(c);

This way you're using the generated objects, with the correctly serialized properties, rather than the original object.

Zhaph - Ben Duguid
A: 

Are you generating the web service method using the 'Add Web Reference' method from within Visual Studio?

This is a compile-issue right? You application doesn't want to compile? Just go to the definition of the method and make sure you are passing the same customer object as specified in the method definition - usually the generated web service method generates a proxy version of the object and you need to pass that exact same class.

Jaco Pretorius
Thanks for your response. Thats exactly i was doing. I figured out that later.
Rohan S
Please accept the answer...
Jaco Pretorius