Webservice复杂类型和类继承
使用以下 Webservice 定义,使用 aClientArgs 作为复杂类型:
[System.Web.Script.Services.ScriptService]
public class Controller : System.Web.Services.WebService {
[WebMethod]
public void save_client(aClientArgs client)
{
// Save client data
}
}
然后将 aClientArgs 定义为子类:
public class aArgs
{
public string id = null;
public string name = null;
}
public class aClientArgs : aArgs
{
public string address = null;
public string website = null;
}
返回 save_client args 的以下 WSDL 片段:
<save_client xmlns="http://tempuri.org/">
<client>
<address>string</address>
<website>string</website>
</client>
</save_client>
当我期待以下内容时:
<save_client xmlns="http://tempuri.org/">
<client>
<id>string</id>
<name>string</name>
<address>string</address>
<website>string</website>
</client>
</save_client>
所以看来 .NET WebService 没有处理继承属性作为 Web 服务的参数/变量。如何让 .NET 也使用基类的属性?
Using the following Webservice definition using aClientArgs as a complex type:
[System.Web.Script.Services.ScriptService]
public class Controller : System.Web.Services.WebService {
[WebMethod]
public void save_client(aClientArgs client)
{
// Save client data
}
}
Then defining aClientArgs as a sub-class:
public class aArgs
{
public string id = null;
public string name = null;
}
public class aClientArgs : aArgs
{
public string address = null;
public string website = null;
}
Returns the following WSDL fragment for the save_client args:
<save_client xmlns="http://tempuri.org/">
<client>
<address>string</address>
<website>string</website>
</client>
</save_client>
When I'm expecting the following:
<save_client xmlns="http://tempuri.org/">
<client>
<id>string</id>
<name>string</name>
<address>string</address>
<website>string</website>
</client>
</save_client>
So it appears that the .NET WebService is not treating inherited properties as arguments/variables for purposes of a web service. How do I get .NET to also use the properties of the base class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何确定 WSDL 是错误的?您是否浏览到该服务并单击 save_client 方法的链接?
这只是一个帮助页面。在这种情况下,这是错误的。单击服务描述的链接,我想您会看到以下内容:
How did you determine that the WSDL is wrong? Did you browse to the service and click the link for the save_client method?
That's just a help page. In this case, it's wrong. Click the link for the service description, and I think you'll see the following: