You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2005/05/19 05:15:36 UTC
svn commit: r170861 -
/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
Author: ips
Date: Wed May 18 20:15:35 2005
New Revision: 170861
URL: http://svn.apache.org/viewcvs?rev=170861&view=rev
Log:
finished request validation code
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java?rev=170861&r1=170860&r2=170861&view=diff
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java Wed May 18 20:15:35 2005
@@ -33,8 +33,8 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
-import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.HandlerInfo;
+import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.soap.SOAPFaultException;
import javax.xml.soap.MessageFactory;
@@ -165,11 +165,7 @@
else // childElems.length == 1
{
XmlObject requestXBean = toDocumentXmlBean( childElems[0] );
- boolean validateRequestXml = Boolean.valueOf( getHandlerOption( HANDLER_OPT_VALIDATE_REQUEST_XML, "true" ) ).booleanValue();
- if ( validateRequestXml && !requestXBean.validate() )
- {
- throw new JAXRPCException( "validation failed!" ); // TODO
- }
+ validateRequestXml( requestXBean );
if ( methodNameFromAction != null )
{
serviceMethod = getServiceMethod( service, methodNameFromAction, requestXBean ); //get method based on Action
@@ -319,6 +315,31 @@
}
return ( soapMsg );
+ }
+
+ private void validateRequestXml( XmlObject requestXBean )
+ {
+ boolean validateRequestXml = Boolean.valueOf( getHandlerOption( HANDLER_OPT_VALIDATE_REQUEST_XML, "true" ) ).booleanValue();
+ if ( validateRequestXml )
+ {
+ XmlOptions validateOptions = new XmlOptions();
+ List errorList = new ArrayList();
+ validateOptions.setErrorListener(errorList);
+ boolean isValid = requestXBean.validate(validateOptions);
+ if (!isValid)
+ {
+ StringBuffer strBuf = new StringBuffer( "Request body element " );
+ strBuf.append( XmlBeanUtils.getName( requestXBean ) );
+ strBuf.append( " is not valid as per its schema: \n" );
+ for (int i = 0; i < errorList.size(); i++)
+ {
+ strBuf.append( " o " );
+ strBuf.append( errorList.get(i) );
+ strBuf.append( "\n" );
+ }
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT, strBuf.toString() );
+ }
+ }
}
private void handleInternalServerError( Exception e )
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org