Click here to Skip to main content
15,920,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in iservice.cs
C#
[operationcontract]
list< result> method(string name);

[datacontract]
public class result
{

[DataMember]
        public int no
        {
            get { return no;}
            set { no= value; }
        }
        [DataMember]
        public int age
        {
            get { return age;}
            set { age= value; }
        }

}


in wcf service.cs

C#
public list< result> method( string name)
{
    sqlcon
    sql command type procedure  name-input,no-output,age-output
    result rs=new result();
    rs.no=cmd.parameters["@no"].value;
    rs.age=cmd.parameters["@age"].value;
    list< result> rls=new list< result>;
    rls.add(rs);

}

in aspx.cs file

C#
ServiceReference2.Service1Client obj2 = new ServiceReference2.Service1Client();


up to calling wcf service in aspx.cs file it is perfect but when calling wcf method which is in return type list its showing error

Error 18  Cannot implicitly convert type 'sample.ServiceReference2.result[]' to 'System.Collections.Generic.List'


how to consume wcf method which is return type list in aspx.cs file any sample code or any example or any modifications for my code
Posted
v2

While Adding service reference select list as return type for array.
 
Share this answer
 
Comments
ntitish 2-May-13 4:48am    
i allready chainged it in settings as return type is generic.list but it is not effecting.so can u send me sample code.....i am little bit confused
 
Share this answer
 
Comments
ntitish 2-May-13 6:01am    
thq u for this link but after wcf service call
ServiceReference2.Service1Client obj2 = new ServiceReference2.Service1Client(); -- its ok
obj2.Add(new result{No,age}); -- here for "Add" showoing error like

Error 40 'prasad.ServiceReference2.Service1Client' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'prasad.ServiceReference2.Service1Client' could be found (are you missing a using directive or an assembly reference?)

and for List< result> res = obj2.getstudentdetails("prasad"); -- here showiing conversion not possible ( i changed the setting to collection type- genric.list)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900