[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-04-19
2
Medium Priority
?
1,304 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:milani_lucie
  • 2
2 Comments
 
LVL 11

Expert Comment

by:saragani
ID: 35427961
public Person[] EndLoad(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((Person[])(results[0])).ToList();
    }
0
 
LVL 11

Accepted Solution

by:
saragani earned 2000 total points
ID: 35427971
Sorry....:

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question