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 sc...@apache.org on 2005/02/01 18:27:28 UTC
svn commit: r149422 -
incubator/apollo/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
Author: scamp
Date: Tue Feb 1 09:27:26 2005
New Revision: 149422
URL: http://svn.apache.org/viewcvs?view=rev&rev=149422
Log:
updated to change to use the XmlBean version of SOAP Envelope
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?view=diff&r1=149421&r2=149422
==============================================================================
--- 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 Tue Feb 1 09:27:26 2005
@@ -19,12 +19,15 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ws.resource.ResourceContext;
import org.apache.ws.resource.ResourceContextException;
-import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.ws.util.i18n.Messages;
import org.apache.xmlbeans.XmlObject;
-
+import org.apache.xmlbeans.XmlOptions;
+import org.xmlsoap.schemas.soap.envelope.Body;
+import org.xmlsoap.schemas.soap.envelope.Envelope;
+import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
@@ -56,8 +59,10 @@
public abstract class ResourceHandler
extends GenericHandler
{
- private static final Log LOG = LogFactory.getLog( ResourceHandler.class );
- public static final Messages MSG = MessagesImpl.getInstance();
+ private static final Log LOG = LogFactory.getLog( ResourceHandler.class );
+
+ /** DOCUMENT_ME */
+ public static final Messages MSG = MessagesImpl.getInstance( );
/**
* DOCUMENT_ME
@@ -89,6 +94,9 @@
*/
public static final String SERVICE_OPT_RESOURCE_HOME_CLASS_NAME = "resourceHomeClass";
+ /** DOCUMENT_ME */
+ public static final String XMLBBEAN_SOAP_ENVELOPE = "XMLBBEAN_SOAP_ENVELOPE";
+
/**
* DOCUMENT_ME
*
@@ -110,26 +118,33 @@
{
try
{
- LOG.debug(MSG.getMessage(Keys.RECEIVED_REQUEST));
- SOAPMessageContext soapMsgContext = (SOAPMessageContext) msgContext;
- // TODO: read the entire SOAP envelope into an XMLBean, so we don't lose
- // any namespace declarations that might be needed to resolve prefixes
- // used in the request.
- SOAPBody soapBody = soapMsgContext.getMessage( ).getSOAPBody( );
- ResourceContext resourceContext = createResourceContext( soapMsgContext );
- List responseBodyElems = new ArrayList( );
- Iterator requestBodyElemIter = soapBody.getChildElements( );
- while ( requestBodyElemIter.hasNext( ) )
+ LOG.debug( MSG.getMessage( Keys.RECEIVED_REQUEST ) );
+ SOAPMessageContext soapMsgContext = (SOAPMessageContext) msgContext;
+ SOAPEnvelope envelope = soapMsgContext.getMessage( ).getSOAPPart( ).getEnvelope( );
+ EnvelopeDocument envelopeDocXmlBean = EnvelopeDocument.Factory.parse( envelope.toString( ) );
+ Envelope envelopeXmlBean = envelopeDocXmlBean.getEnvelope( );
+ Body body = envelopeXmlBean.getBody( );
+
+ ResourceContext resourceContext = createResourceContext( soapMsgContext );
+ resourceContext.setProperty( XMLBBEAN_SOAP_ENVELOPE, envelopeXmlBean );
+ List responseBodyElems = new ArrayList( );
+
+ XmlObject[] childElements = XmlBeanUtils.getChildElements( body );
+
+ for ( int i = 0; i < childElements.length; i++ )
{
- SOAPElement requestElem = (SOAPElement) requestBodyElemIter.next( );
- XmlObject requestXBean = XmlBeanUtils.toXmlObject( requestElem );
+ XmlObject requestXBean = childElements[i];
+
+ //todo probably need to change method signatures to take types instead of documents to avoid this,
+ requestXBean = XmlObject.Factory.parse( requestXBean.xmlText( new XmlOptions( ).setSaveOuter( ) ) );
if ( requestXBean != null )
{
Class serviceClass = getServiceClassName( resourceContext );
WsrfService service = createService( serviceClass, resourceContext );
Method serviceMethod = getServiceMethod( service, requestXBean );
- LOG.debug(MSG.getMessage( Keys.INVOKE_RESOURCE_METHOD,serviceMethod.getName()));
- XmlObject responseXBean = null;
+ LOG.debug( MSG.getMessage( Keys.INVOKE_RESOURCE_METHOD,
+ serviceMethod.getName( ) ) );
+ XmlObject responseXBean = null;
try
{
responseXBean = (XmlObject) serviceMethod.invoke( service,
@@ -140,7 +155,10 @@
}
catch ( InvocationTargetException ite )
{
- LOG.error(MSG.getMessage(Keys.ERROR_INVOKING_METHOD_ON_SERVICE,serviceMethod.getName(),serviceClass.getName(),ite));
+ LOG.error( MSG.getMessage( Keys.ERROR_INVOKING_METHOD_ON_SERVICE,
+ serviceMethod.getName( ),
+ serviceClass.getName( ),
+ ite ) );
throw ite.getCause( );
}
@@ -159,7 +177,7 @@
else
{
t.printStackTrace( );
- throw new JAXRPCException( MSG.getMessage(Keys.UNEXPECTED_ERROR_WITH_EXCEPTION,t ));
+ throw new JAXRPCException( MSG.getMessage( Keys.UNEXPECTED_ERROR_WITH_EXCEPTION, t ) );
}
}
@@ -175,10 +193,11 @@
*/
public boolean handleResponse( MessageContext messageContext )
{
- LOG.debug(MSG.getMessage( Keys.HANDLING_RESPONSE));
+ LOG.debug( MSG.getMessage( Keys.HANDLING_RESPONSE ) );
SOAPEnvelope responseEnvelope = getResponseEnvelope( (SOAPMessageContext) messageContext );
List responseBodyElems = (List) messageContext.getProperty( WSRF_RESPONSE_XMLOBJECT_LIST );
- LOG.debug(MSG.getMessage( Keys.FOUND_RESP_ELEMS,Integer.toString(responseBodyElems.size())));
+ LOG.debug( MSG.getMessage( Keys.FOUND_RESP_ELEMS,
+ Integer.toString( responseBodyElems.size( ) ) ) );
if ( responseBodyElems != null )
{
@@ -200,7 +219,7 @@
else
{
e.printStackTrace( );
- throw new JAXRPCException( MSG.getMessage( Keys.UNEXPECTED_ERROR_WITH_EXCEPTION, e ));
+ throw new JAXRPCException( MSG.getMessage( Keys.UNEXPECTED_ERROR_WITH_EXCEPTION, e ) );
}
}
}
@@ -233,16 +252,19 @@
*
* @return DOCUMENT_ME
*/
- protected Class getServiceClassName( ResourceContext resourceContext ) throws ResourceContextException, ClassNotFoundException
+ protected Class getServiceClassName( ResourceContext resourceContext )
+ throws ResourceContextException,
+ ClassNotFoundException
{
- String serviceClassName = resourceContext.getResourceHome().getServiceClassName();
- LOG.debug(MSG.getMessage( Keys.RETRIEVED_SERVICE_CLASSNAME,serviceClassName));
+ String serviceClassName = resourceContext.getResourceHome( ).getServiceClassName( );
+ LOG.debug( MSG.getMessage( Keys.RETRIEVED_SERVICE_CLASSNAME, serviceClassName ) );
if ( serviceClassName == null )
{
- throw new JAXRPCException( MSG.getMessage( Keys.SERVICE_OPT_UNDEFINED_IN_HOME,SERVICE_OPT_SERVICE_CLASS_NAME) );
+ throw new JAXRPCException( MSG.getMessage( Keys.SERVICE_OPT_UNDEFINED_IN_HOME,
+ SERVICE_OPT_SERVICE_CLASS_NAME ) );
}
- Class serviceClass = Class.forName(serviceClassName);
+ Class serviceClass = Class.forName( serviceClassName );
return serviceClass;
}
@@ -312,13 +334,14 @@
private Method getServiceMethod( WsrfService service,
XmlObject requestXBean )
{
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( MSG.getMessage( Keys.DERIVE_SERVICE_NAME_FROM_REQ,
+ requestXBean.toString( ) ) );
+ }
- if (LOG.isDebugEnabled())
- {
- LOG.debug(MSG.getMessage( Keys.DERIVE_SERVICE_NAME_FROM_REQ,requestXBean.toString()));
- }
- Method serviceMethod = null;
- String serviceMethodName =
+ Method serviceMethod = null;
+ String serviceMethodName =
service.getMethodNameMap( ).getMethodName( XmlBeanUtils.getName( requestXBean ) );
Method[] methods = service.getClass( ).getMethods( );
@@ -336,10 +359,13 @@
if ( serviceMethod == null )
{
- throw new JAXRPCException( MSG.getMessage( Keys.UNABLE_TO_FIND_METHOD_IN_SERVICE,serviceMethodName,service.getClass( ).getName( ) ));
+ throw new JAXRPCException( MSG.getMessage( Keys.UNABLE_TO_FIND_METHOD_IN_SERVICE,
+ serviceMethodName,
+ service.getClass( ).getName( ) ) );
}
- LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD,serviceMethod.getName() ));
+ LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD,
+ serviceMethod.getName( ) ) );
return serviceMethod;
}
@@ -351,7 +377,7 @@
}
catch ( SOAPException soape )
{
- throw new JAXRPCException( MSG.getMessage( Keys.FAILED_TO_CREATE_SOAP_MSG) );
+ throw new JAXRPCException( MSG.getMessage( Keys.FAILED_TO_CREATE_SOAP_MSG ) );
}
}
@@ -362,7 +388,7 @@
IllegalAccessException,
InvocationTargetException
{
- LOG.debug(MSG.getMessage( Keys.CREATING_INSTANCE_OF_SERVICE,serviceClass));
+ LOG.debug( MSG.getMessage( Keys.CREATING_INSTANCE_OF_SERVICE, serviceClass ) );
Constructor serviceCtor = serviceClass.getConstructor( new Class[]
{
ResourceContext.class
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org