0

My problem :-

I want to call webservice from Windows Phone App using WebClient/HttpWebRequest.
I have got login success but when I call new function it ask me to login
(The new url call get new asp.net session id),

I have tried all scenario but with no vain, I can't solve this problem.

Please help me to make two url call with the same session id or any way to keep me login and use the second call function.

This is the two url I used:- 1- (login) http://xx.xx.xx.xx/vertexweb10/webservice.svc/login?username=%22user15650%22&password=%22898k%22

2- (Get All symbols) http://xx.xx.xx.xx/vertexweb10/webservice.svc/getallsymbols?AccountID=1122336675

You can find the IP in the comment

Note:- I have used cookie container, pass cookies....., etc with no vain

Please help me with sample code because I'm tired

csharpwinphonexaml
  • 3,659
  • 10
  • 32
  • 63
Jordan
  • 48
  • 7
  • this is the ip 74.54.46.178 – Jordan Apr 13 '14 at 16:16
  • Check this: http://stackoverflow.com/questions/2972643/how-to-use-cookies-with-httpwebrequest And if you want to be helped on the Windows Phone Code you most edit the question adding some of your code – csharpwinphonexaml Apr 14 '14 at 07:03
  • you can check the full code from http://stackoverflow.com/questions/22895469/cookies-not-working-using-webclient-on-windows-phone/22903678?noredirect=1#comment35143924_22903678 , i told you that i have tried all possible solutions but all of them not working so i have paste here the IP and the link to get a help with code .... please advise – Jordan Apr 14 '14 at 12:01
  • What do you know about the service? – csharpwinphonexaml Apr 14 '14 at 13:31
  • what is the information that you need about the service? its wsdl service ? – Jordan Apr 14 '14 at 19:09
  • You know how it does process the login and the session? – csharpwinphonexaml Apr 14 '14 at 19:19
  • yes i know you can check the service URL 74.54.46.178/vertexweb10/webservice.svc?wsdl – Jordan Apr 14 '14 at 20:52
  • I mean if you put a breakpoint in there what gets passed – csharpwinphonexaml Apr 14 '14 at 20:54
  • I`m not experit on windows phone and C# but as i know it pass 2 string username& password,and result is json & httpOnly cookies that have session id ---> the result contain userid if its userid>0 its pass, and if the result is -201 its mean that you are not logged in..help me – Jordan Apr 14 '14 at 21:00
  • Ok one thing i wanted to know if you use this WebService i think that you should do the part that chooses what must be added to the Cookies and what not. At least that's what i think – csharpwinphonexaml Apr 14 '14 at 21:02
  • What does the service expects after login? Witch of the codes that the service gave in the JSON – csharpwinphonexaml Apr 14 '14 at 21:02
  • Sorry dear , i don't understand what did you say i see the cookies in fiddler and i always i get new session id – Jordan Apr 14 '14 at 21:10
  • Please help me .... i have no solutions to solve my problem – Jordan Apr 23 '14 at 00:07

1 Answers1

0

I have solved my problem using

request.CookieContainer = cookieJar;

then i use the same cookieJar on the second request

var request = HttpWebRequest.Create(new    Uri("http://x.x.x.x/vertexweb10/webservice.svc/getallsymbols?AccountID=1122336675")) as     HttpWebRequest;
request.Method = "GET";
request.CookieContainer = cookieJar;
request.BeginGetResponse(ar =>
{
HttpWebRequest req2 = (HttpWebRequest)ar.AsyncState;
using (var response = (HttpWebResponse)req2.EndGetResponse(ar))
{
    using (Stream stream = response.GetResponseStream())
    {
        using (var reader = new StreamReader(stream))
        {




            //the code you need


        }
    }

}

}, request);
Jordan
  • 48
  • 7