C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » WCF »

Newbie to wcf need few basic question answered


Posted Date: 04 Jul 2009      Posted By: Shuby Arora      Member Level: Gold     Points: 1   Responses: 3



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





Regards,
Shuby
Check your feet while you are ranning,
Check your hand while you are writting.....
But never check your swept while you are struggling
Lets Share Knowledge...





Responses

Author: Gaurav Arora    04 Jul 2009Member Level: DiamondRating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

Hi Shiby,

Well I am giving answers as follows:

Ans-1:In steady way, yes WCF method can return collections, check the following example:


[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;
}




Ans-2: The answer is in your first question itself check above example, I have supplied 'desItem' an object of 'Designation' class as parameter.


Ans-3:Sure we can. But while using thrid party controls we need to check the availability for the same.

Ans-4:In simple way, we can't use Response.Redirect() in services. But if you want you can customize services accordingly

Please visist this link:http://forums.asp.net/t/1275870


Ans-5: 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.

Hope above answers give you idea.



Thanks & regards,
Gaurav Arora - Sr. Editor
Me in My Own Style



Author: Shuby Arora    04 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Thanks a lot Gaurav for answering.

My quest is solved

Regards,
Shuby
Check your feet while you are ranning,
Check your hand while you are writting.....
But never check your swept while you are struggling
Lets Share Knowledge...



Author: Miss Meetu Choudhary    04 Jul 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Gaurav,
You have given really nice answer. I quite for answering this question just rating yours.

Thanks and Regards
Miss Meetu Choudhary (Site Coordinator)
Go Green Save Green
My Profile on Google



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Contracts in wcf
Previous : Wcf - property assignment issue
Return to Discussion Forum
Post New Message
Category: WCF

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use