Re: Internal Server Error / DirectAction

"Jerry W. Walker" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi, Simon,

On Apr 7, 2006, at 8:13 AM, Simon wrote:

> Hi Jerry - thanks.
>
> How do I log the requests and response ?

Try adding the following code to your WO Application class's  
constructor method:

     String theResponse;
     theResponse = System.getProperty("DisplayHeaders");
     displayHeaders = ("true".equals(theResponse) || "YES".equals 
(theResponse));
     LOGGER.debug("displayHeaders = " + ( displayHeaders ? "YES" :  
"NO" ));
		
     theResponse = System.getProperty("DisplayHeaderContent");
     displayHeaderContent = ("true".equals(theResponse) ||  
"YES".equals(theResponse));
     LOGGER.debug("displayHeaderContent = " +  
( displayHeaderContent ? "YES" : "NO" ));

Then add the following method to your WO app's Application class:

     public WOResponse dispatchRequest( WORequest request )
     {
		if (displayHeaders) {
			LOGGER.debug( "*********** The request = " + request.toString() );
			if (displayHeaderContent)
				LOGGER.debug( "*********** The request content = " +  
request.contentString() );
		}
		WOResponse response = super.dispatchRequest( request );
		if (displayHeaders) {
			LOGGER.debug( "*********** The response = " + response.toString() );
			if (displayHeaderContent)
				LOGGER.debug( "*********** The response content = " +  
response.contentString() );
		}
         return response;
     }

Finally, set the two runtime parameters, DisplayHeaders and  
DisplayHeaderContent, appropriately to log the requests and responses  
to determine where the holdup is occurring in the network.

The code is a modification of something I got from Chuck Hill (either  
his & Sacha's book or a response on one of the lists, I don't  
remember). It also presumes that you're running log4j. If you're not,  
then change the LOGGER.debug messages to System.out.println, or some  
other appropriate logging statements.

> I think the problem might be that the external system is streaming  
> the file to us, and hence when i call request().contentString() i  
> am getting a null. i have changed the code now to use the  
> WOStreamRequestHandler instead of the WODirectActionHandler and am  
> just waiting for the supplier to change the url they are posting to.

That sounds like a strong possibility.

HTH

Regards,
Jerry

> Simon
> On 6 Apr 2006, at 20:57, Jerry W. Walker wrote:
>> Hi, Simon,
>>
>> I suggest two things:
>>
>>   * take a look at the network and Apache logs
>>
>>   * if the request is getting through to your application, log the  
>> requests and responses.
>>
>> Regards,
>> Jerry
>>
>> On Apr 6, 2006, at 1:08 PM, Simon wrote:
>>
>>> Hi all -
>>>
>>> i'm working on an interface to a external system which is posting  
>>> an xml file to our application. the external system http-post's  
>>> the file to a url, with the filename as the single parameter in  
>>> the url - eg:
>>>
>>> http://claney.com/cgi-bin/WebObjects/Handler.woa/wa/DirectAction/ 
>>> handler?filename=EBO_DETAIL_MM_35_0000000142.xml
>>>
>>> My handler action simply writes the file to disk, and looks like  
>>> this:
>>>
>>> 	public WOActionResults handoffAction() {
>>> 		String result = "";
>>> 		try {
>>> 			String content = request().contentString();
>>> 			String filename = request().formValueForKey 
>>> ("filename").toString();
>>> 			BufferedWriter out = new BufferedWriter(new FileWriter("/ 
>>> Library/Handoffs/"+filename));
>>> 			out.write(content);
>>> 			out.close();
>>> 			result = "OK";
>>> 		} catch (Exception e) {
>>> 			System.out.println(e.getMessage());
>>> 			result = Utilities.getStackTrace(e);
>>> 			System.out.println(result);
>>> 		}
>>> 		Main pg = (Main)pageWithName("Main");
>>> 		pg.setResponseMessage(result);
>>> 		return pg;
>>> 	}
>>>
>>>
>>> However, the external system is reporting an Internal Server error:
>>>
>>> *****2006-04-05T09:07:26:5565 Info      NETWORK SERVICE@EVOLVIWEB03
>>> *****
>>> *****  3480 -  2773 Videcom.Utils.HttpHelper
>>> Sending to http://claney.com/cgi-bin/WebObjects/Handler.woa/wa/ 
>>> DirectAction/handoff?filename=EBO_DETAIL_MM_35_0000000142.xml
>>> *****2006-04-05T09:07:27:1502 Error      NETWORK SERVICE@EVOLVIWEB03
>>> *****
>>> *****  3480 -  2773 Videcom.TravelPackOnline.KernelServer.Transport
>>> Error when HTTPing file EBO_DETAIL_MM_35_0000000142.xml to http:// 
>>> claney.com/cgi-bin/WebObjects/Handler.woa/wa/DirectAction/ 
>>> handoff. Exception = The remote server returned an error: (500)  
>>> Internal Server Error
>>>
>>>
>>> Unfortunately the external system is a supplier, and therefore I  
>>> have no access to their code (and to be honest their developers  
>>> are not being too helpful). there is nothing showing in the  
>>> webobjects logs.
>>>
>>> any ideas where i start to debug this ?
>>>
>>> thanks, simon

--
__ Jerry W. Walker,
    WebObjects Developer/Instructor for High Performance Industrial  
Strength Internet Enabled Systems

     [email protected]
     203 278-4085        office
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.