我创建了一个使用泛型类型的web服务 Response<TCode, TData>
Response<TCode, TData>
功能上很好,但我想知道是否有办法命名这些特定元素?
编辑:
[return: XmlElement("AuthenticationResponse")] [WebMethod] public Response<ResponseCode, AuthenticationData> AuthenticateProcess(string ProcessName, string Password) { // ... Code ... }
<ResponseOfResponseCodeAuthenticationData (...) >
如果您要显示一些代码,可能会有所帮助。
不过,请看[XmlElementAttribute]属性,它允许您指定元素名称。如果您的问题是返回值,那么您需要使用
[return: XmlRoot("ReturnElementName")] [WebMethod] public int MyWebMethod() { ... }