Osher Levy
Osher Levy

Reputation: 83

How do I read from web-service XML response?

I send Text messages using soap webservice here's the function:

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;
    }
}

the XML response looks like that:

XML Response Example

how do I read from XML as webservice method call has completed?

Update: enter image description here

Upvotes: 0

Views: 523

Answers (1)

Dakota Kronberger
Dakota Kronberger

Reputation: 119

It looks like you are looking to return the XML response from sms.SendSMS():

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";
    }
}

Upvotes: 1

Related Questions