none
Access a method in a proxy class RRS feed

  • Question

  • I'm trying to access a method in a proxy class and display the values returned by the method on a web page.

    This is the class and the method I'm trying to access is RaceDaySimple[] raceDay:

    /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18408")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace="java:se.atg.aisbean.calendar")]
        public partial class RaceDayCalendarSimple : object, System.ComponentModel.INotifyPropertyChanged {
            
            private RaceDaySimple[] raceDayField;
            
            private AtgDateTime timestampField;
            
            /// <remarks/>
            [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=0)]
            /*Access this method ==>*/public RaceDaySimple[] raceDay {
                get {
                    return this.raceDayField;
                }
                set {
                    this.raceDayField = value;
                    this.RaisePropertyChanged("raceDay");
                }
            }
            
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=1)]
            public AtgDateTime timestamp {
                get {
                    return this.timestampField;
                }
                set {
                    this.timestampField = value;
                    this.RaisePropertyChanged("timestamp");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName) {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null)) {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }


    On WebForm1.aspx.cs I have this content:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    //using System.Net;
    
    namespace WebServiceClient
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                InformationServiceReference.PartnerInfoServicePortClient pbs = new InformationServiceReference.PartnerInfoServicePortClient();
                pbs.ClientCredentials.UserName.UserName = "SomeUsername";
                pbs.ClientCredentials.UserName.Password = "SomePassword";
    
               test.InnerHtml = Convert.ToString(pbs.fetchRaceDayCalendarSimple().raceDay);
              
            }
        }
    }
     

    This method will return a race day and I'm trying to display it on WebForm1.aspx. First I tried with:

    test.InnerHtml = pbs.fetchRaceDayCalendarSimple().raceDay;

    Then "pbs.fetchRaceDayCalendarSimple().raceDay;" is underlined so I understand that something is wrong. When hovering over it I get the error message:

    Cannot implicitly convert 'WebServiceClient.InformationServiceReference.RaceDaySimple[]' to 'String'

    So I figure I should do this instead:

    test.InnerHtml = Convert.ToString(pbs.fetchRaceDayCalendarSimple().raceDay);

    So "test" is the div id on the page WebForm1.aspx:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <h1>Test:</h1>
        <div id="test" runat="server"></div>
        </div>
        </form>
    </body>
    </html>
    

    So then when loading WebForm1.aspx this is what is displayed:

    Test:

    WebServiceClient.InformationServiceReference.RaceDaySimple[]

    Only the name of the method is displayed, but I want the method to displayed what the method does and that is to display a race day. So how do I do that?

    Saturday, June 14, 2014 7:42 PM

Answers

All replies

  • raceDay is an array of strings. You expect for a single string.

    Maybe you want to do something like that:

    test.InnerHtml = pbs.fetchRaceDayCalendarSimple().raceDay[0];

    Sunday, June 15, 2014 9:42 AM
  • I get the same error message:

    convert 'WebServiceClient.InformationServiceReference.RaceDaySimple[]' to 'String'

    Any advise?

    Sunday, June 22, 2014 2:23 PM