else
obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
inputStream.close();
boolean isError = false;
InvocationRequest invocationRequest = null;
if(obj instanceof InvocationRequest)
{
invocationRequest = (InvocationRequest) obj;
Map requestMap = invocationRequest.getRequestPayload();
if (requestMap == null)
{
invocationRequest.setRequestPayload(metadata);
}
else
{
requestMap.putAll(metadata);
}
}
else
{
if(WebUtil.isBinary(requestContentType))
{
invocationRequest = getInvocationRequest(metadata, obj);
}
else
{
invocationRequest = createNewInvocationRequest(metadata, obj);
}
}
String remoteAddressString = request.getRemoteAddr();
InetAddress remoteAddress = InetAddress.getByName(remoteAddressString);
Map requestPayload = invocationRequest.getRequestPayload();
if (requestPayload == null)
{
requestPayload = new HashMap();
invocationRequest.setRequestPayload(requestPayload);
}
requestPayload.put(Remoting.CLIENT_ADDRESS, remoteAddress);
try
{
// call transport on the subclass, get the result to handback
responseObject = invoke(invocationRequest);
}
catch(Throwable ex)
{
log.debug("Error thrown calling invoke on server invoker.", ex);
if (checkForNoExceptionReturn(metadata))
{
log.trace("Returning error message instead of Exception");
response.sendError(500, "Error occurred processing invocation request. ");
return retval;
}
else
{
responseObject = ex;
isError = true;
}
}
int status = 200;
if(responseObject != null)
{
if(isError)
{
status = 500;
}
}
else
{
if (!isRemotingUserAgent || "HEAD".equals(request.getMethod()))
{
status = 204;
}
}
// extract response code/message if exists
Map responseMap = invocationRequest.getReturnPayload();
if(responseMap != null)
{
Integer handlerStatus = (Integer) responseMap.remove(HTTPMetadataConstants.RESPONSE_CODE);
if(handlerStatus != null)
{
status = handlerStatus.intValue();
}
// add any response map headers
Set entries = responseMap.entrySet();
Iterator itr = entries.iterator();
while(itr.hasNext())
{
Map.Entry entry = (Map.Entry)itr.next();
response.addHeader(entry.getKey().toString(), entry.getValue().toString());
}
}
// can't set message anymore as is deprecated
response.setStatus(status);
if (isRemotingUserAgent && !(invocationRequest instanceof CreatedInvocationRequest))
{
responseObject = new InvocationResponse(invocationRequest.getSessionId(),
responseObject, isError, responseMap);
}
if(responseObject != null)
{