Cookie container

I am developing an application that would use many external web services. One of the webservices I need to use, is not stateless. So it defines and uses session state variables. Because of this reason, my client application has to permit the usage of cookies. Or as I am being told by the web service server application :
"For client applications that do not use cookies (for example Windows Forms applications) you can use objects of type CookieContainer"
The problem is that I am not able to access the full functionality of the webservice without using these cookies.
As far as I know... there is no such object type in Delphi.
I am open to suggestions (with code snippets of course)

LVL 11
calinutzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ebob42Commented:
After you import the web service, and you create an instance of the proxy, let's say in variable WS, then you can create a new CookieContainer for the WS.CookieContainer property.

CookieContainer is defined in the System.Web.Services.Protocols namespace.
0
ebob42Commented:
Note that CookieContainer should only be needed if you use Delphi Prism or an older Delphi for .NET client.

When using Delphi for Win32, there is no need for a cookieContainer, since the Win32 client will automatically accept the cookies for you.
0
calinutzAuthor Commented:
I use delphi 2010 (not .NET nor Prism)... so I have no access to the cookie container.
And as for Delphi I have problems with obtaining a correct result from a web service function, and the people from the server told me it's because of the cookies...
Suggestions?
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

calinutzAuthor Commented:
Dear Mr. Bob I was not expecting you to show up here and try to help me out. (I am a fan of your website). I have probably read all your articles about SOAP and Delphi, and I based my client app on hints from your articles (and other sources).
Please get back to me with a solution for this problem. I'm counting on your expertise in using SOAP with Delphi ;)

I assume Delphi 2010 does not use the cookies correctly (in my case to say the least).

To make things short, the webservice has a few functions (5)... I need to use 2 of them. After calling the first function, I must call the second function... (with the same arguments). Apparently it is necessary  to call the first function before calling the second. But when I call the functions... I call the first one... ok, then I call the second... and I receive an error message saying that I did not call the first function.

Based on the hint about the cookies, that the web service owners previously sent to me, I assume that there should be a cookie filled with something in the back after calling function one ... cookie that is used by the function two.

Thanks
0
ebob42Commented:
I'm not sure why Delphi 2010 doesn't handle the cookies correcrlt.

Do you have a WSDL example or location, so I can try to import and build a client myself? Or is this a private web service?
0
calinutzAuthor Commented:
It is private... I could give the credentials and WSDL to you, but not publicly...
Tell me how to do it, and I'll do it...
Of course, the conclusions will be posted here... only without the sensitive information.
Thank you and I will be waiting for your post with the communications means to use to pass you the WSDL and credentials
0
calinutzAuthor Commented:
Send me an email on my email (from my profile) and I'll reply with the informations.
0
calinutzAuthor Commented:
I have sent you the test project.
Please tell me what you think.
0
ebob42Commented:
Sorry, I took a few days off, I will look at your project later today...
0
ebob42Commented:
I see nothing wrong with your code. The WSDL does not specify any SOAP header (which would be useful) and as far as my tests show for example with ASP.NET sessions (that also require a cookie from the server to the client that gets returned with each follow-up request), the Delphi Win32 clients support cookie handling out-of-the-box.

I wonder if the problem is at the server side. Looking at the WSDL, there are some aspects that make me wonder about the server implementation. Seeing namespaces with tempuri.org only increases that feeling. I would see if they can modify the server to use SOAP headers, use a correct namespace, etc.
0
calinutzAuthor Commented:
Since this goes nowhere... my code should work as it is... and I want to give you points... please help me with another problem in the same area.
I have 2 links. One is a WSDL and the other is an XSD. The problem is that the XSD contains declarations that are used by the WSDL, and the WSDL does not work correctly with xsd:import.
My conclusion is that the XSD contents should somehow be merged with the WSDL. So the first steps are to save the contents of both links (WSDL + XSD) in 2 local files with appropriate extensions. And then the xsd contents should somehow be added to the WSDL. Since Delphi's WSDL importer wizard apparently does not work well with xsd:import, instead of the reference to the import... there probably should be directly the contents of the xsd...
Here are the links. Please merge them correctly because I have no idea how to do it properly (and I'll give you the points):

https://www.omniasigonline.ro/portalAsiguratori/QuotationService?wsdl   
https://www.omniasigonline.ro/portalAsiguratori/QuotationService?xsd=1
0
ebob42Commented:
I saved the first WSDL URL as QuotationService.wsdl and the second as QuotationService.xsd, and then only had to edit QuotationService.wsdl and change schemaLocation="QuotationService.xsd"

The two files plus the import unit (by the WSDLIMP for Delphi 2010) are attached. The .wsdl file is renamed to .xml, otherwise I was not allowed to upload it.
QuotationService.zip
0
ebob42Commented:
As a final comment: for more information on Delphi 2010 XML, SOAP and Web Services, check out my latest publication at http://www.bobswart.nl/Weblog/Blog.aspx?RootId=5:4008
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
calinutzAuthor Commented:
I will definitely buy your publication.
Thanks a lot. I never would have thought to replace the path of the SchemaLocation. I always thought of something complicated with XML syntax.
So the solution is brilliant.
You deserve all the points. Too bad I do not have more points to raise them a little.

Thank you
0
calinutzAuthor Commented:
Brilliant
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.