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!
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!