Hello I have a web service that has a parameter class
[WebMethod]
public int Customers(Customer _customers)
{
Customer getCustomer = new Customer();
getCustomer.ID = _customers.ID;
getCustomer.FirstName = _customers.FirstName;
getCustomer.LastName = _customers.LastName;
return 0;
}
now I have a C# console application calling the webservice
ServiceReference1.WebService1SoapClient _client = new WebService1SoapClient();
Customer _customers = new Customer();
_customers.ID = 1;
_customers.FirstName = "FirstName";
_customers.LastName = "LAstName";
_client.Customers(_customers);
one the _client.Customers(_customers);
I have an error
"cannot convert from 'Customer' to 'WRTC_BACKUPDB.ServiceReference1.Customer'"
It seems that you have 2 Customer
classes on the client side
Changing
Customer _customers = new Customer();
to
var _customers = new WRTC_BACKUPDB.ServiceReference1.Customer();
Should solve this, although you should also determine where the other Customer
class came from.
It may be that the console client has both a proxied Customer
class created by the wizard when adding the Service Reference
, and it also directly references the original Customer
class used on the server assembly. If you wish to share the same class between client and server, there is an option to reuse type in the Service Reference wizard.
(also from a naming convention viewpoint, I would also change the variable name to _customer
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments