View Full Version : http data / java problem
ch_bowen
07-10-2003, 07:05 AM
I am unable to retrieve a dataset after making a request to a servlet to process XML. I am confirming that the XML is being printed out properly, but when calling dataset.getPointer().serialize(), there is only the 'root' element present. The dataset is properly making the request to the servlet and it is processing xml fine. The problem is that dataset is not being returned. I was wondering if I am setting up my HttpServletResponse object up wrong or if there is something I am missing. If my dataset src has hardcoded xml, the UI parses it fine. Below is the code where my servlet is retrieving xml for my UI to parse. Am I setting up the HttpServletResponse's PrintWriter object properly or anything obvious I am missing? Thank you, your help is appreciated.
if(result.isSynchronous()){
response.setStatus(HttpServletResponse.SC_OK);
System.out.println("response is : " + result.getXML());
out.write(result.getXML());
out.flush();
}
antun
07-10-2003, 07:28 AM
Can you post the LZX code you're using?
-Antun
In your example, are you sure your debug print statement is not printing to the data output stream?
if(result.isSynchronous()){
response.setStatus(HttpServletResponse.SC_OK);
System.out.println("response is : " + result.getXML());
out.write(result.getXML());
out.flush();
}
Instead of printing out a debug statement, can you
install your servlet and then use "wget" or some other http client utility to fetch the URL and verify that you are getting back well formed XML when you
fetch data over HTTP?
Can you post your source code for the servlet, and
Can you post the exact XML data which is coming back from your servlet, and include HTTP headers if you can.
ch_bowen
07-10-2003, 08:52 AM
Here is the xml that is printed out on a System.out.println():
<?xmlversion='1.0'encoding='ISO-8859-1'?>
<participant active='true'
id='admin' xmlns='http://www.testing.ca/common/csp/participants'>
<profile password='wPSvHSxgUvkMRFrHYDpxOnx1Th8=' emailAddress='joe@hotmail.com'
firstName='Administrator'
lastName='Administrator'/>
<preference value='true'
id='EMAIL_PREFERENCE'/>
<roleRef id='admin'/>
<scopeValue id='participant'>
<value id='*'/>
<scopeValue id='commodity'>
<value id='*'/>
</scopeValue>
</participant>
Here is how I am retrieving the dataset in my lzx platform:
<dataset name="participants" autorequest="true" src="http://localhost:8080/webapp/participants/participant/admin">
</dataset>
Also, when I hit that url from my browser, the xml is not being printed into the browser at all, although the xml I'm expecting is being printed to the console with a System.out.println() on the previous line so I know that I am getting the xml that I am requesting. Here is the piece of servlet code:
response.setContentType("text/xml");
Transporter.setup(new LocalChannel());
TransporterResponse res = null;
try{
res = Transporter.send(resource, command, arg, securityToken, params);
if(res.isSynchronous()){
response.setStatus(HttpServletResponse.SC_OK);
System.out.println("response is : " + res.getResult());
out.write(res.getResult());
out.flush();
}
Thanks again for the help.
antun
07-10-2003, 08:57 AM
Also, when I hit that url from my browser, the xml is not being printed into the browser at all, although the xml I'm expecting is being printed to the console with a System.out.println() on the previous line so I know that I am getting the xml that I am requesting.
That's a bad sign! You have to be able to hit your servlet from a browser and see the XML, just like you can hit the service for the weather app:
http://www.laszlosystems.com/cgi-pub/weather.cgi?zip=19702
The LPS will be hitting it in the same way.
For that, I used text/plain as the Content-Type header for the response.
-Antun
ch_bowen
07-10-2003, 09:00 AM
well, somewhat. It turns out that its to do with some ServletFilters that are being used for security purposes. It was not related to laszlo. When I tested this from a different url that was not filtered on, the datapath was set fine.
I apologize for wasting anyone's time and I appreciate the help.
antun
07-10-2003, 09:15 AM
I apologize for wasting anyone's time...
Don't be silly - it's a learning experience for us all :)
For my own curiosity, the servlet fiters you mentioned - do they prevent the servlet from sending out certain kinds of headers?
What servlet container were you using? How did you disable them?
-Antun
ch_bowen
07-10-2003, 11:16 AM
Well, we thought it may be something to do with the servletfilters initially. When deploying the lzx file to a different location where the url is not secured, the dataset can retrieve the proper data that it is requesting via http. However, now we are trying to have multiple datasets that do http requests for xml and we are having some problems again. The requests are made and the xml is retreived (from the servlets perspective), however only one of the datasets are are set properly. I am assuming that there can be multiple datasets in a lzx file that use http requests for data, correct?
antun
07-10-2003, 12:00 PM
I am assuming that there can be multiple datasets in a lzx file that use http requests for data, correct?
Absolutely!
How are you confirming this:
however only one of the datasets are are set
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.