You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2007/02/09 22:23:44 UTC
svn commit: r505505 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/
jaxws/test/org/apache/axis2/jaxws/sample/
metadata/src/org/apache/axis2/jaxws/i18n/
Author: scheu
Date: Fri Feb 9 13:23:43 2007
New Revision: 505505
URL: http://svn.apache.org/viewvc?view=rev&rev=505505
Log:
AXIS2-2156
Contributor:Rich Scheuerle
Quick Fix to detect null arguments in doc/lit bare methods.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?view=diff&rev=505505&r1=505504&r2=505505
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java Fri Feb 9 13:23:43 2007
@@ -28,6 +28,7 @@
import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
import org.apache.axis2.jaxws.description.OperationDescription;
import org.apache.axis2.jaxws.description.ParameterDescription;
+import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
@@ -71,6 +72,7 @@
ParameterDescription[] pds =operationDesc.getParameterDescriptions();
MarshalServiceRuntimeDescription marshalDesc = MethodMarshallerUtils.getMarshalDesc(endpointDesc);
TreeSet<String> packages = marshalDesc.getPackages();
+
// Get the return value.
Class returnType = operationDesc.getResultActualType();
@@ -83,6 +85,13 @@
} else {
returnValue = MethodMarshallerUtils.getReturnValue(packages, message, null, false, null, null);
}
+ //TODO should we allow null if the return is a header?
+ //Validate input parameters for operation and make sure no input parameters are null.
+ //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
+ //to a method then an implementation MUST throw WebServiceException.
+ if (returnValue == null){
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Return", operationDesc.getJavaMethodName(), "doc/lit"));
+ }
}
// Unmarshall the ParamValues from the Message
@@ -128,6 +137,19 @@
// Build the signature arguments
Object[] sigArguments = MethodMarshallerUtils.createRequestSignatureArgs(pds, pvList);
+ // TODO This needs more work. We need to check inside holders of input params. We also
+ // may want to exclude header params from this check
+ //Validate input parameters for operation and make sure no input parameters are null.
+ //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
+ //to a method then an implementation MUST throw WebServiceException.
+ if(sigArguments !=null){
+ for(Object argument:sigArguments){
+ if(argument == null){
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "doc/lit"));
+
+ }
+ }
+ }
return sigArguments;
} catch(Exception e) {
throw ExceptionFactory.makeWebServiceException(e);
@@ -178,6 +200,14 @@
// Put the return object onto the message
Class returnType = operationDesc.getResultActualType();
if (returnType != void.class) {
+ // TODO should we allow null if the return is a header?
+ //Validate input parameters for operation and make sure no input parameters are null.
+ //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
+ //to a method then an implementation MUST throw WebServiceException.
+ if(returnObject == null){
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Return", operationDesc.getJavaMethodName(), "doc/lit"));
+
+ }
MethodMarshallerUtils.toMessage(returnObject, returnType,
operationDesc.getResultTargetNamespace(),
operationDesc.getResultName(), packages, m,
@@ -227,7 +257,24 @@
ParameterDescription[] pds =operationDesc.getParameterDescriptions();
MarshalServiceRuntimeDescription marshalDesc = MethodMarshallerUtils.getMarshalDesc(endpointDesc);
TreeSet<String> packages = marshalDesc.getPackages();
-
+
+ // TODO This needs more work. We need to check inside holders of input params. We also
+ // may want to exclude header params from this check
+ //Validate input parameters for operation and make sure no input parameters are null.
+ //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
+ //to a method then an implementation MUST throw WebServiceException.
+ if(pds.length > 0){
+ if(signatureArguments == null){
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "doc/lit"));
+ }
+ if(signatureArguments !=null){
+ for(Object argument:signatureArguments){
+ if(argument == null){
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "doc/lit"));
+ }
+ }
+ }
+ }
// Create the message
MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
Message m = mf.create(protocol);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?view=diff&rev=505505&r1=505504&r2=505505
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java Fri Feb 9 13:23:43 2007
@@ -96,12 +96,12 @@
//to a method then an implementation MUST throw WebServiceException.
if(pds.length > 0){
if(signatureArguments == null){
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RPCLitMethodMarshallerErr1", "Input"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "rpc/lit"));
}
if(signatureArguments !=null){
for(Object argument:signatureArguments){
if(argument == null){
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RPCLitMethodMarshallerErr1", "Input"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "rpc/lit"));
}
}
}
@@ -185,7 +185,8 @@
if(sigArguments !=null){
for(Object argument:sigArguments){
if(argument == null){
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RPCLitMethodMarshallerErr1", "Input"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Input", operationDesc.getJavaMethodName(), "rpc/lit"));
+
}
}
}
@@ -275,7 +276,8 @@
//As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
//to a method then an implementation MUST throw WebServiceException.
if(returnObject == null){
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RPCLitMethodMarshallerErr1", "Return"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Return", operationDesc.getJavaMethodName(), "rpc/lit"));
+
}
MethodMarshallerUtils.toMessage(returnObject,
@@ -357,7 +359,7 @@
//As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument
//to a method then an implementation MUST throw WebServiceException.
if (returnValue == null){
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("RPCLitMethodMarshallerErr1", "Return"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NullParamErr1", "Return", operationDesc.getJavaMethodName(), "rpc/lit"));
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java?view=diff&rev=505505&r1=505504&r2=505505
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/NonWrapTests.java Fri Feb 9 13:23:43 2007
@@ -6,6 +6,7 @@
import java.util.concurrent.Future;
import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceException;
import junit.framework.TestCase;
import org.apache.axis2.jaxws.sample.nonwrap.sei.DocLitNonWrapPortType;
@@ -47,6 +48,21 @@
fail();
}
}
+
+ public void testTwoWaySyncNull() throws Exception{
+ System.out.println("------------------------------");
+ System.out.println("Test : "+getName());
+ try{
+ TwoWay twoWay = null; // This should cause an WebServiceException
+ DocLitNonWrapService service = new DocLitNonWrapService();
+ DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+ ReturnType returnValue = proxy.twoWay(twoWay);
+ fail("Expected WebServiceException");
+ } catch(WebServiceException e){
+ System.out.println(e.toString());
+ }
+ }
+
public void testTwoWayASyncCallback(){
System.out.println("------------------------------");
System.out.println("Test : "+getName());
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=505505&r1=505504&r2=505505
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties Fri Feb 9 13:23:43 2007
@@ -143,7 +143,7 @@
dispatchBadDOMSource=An invalid DOMSource was encountered during Dispatch. Please use a DOMSource that contains a Node.
convertProblem=An internal error occurred during JAX-WS marshalling. An object of type {0} cannot be converted into the destination type of {1}
invalidPropValue=The value of property {0} was invalid. {1} does not match expected type {2}.
-RPCLitMethodMarshallerErr1={0} argument for Operation cannot be null for RPC/LIT messages.
+NullParamErr1={0} argument in operation {1} is null. This is not allowed for {2} messages.
unknownHost=The host specified by the URL is unknown.
connectionRefused=An attempt to connect to the URL was refused.
mimeBodyPartError=Error: Problem creating mime parts.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org