Web服务方法返回响应对象,而不是自定义对象的 [英] Web service method returns Response object instead of custom object
问题描述
我有以下的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);
但我得到的是一个GetUserRequest实例的请求,并获得返回的GetUserResponse实例。在为什么我的目标是不被我的web服务发送任何帮助吗?
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?
推荐答案
您会发现GetUserRequest对象有一个字符串属性(用户名)和GetUserResponse对象包含用户对象。这些请求/响应对象是存在于SOAP消息容器。
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.
这篇关于Web服务方法返回响应对象,而不是自定义对象的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!