Call WCF method from client c# -
i have created 1 wcf service application. there few methods in service1.svc
.
here iservice1.cs
[operationcontract] getuserdetailsbyemail_result getuserdetailsbyemail(string email);
here service.svc.cs
public class service1 : iservice1 { #region getuserdetails public getuserdetailsbyemail_result getuserdetailsbyemail(string email) { return (new usermanager()).getuserdetailsbyemail(email); } #endregion }
here getuserdetailsbyemail_result
complex type
created in demomodel.edmx. contain scalar property.
basically trying is, want call method client(c#) side. here client side code
//svc.getuserdetailsbyemailcompleted += new eventhandler<getuserdetailsbyemailcompletedeventargs>(svc_getuserdetailsbyemailcompleted); getuserdetailsbyemail_result dtbuserdetails = svc.getuserdetailsbyemailasync(loginname);
here svc object of service1client
. here calling wcf method. gives me error
cannot implicitly convert type 'void' 'demo.demoservicereference_client.getuserdetailsbyemail_result'
it works when use svc_getuserdetailsbyemailcompleted method. want return data directly in dtbuserdetails
. how can achieve this? there changes in wcf service or in client side? or in wcf method declaration?
you either need create object , bind data of people in comments suggested mark each property so:
[datacontract(namespace = "myservicecontract.service1.complexobject")] public class complexobject { [datamember(order = 1, isrequired = true)] public string dbitem1{ get; private set; } [datamember(order = 2, isrequired = false)] public complexblobdata dbitem2{ get; set; } }
or if can open demomodel.edmx(code behind) , mark data contract same way mark own object.
bottom line not marked not going on wire.
Comments
Post a Comment