Web Service Passing parameter Class

user2530833

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'"

StuartLC

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Trouble passing datetime parameter to web service, in GET

From Dev

JAVA: Restfull web service not passing parameter correctly

From Dev

JAVA: Restfull web service not passing parameter correctly

From Dev

Passing a file as a parameter for a Spring web service via Postman

From Dev

Passing a class object as input parameter to a RESTful WCF service with POST request

From Dev

Passing a class as function parameter

From Dev

Passing Child class as parameter

From Dev

Passing Scala Class as parameter?

From Dev

Passing class as a Parameter

From Dev

Passing Child class as parameter

From Dev

Passing a parameter to an ionic angular service

From Dev

Passing a parameter in url Restful service?

From Dev

Passing a parameter to an ionic angular service

From Dev

JSON Parameter for Web Service

From Dev

Passing parameter as Wrapper class and overriding

From Dev

Typescript passing generic class as parameter

From Dev

Typescript passing generic class as parameter

From Dev

Passing Class<? extends T> as a parameter

From Dev

Passing parameter to anonymous class in Java

From Dev

Passing Class<?> cls as a method parameter?

From Dev

Passing getClass() as a parameter to a different class

From Dev

Passing date to ASMX web service

From Dev

Passing Username and Password to Web Service

From Dev

Passing a password to a web service and storing it

From Dev

Passing a class as a parameter in a method and using this parameter in an If statement

From Dev

Ksoap: Cannot Serialize exception when passing user defined class as parameter to web method

From Dev

Ksoap: Cannot Serialize exception when passing user defined class as parameter to web method

From Dev

Passing a Class as parameter and instantiating an object using this class

From Dev

Passing a member function of a class to a parameter outside the class

Related Related

  1. 1

    Trouble passing datetime parameter to web service, in GET

  2. 2

    JAVA: Restfull web service not passing parameter correctly

  3. 3

    JAVA: Restfull web service not passing parameter correctly

  4. 4

    Passing a file as a parameter for a Spring web service via Postman

  5. 5

    Passing a class object as input parameter to a RESTful WCF service with POST request

  6. 6

    Passing a class as function parameter

  7. 7

    Passing Child class as parameter

  8. 8

    Passing Scala Class as parameter?

  9. 9

    Passing class as a Parameter

  10. 10

    Passing Child class as parameter

  11. 11

    Passing a parameter to an ionic angular service

  12. 12

    Passing a parameter in url Restful service?

  13. 13

    Passing a parameter to an ionic angular service

  14. 14

    JSON Parameter for Web Service

  15. 15

    Passing parameter as Wrapper class and overriding

  16. 16

    Typescript passing generic class as parameter

  17. 17

    Typescript passing generic class as parameter

  18. 18

    Passing Class<? extends T> as a parameter

  19. 19

    Passing parameter to anonymous class in Java

  20. 20

    Passing Class<?> cls as a method parameter?

  21. 21

    Passing getClass() as a parameter to a different class

  22. 22

    Passing date to ASMX web service

  23. 23

    Passing Username and Password to Web Service

  24. 24

    Passing a password to a web service and storing it

  25. 25

    Passing a class as a parameter in a method and using this parameter in an If statement

  26. 26

    Ksoap: Cannot Serialize exception when passing user defined class as parameter to web method

  27. 27

    Ksoap: Cannot Serialize exception when passing user defined class as parameter to web method

  28. 28

    Passing a Class as parameter and instantiating an object using this class

  29. 29

    Passing a member function of a class to a parameter outside the class

HotTag

Archive