Web service method returns Response object instead of custom object

狂风中的少年 提交于 2020-01-03 05:38:25

问题


I have the following code:

    [WebMethod]
    [SoapHeader("_webServiceAuth")]
    public User GetUser(string username)
    {
        try
        {
            this._validationMethods.Validate(_webServiceAuth);
            User user = new User(username);

            return user;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

As you can see, one would expect to receive a User as a responce when I do:

myUser = this.Service.GetUser(username);

But what I get is a request for a "GetUserRequest" instance, and get returned a "GetUserResponse" instance. Any help in why my object is not being send by my webservice?


回答1:


You will find that the GetUserRequest object has a string property (username), and the GetUserResponse object contains your User object. These Request/Response objects are containers that exist in the SOAP messages.

I believe they are normally abstracted away but I may be mistaken.



来源:https://stackoverflow.com/questions/3818208/web-service-method-returns-response-object-instead-of-custom-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!