我有这个特定的方法(下面的片段),我想为它获取 XML 结果。
服务器
[OperationContract]
[WebGet(UriTemplate = "getcustomerschema/userCode={userCode}/password={password}",
ResponseFormat= WebMessageFormat.Xml,
RequestFormat= WebMessageFormat.Xml,
BodyStyle= WebMessageBodyStyle.Wrapped)]
public DataSet GetCustomerSchema(string userCode, string password)
{
//method
}
客户端
using (HttpResponseMessage response = m_RestHttpClient.Get("getcustomerschema/userCode=admin/password=admin"))
{
//how can I get the xml resuly from the httpResponseMessage?
}
谢谢
最佳答案
使用 HttpResponseMessage,您可以通过“Content”属性访问 xml 响应。
HttpResponseMessage resp = http.Get("friends_timeline.xml"); resp.EnsureStatusIsSuccessful(); XElement document = resp.Content.ReadAsXElement();
关于c# - 我有一个 WebGet 方法,如何获取 xml 结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3656849/