CookieContainer in CF problem

G

Guest

I studied the previous post in this topic for C#. Failed to understand the
sample code.
Could some one explain how to solve it in VB.NET?
Add a CookieContainer in the webservice class?

Appreciate your reply!
 
A

Alex Feinman [MVP]

I am not going to rewrite the sample code in VB.NET. Simply place the file
WebRequestHelper.cs into a new C# class library project, compile it and
reference it from your VB code.
In VB code add

private DIm ReqData as RequestData

Sub New
...
IntializeComponent()
Dim svc as New YourServiceClass()
ReqData = new RequestData(svc.Url)

End Sub
 
G

Guest

thank you. done, but there is an error while referencing the C# class lib.
Error: The dependency 'mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' in project 'SmartDeviceApplication1' cannot
be copied to the run directory because it would conflict with dependency
'mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac'.

Seems the lib is not compatible with CF?
 
S

Sergey Bogdanov

I believe you created class library incorrectly. Instead of Smart Device
Application->Class Library you chose standard Class Library for
desktop applications. That is why two different versions of mscorlib
conflict with each other.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
G

Guest

thank all you guys. I added the cookies, but still not fixed my problem.
here is my code calling the service, works fine on PC platform, and returns
nothing on CF.
responseMessage = svc.ProcessRequest(requestMessage)
Now I added cookies:
svc = New Myservice
ReqData = New SessionAwareWebSvcClient.RequestData(svc.Url)
...
responseMessage = svc.ProcessRequest(requestMessage)
still returns nothing.
BTW, the structure of responseMessage and requestMessage is sort of
complicated.

What can I do now?
 
J

Jeremy

hey

there's not much you can get wrong.. alex's helperclass is great (btw,
thanks alex!). All I do in my application is the following :

<code>
Service1 ws = new Service1();
ReqData = new RequestData(ws.Url);
IAsyncResult ar = ws.BegingetSeatingChartFromDb("your parameters", new
AsyncCallback(callBackMethod), ws);
<\code>

and then have your callback method do whatever you need to do. The only line
you need to add when using alex's code is the ReqData line. You don't
actually need to worry about anything else relating to your cookies and your
unique ID, the helper class takes care of that.

Hope that helps
 
G

Guest

thanks. I've being debugging whole day, still no clue.
something to verify:
1. I don't need to change anything on the service, right?
2. the parameters being passed are in xml format, is it ok?
3. I removed "using SessionAwareWebSvcClient.SessionService;" from the
helperclass , it should be independent from the specific service, right?

help me, help me ,thanks a lot
 
A

Alex Feinman [MVP]

Could you post the url to your web service?
Also, make sure that you only instantiate the RequestData object once
 
J

Jeremy

1. don't change anything in your service. Just instantiate ReqData.
2. Doesn't really matter in what form the parameters are being passed afaik.
3. make sure you change the namespace to your own namespace and make a
reference to your webservice in the helperclass.
 
G

Guest

yes, I didn't make a reference to the webservice in helperclass.
But I also need to add reference to the webservice in my client.
Would thiese two cause conflict?

I tried to add the reference, still got nothing returned.
I guess I must translate the helperclass into VB and add it to my client. ??

thanks
 
J

Jeremy

here's what you ought to do:

1) don't touch your webservice (i.e. the service running on your server)
2) in your client (i.e. netcf) app, add as existing item webrequesthelper.cs
3) in webrequesthelper.cs change the "use ...." to "use myapp.mywebservice"
where myapp.mywebservice is the name of your webservice
4) in webrequesthelper.cs change the namespace to "mynamespace" where
mynamespace is the namespace of your netcf application
5) in your form1.cs file (where form1 is your form in your netcf app)
instantiate a new object of type RequestData like this "RequestData
reqData;"
6) where you create your webservice do the following :
mywebservice ws = new mywebservice();
reqData = new RequestData(ws.Url);

that's all you need to do. Whenever you will make a connection with your
webservice the the helperclass will make sure that the same session id is
sent so that you can use cookies. yum!
 
G

Guest

Alex , you said cookie persistence is not handled in the helperclass,
does it mean it cannot support session-persistent?
 
G

Guest

Alex , you said cookie persistence is not handled in this solution, does it
mean it cannot support session-persistent service?
Any materials I can refer to implement the cookie persistence ?

thanks
 
A

Alex Feinman [MVP]

There are 2 types of cookies - ones that are stored in the file system
(think of things like web sites recognizing you on your next visit) and the
ones that live while your web client is running. Web session cookie is the
example of latter. My code does not support the first type - does not save
anything on disk, nor reads it from disk.

One think that you need to understand about session cookie is that the
server will send it to you only once - on the first request, but you will
need to send it back every time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top