Задайте вопросЗадайте вопрос
 

ОтвеченоNewbie to WCF need few basic question answered

  • 4 июля 2009 г. 11:29devBrix Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    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

Ответы

  • 4 июля 2009 г. 17:34Meetu ChoudharyMVPМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено
    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 services
    But if you want you can customize services accordingly
    Check 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
    • Предложено в качестве ответаMeetu ChoudharyMVP4 июля 2009 г. 17:48
    • Помечено в качестве ответаdevBrix 5 июля 2009 г. 4:57
    •  

Все ответы

  • 4 июля 2009 г. 12:21Meetu ChoudharyMVPМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Предложенный ответС кодом
     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:
     [OperationContract]
            [WebGet]
            List<int> UpdateDesignation(Designation desItem);
    
    in class:

     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
    • Предложено в качестве ответаMeetu ChoudharyMVP4 июля 2009 г. 13:03
    •  
  • 4 июля 2009 г. 16:46devBrix Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Thanks a lot for your time/reply.

    Waiting for the others as well :)


    Thanks for your help
  • 4 июля 2009 г. 17:34Meetu ChoudharyMVPМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено
    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 services
    But if you want you can customize services accordingly
    Check 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
    • Предложено в качестве ответаMeetu ChoudharyMVP4 июля 2009 г. 17:48
    • Помечено в качестве ответаdevBrix 5 июля 2009 г. 4:57
    •  
  • 4 июля 2009 г. 18:10Gaurav Arora Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.
  • 5 июля 2009 г. 4:57devBrix Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Thank you very much for your replies!!!

    Question  4 and 5 I guess require more investigation on my part.

    Thanks for your help
  • 8 июля 2009 г. 12:06Steven Cheng - MSFTMSFT, МодераторМедали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    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.