locked
C# SOAP Client using WebForm and listbox RRS feed

  • Question

  • User1855899577 posted

    I'm very new to SOAP and C# but I trying to learn by building a simple SOAP web client. I've create a web form with a single button and listbox. Clicking the button sends a SOAP call to the web services, returns a simple result and displays in the list box. That method (getCountRegisteredSubscribers) doesn't require input and returns an int. Next I want to return information about subscribers using another method called getSubscriber. This method does require input (subscriber name) and will return several results. I'm passing the subscriber name using a var but all I get back is 'WebApplicaiton2.WebReference.Subscriber' in my listbox. Any suggestions would be appreciated!

    namespace WebApplication2
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void Button1_Click(object sender, EventArgs e)
        {
    
            var subName = "subscriber 1";
    
            WebApplication2.WebReference.SMFAdmin ws = new WebApplication2.WebReference.SMFAdmin();
    
            ListBox1.Items.Add("Request Submitted");
            ListBox1.Items.Add(""+ ws.getCountRegisteredSubscribers());
            ListBox1.Items.Add("" + ws.getSubscriber(subName));
    
        }
    
    
    }
    }

    Sunday, September 13, 2015 1:17 PM

Answers

  • User-84896714 posted

    Hi sjw2011,

    As @Ken Tucker mentioned, you will only see the type name if you don't add property name after object. According to your code, service return a Single object(Subscriber type object) to your form. Please check which property do you want to display. For example, if there is a property named SubscriberName, you could use below code to display it.

    ListBox1.Items.Add("" + ws.getSubscriber(subName).SubscriberName);

    Best Regards,
    Wang Li

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 14, 2015 5:00 AM

All replies

  • User-417784260 posted

    You should add a property name to the string instead of the returned results because you will only see the type name.

    For example (I assume Count is a int property returned)

    ListBox1.Items.Add(""+ ws.getCountRegisteredSubscribers().Count.ToString());
    Sunday, September 13, 2015 1:28 PM
  • User1855899577 posted

    Thanks for the reply, ws.getCountRegisteredSubscribers works no problem, I get an int in my listbox. It's ws.getSubscriber(subName) that's causing me grief. All I get back in my list box is 'WebApplication2.WebReference.Subscriber'. Any ideas on that one?

    Sunday, September 13, 2015 1:40 PM
  • User-84896714 posted

    Hi sjw2011,

    As @Ken Tucker mentioned, you will only see the type name if you don't add property name after object. According to your code, service return a Single object(Subscriber type object) to your form. Please check which property do you want to display. For example, if there is a property named SubscriberName, you could use below code to display it.

    ListBox1.Items.Add("" + ws.getSubscriber(subName).SubscriberName);

    Best Regards,
    Wang Li

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 14, 2015 5:00 AM