views:

73

answers:

1

I already searched a lot in Google. I created a EntityClass on client side, and then I added the library reference of this class on Web Service side. But when I want to call the method, it shows this error:

Error 2 Argument 1: cannot convert from 'Services_Library.UserService.UserServiceSoapClient' to 'Services_Library.UserService.UserEntity'

here is the code, this method is called from a User Interface:

public UserEntity test(UserEntity userEntityx)
    {
        UserService.UserServiceSoapClient userService = new UserService.UserServiceSoapClient();
        userService.testUserAsync(new UserEntity());
    }

I think we can do this without explicity serialization, right? If so, I prefer this way.

+1  A: 

I think the problem is when you actually call the service, you're passing in the serviceReference and not the object that the call accepts. I think it should look something like:

public UserEntity test(UserEntity userEntityX)
{
    var userService = new UserService.UserServiceSoapClient();
    return userService.testUser(userEntityX);
}

No explicit serialization needed.

Also, keep in mind that if you're calling the Async version of the method you're code is going to become more complicated. I used the synchronous version in my example.

Justin Niessner
ye, i know about that async.Sorry my real code is this, and still don't work:public UserEntity test(UserEntity userEntityx) { UserService.UserServiceSoapClient userService = new UserService.UserServiceSoapClient(); userService.testUserAsync(new UserEntity()); }
Alan
If that's the case, then the compilation error you're getting doesn't make any sense. Are you sure that's your exact/entire code?
Justin Niessner
yea man, this don't make sence to me =/as I said, this only code generate the error:public UserEntity test(UserEntity userEntityx){ UserService.UserServiceSoapClient userService = new UserService.UserServiceSoapClient(); userService.testUserAsync(new UserEntity()); }
Alan