如何阅读Web服务XML响应?

时间:2017-01-27 20:28:42

标签: c# asp.net xml web-services

我使用soap webservice发送短信 这是功能:

public static string SendSms(string Message, string Phone, string BranchName)
{
    string result;
    try
    {
        var sms = new WebServiceSMS.SendMessageSoapClient();
        sms.SendSms(WebConfigurationManager.AppSettings["UserName"], WebConfigurationManager.AppSettings["Pwd"], Message, Phone, BranchName, "0");
        result = "Successful";
        return result;
    }
    catch
    {
        result = "failed";
        return result;
    }
}

XML响应看起来像这样:

XML Response Example

如何在Web服务方法调用完成后从XML读取?

更新 enter image description here

1 个答案:

答案 0 :(得分:1)

看起来您正在寻找从sms.SendSMS()返回XML响应:

public static string SendSms(string Message, string Phone, string BranchName)
{
    try
    {
        var sms = new WebServiceSMS.SendMessageSoapClient();
        return sms.SendSms(WebConfigurationManager.AppSettings["UserName"], WebConfigurationManager.AppSettings["Pwd"], Message, Phone, BranchName, "0");
    }
    catch
    {
        return "Failed";
    }
}