Fazer uma PerguntaFazer uma Pergunta
 

RespondidoNewbie to WCF need few basic question answered

  • sábado, 4 de julho de 2009 11:29devBrix Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    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

Respostas

  • sábado, 4 de julho de 2009 17:34Meetu ChoudharyMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    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
    • Sugerido como RespostaMeetu ChoudharyMVPsábado, 4 de julho de 2009 17:48
    • Marcado como RespostadevBrix domingo, 5 de julho de 2009 4:57
    •  

Todas as Respostas

  • sábado, 4 de julho de 2009 12:21Meetu ChoudharyMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Resposta PropostaContém Código
     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
  • sábado, 4 de julho de 2009 16:46devBrix Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Thanks a lot for your time/reply.

    Waiting for the others as well :)


    Thanks for your help
  • sábado, 4 de julho de 2009 17:34Meetu ChoudharyMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    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
    • Sugerido como RespostaMeetu ChoudharyMVPsábado, 4 de julho de 2009 17:48
    • Marcado como RespostadevBrix domingo, 5 de julho de 2009 4:57
    •  
  • sábado, 4 de julho de 2009 18:10Gaurav Arora Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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.
  • domingo, 5 de julho de 2009 4:57devBrix Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Thank you very much for your replies!!!

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

    Thanks for your help
  • quarta-feira, 8 de julho de 2009 12:06Steven Cheng - MSFTMSFT, ModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    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.