Link to home
Start Free TrialLog in
Avatar of milani_lucie
milani_lucieFlag for United States of America

asked on

Cannot implicitly convert type 'Person[]' to 'System.Collections.Generic.List<Person> ==== Web Service Proxy Modifications - C# / ASP.NET

Hi,

I have the below code generated by WSDL.EXE for Proxy. But i want to have the List<Person> instead of Person[] as my front end UI requires a List instead of Array.

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Load", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public Person[] Load() {
        object[] results = this.Invoke("Load", new object[0]);
        return ((Person[])(results[0]));
    }
   
    /// <remarks/>
    public System.IAsyncResult BeginLoad(System.AsyncCallback callback, object asyncState) {
        return this.BeginInvoke("Load", new object[0], callback, asyncState);
    }
   
    /// <remarks/>
    public Person[] EndLoad(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((Person[])(results[0]));
    }
   
    /// <remarks/>
    public void LoadAsync() {
        this.LoadAsync(null);
    }
   
    /// <remarks/>
    public void LoadAsync(object userState) {
        if ((this.LoadOperationCompleted == null)) {
            this.LoadOperationCompleted = new System.Threading.SendOrPostCallback(this.OnLoadOperationCompleted);
        }
        this.InvokeAsync("Load", new object[0], this.LoadOperationCompleted, userState);
    }
   
    private void OnLoadOperationCompleted(object arg) {
        if ((this.LoadCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.LoadCompleted(this, new LoadCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
   
    /// <remarks/>
    public new void CancelAsync(object userState) {
        base.CancelAsync(userState);
    }

I want to modify the code generated by WSDL tool. So can you please modify the above code to have the List instead of Array ?

List<Person> instead of Person[].

Carefully look at this code:

    /// <remarks/>
    public Person[] EndLoad(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((Person[])(results[0]));
    }

Thanks
Avatar of saragani
saragani

public Person[] EndLoad(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((Person[])(results[0])).ToList();
    }
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial