Internet class differences...

  • Thread starter Thread starter Peter Hayes
  • Start date Start date
P

Peter Hayes

I've tried this on another group without any resolution, so let me see
if anyone here has an answer - please! ;-)

I have a database with which I must communicate queries via a web-based
interface. The queries are not in a standard format, but involve strings
such as

....&fieldA=value1&fieldA=value2&...fieldA=valuej&fieldB=valueK...

being sent to the web interface.

This was started as a C++.NET project for some other reasons unrelated
to the networking. Initially a WebClient class was used. An object was
instantiated and the 'name-value' method of sending data was used.

This worked fine for submitting the query. The result of the query is an
HTML page returned (from the server)containing some parameters and a
javascript method that opens a new window with the results... the
parameters are sent to the new page requesting the results (via a
sessionID cookie and sequence number). So, after sending the initial
query, the reply is parsed to obtain the new page and sequence number.
The same object - the WebClient - is redirected to the page and
retrieves the query results.

This all works fine for simple queries - where fieldA has only a single
value required. However, if fieldA requires multiple values, the
WebCLient (actually the name-value collection of the WebClient) believes
that multiple values should be sent as

....&fieldA=value1,value2,value3...

which causes the query processor at the database end to choke.

I have not found any means of using the WebCLient that allows me to send
all of the selections I need for the queries without reformatting
something in the query. So, I tried the HTTPWebRequest class.

The HTTPWebRequest object does a dandy job of allowing me to format my
queries so that the database at the other end (and all the query
processing) is happy - I have tried a number of complicated ones and
always receive the 'redirect' javascript response indicating that the
query processed properly.

However, there seems to be no way to redirect the HTTPWebCLient class to
a new page, so a new object needs to be created. I use the same
cookiecollection for both the initial query request and the second
results request (two different HTTPWebCLient objects) so that the second
object obtains the sessionID cookie from the first one. However, it does
not retrieve the results but, instead, is sent to a login page from
which it is impossible to retrieve the results (the login initiates a
new session, new sessionID, therefore makes access to the results
impossible).

I have used an ethernet sniffer to inspect the packets from the
WebClient (which works completely with simple queries) and the
HTTPWebRequest (which submits the query successfully but seems unable to
submit the cookie and sequence number properly to retrieve the results).
The only difference I can see in the packets is that the WebCLient
orders the header values slightly differently (the same values are
present but their order is different from the HTTPWebRequest ordering of
the same values) and the WebClient returns not just the cookie
name-value combination, but also the 'Path=/' parameter from the
internal cookie. The HTTPWebRequest has the Path member set properly (to
'/') but does not return this with the cookie to the redirected server
page - only the name-value members are sent.

I don't know if the order or the lack of a 'Path=/' in the header/cookie
causes the failure, but something is doing it and I can't figure out how
to change the behavior...

I'm tearing my hair out on this and looking for any help/ideas.

Thanks a lot for anything to follow up on! 8-)
 
Peter,

Are you able to replace this by a webservice.

A webservice is very easy to make with visual Studio Net.

Cor
 
I'm afraid that I have no control over the server side and, I think, the
web service would need to be created to interface with the database server.

The database and web interface to the server is produced by a different
company (not the one for which I'm programming) and it just happens that
they and we share clients (and it would be helpful if our database app
could obtain selected information from their database app). But, this is
the interface they have provided us.

Would a MFC version of this provide more flexibility? I suspect it would
be more difficult to write (and networking is obviously not my forte -
nor is MFC, for that matter!) but might allow more control over the
network packets?

I do appreciate the reply! Thank you, Cor! If I've misunderstood how web
services might be used, please correct the ignorant! It just seems that,
given that the interface to this other database is constant and not
subject to changes on my account, I need to be able to work with that
interface someplace.


Pete
 
Cor,

That reference has given me an idea... the one thing I have not done is
to try to save the whole header from the first HTTPWebClient and use it
in the second... I don't even know if that is possible, but the example
you linked to did access the header of the HTTPWebCLient object, so...
possibly this can be done!

I'll let you know (here) how it works out!

Thank you!
 
Thus wrote Peter,
I've tried this on another group without any resolution, so let me see
if anyone here has an answer - please! ;-) [...]
I have used an ethernet sniffer to inspect the packets from the
WebClient (which works completely with simple queries) and the
HTTPWebRequest (which submits the query successfully but seems unable
to submit the cookie and sequence number properly to retrieve the
results). The only difference I can see in the packets is that the
WebCLient orders the header values slightly differently (the same
values are present but their order is different from the
HTTPWebRequest ordering of the same values) and the WebClient returns
not just the cookie name-value combination, but also the 'Path=/'
parameter from the internal cookie. The HTTPWebRequest has the Path
member set properly (to '/') but does not return this with the cookie
to the redirected server page - only the name-value members are sent.

I don't know if the order or the lack of a 'Path=/' in the
header/cookie causes the failure, but something is doing it and I
can't figure out how to change the behavior...

I'm tearing my hair out on this and looking for any help/ideas.

Thanks a lot for anything to follow up on! 8-)

Cookie processing in HttpWebRequest requires a single CookieContainer to
be associated with each request in your HTTP "conversation". I guess you're
missing one ;-)

Cheers,
 
Hi Joerg,

Do you mean to say that I need two cookie containers... one for the
first HTTPWebRequest object and a different one for the second? I would
then (I assume) recreate any cookie from the first in the second...

This sounds wrong, but it could just be me! I presently use the same
cookie container for both HTTPWebRequest objects, so it has all the
cookies from the first object available to the second... which does seem
to use and send them...

Have I got your thought correct? I create two separate cookie containers...

And thank you for the help... nothing I've tried so far works! It's so
darn close to working, but not quite there...

Pete


Joerg said:
Thus wrote Peter,
I've tried this on another group without any resolution, so let me see
if anyone here has an answer - please! ;-)
[...]

I have used an ethernet sniffer to inspect the packets from the
WebClient (which works completely with simple queries) and the
HTTPWebRequest (which submits the query successfully but seems unable
to submit the cookie and sequence number properly to retrieve the
results). The only difference I can see in the packets is that the
WebCLient orders the header values slightly differently (the same
values are present but their order is different from the
HTTPWebRequest ordering of the same values) and the WebClient returns
not just the cookie name-value combination, but also the 'Path=/'
parameter from the internal cookie. The HTTPWebRequest has the Path
member set properly (to '/') but does not return this with the cookie
to the redirected server page - only the name-value members are sent.

I don't know if the order or the lack of a 'Path=/' in the
header/cookie causes the failure, but something is doing it and I
can't figure out how to change the behavior...

I'm tearing my hair out on this and looking for any help/ideas.

Thanks a lot for anything to follow up on! 8-)


Cookie processing in HttpWebRequest requires a single CookieContainer to
be associated with each request in your HTTP "conversation". I guess
you're missing one ;-)

Cheers,
 
Back
Top