Newbie to WCF need few basic question answered
hi,
After long time i finally got a project that I can use some WCF.Trouble is I have not time to learn as I should.
I have some questions?
1)Can a wcf method return list<T> or do I have to return ICollection?
2)When passing arguments can you pass an object EG Save(Customer customer) or do you have to do Save(string name,string surname etc...) ?
3)When passing arguments can you pass collection EG Save(List<customer>customerList) or do you have to pass arrays ?
4)Is it possible to redirect from an aspx page to a WCF Method ?
Need to simulate a 3rd party control EG paypal (calling my WCF method "Save" to record the payment into the database and then redirect to an aspx.page" can this be done conceptually?
5) can you redirect to a web page from a WCF Method?
If you can answer one that will be fine.
THanks a lot as usual
Thanks for your help
Antworten
- OK the remaing answers are:
3)When passing arguments can you pass collection EG Save(List<customer>customerList) or do you have to pass arrays ?
Answer is : Yes We can do it but need to check third party control's availability for the same
4)Is it possible to redirect from an aspx page to a WCF Method ?
Need to simulate a 3rd party control EG paypal (calling my WCF method "Save" to record the payment into the database and then redirect to an aspx.page" can this be done conceptually?
Answer is:
We cant use Response.Redirect() in servicesBut if you want you can customize services accordinglyCheck this:http://forums.asp.net/t/1275870
5) can you redirect to a web page from a WCF Method?
Answer Is:
You can use document.url=getUrl(call webservice) This is a tricky one Its because you cant use Response.Redirect in services You need to customize Now suppose a scenario in WCF services your client send you a SOAP with UID/PWD and you need to login to another site then you can use this by creating a get Url method ok
Sorry at time due to lak of time I was not able to answer other questions.
Thanks and Regards
Meetu Choudhary
MCPD- Als Antwort vorgeschlagenMeetu ChoudharyMVPSamstag, 4. Juli 2009 17:48
- Als Antwort markiertdevBrix Sonntag, 5. Juli 2009 04:57
Alle Antworten
- 1)Can a wcf method return list<T> or do I have to return ICollection?
yes your WCF serivce can retuen list<t> an example is
in Interface:in class:[OperationContract] [WebGet] List<int> UpdateDesignation(Designation desItem);
public List<int> UpdateDesignation(PLO.Web.Classes.Designation desItem) { List<int> result = new List<int>(); SqlCommand cmd = new SqlCommand("UpdateDesignation", new SqlConnection(GetConnectionString())); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("did", desItem.ID)); cmd.Parameters.Add(new SqlParameter("des", desItem.DesignationName)); cmd.Connection.Open(); int i = cmd.ExecuteNonQuery(); cmd.Connection.Close(); result.Add(i); return result; }Answer to your second question :
2)When passing arguments can you pass an object EG Save(Customer customer) or do you have to do Save(string name,string surname etc...) ?
In the above code snippet Designation is my class and i have passed it as a parameter.
Thanks and Regards
Meetu Choudhary
MCPD- Als Antwort vorgeschlagenMeetu ChoudharyMVPSamstag, 4. Juli 2009 13:03
- Thanks a lot for your time/reply.Waiting for the others as well :)
Thanks for your help - OK the remaing answers are:
3)When passing arguments can you pass collection EG Save(List<customer>customerList) or do you have to pass arrays ?
Answer is : Yes We can do it but need to check third party control's availability for the same
4)Is it possible to redirect from an aspx page to a WCF Method ?
Need to simulate a 3rd party control EG paypal (calling my WCF method "Save" to record the payment into the database and then redirect to an aspx.page" can this be done conceptually?
Answer is:
We cant use Response.Redirect() in servicesBut if you want you can customize services accordinglyCheck this:http://forums.asp.net/t/1275870
5) can you redirect to a web page from a WCF Method?
Answer Is:
You can use document.url=getUrl(call webservice) This is a tricky one Its because you cant use Response.Redirect in services You need to customize Now suppose a scenario in WCF services your client send you a SOAP with UID/PWD and you need to login to another site then you can use this by creating a get Url method ok
Sorry at time due to lak of time I was not able to answer other questions.
Thanks and Regards
Meetu Choudhary
MCPD- Als Antwort vorgeschlagenMeetu ChoudharyMVPSamstag, 4. Juli 2009 17:48
- Als Antwort markiertdevBrix Sonntag, 5. Juli 2009 04:57
- Oh! I joined late the thread.Meetu, you wrote well by giving all the answer. I think there is no need for another opinion now.
- Thank you very much for your replies!!!
Question 4 and 5 I guess require more investigation on my part.
Thanks for your help - Hi DevBrix,
As for Question 4 and 5, I think you don't need to accomplish the redirecting (to page or from) in WCF. And WCF is focusing on distributed processing. For redirecing, you can implement it via some ASP.NET programming tricks. For example:
Your ASP.NET page and sychronously call the WCF method and perform Response.Redirect after the method call return.
Or if the service method is long-run and you need to call it asynchronously, then your page should use some client scripts to constantly poll server for the status of the metho call. If the call finishes(and data is ready), perform the redirection to new page.
Anyway, the redirection should be done at ASP.NET page code.
Hope this help some:)
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

