Author: jim.ma
Date: 2010-04-05 00:29:32 -0400 (Mon, 05 Apr 2010)
New Revision: 11935
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/JBWS2969TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/jboss-web.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/web.xml
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBPAPP-3984]: Add rpc/lit parameter null check to holder class
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2010-04-02
16:10:22 UTC (rev 11934)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2010-04-05
04:29:32 UTC (rev 11935)
@@ -289,7 +289,8 @@
for (QName qname : epInv.getRequestParamNames())
{
ParameterMetaData paramMetaData = opMetaData.getParameter(qname);
- if (paramMetaData.getMode().equals(ParameterMode.IN) &&
epInv.getRequestParamValue(qname) == null)
+ if ((paramMetaData.getMode().equals(ParameterMode.IN) ||
paramMetaData.getMode().equals(ParameterMode.INOUT))
+ && epInv.getRequestParamValue(qname) == null)
{
throw new WebServiceException("The RPC/Literal Operation [" +
opMetaData.getQName()
+ "] parameters can not be null");
@@ -400,20 +401,9 @@
MessageAbstraction resMessage = msgContext.getMessageAbstraction();
binding.unbindResponseMessage(opMetaData, resMessage, epInv,
unboundHeaders);
}
-
- //JBWS-2969: check if the RPC/Lit output paramter is null
- if (opMetaData.getEndpointMetaData().getType() != Type.JAXRPC &&
opMetaData.isRPCLiteral())
- {
- if (opMetaData.getReturnParameter() != null &&
epInv.getReturnValue() == null)
- {
- throw new WebServiceException("The RPC/Literal Operation [" +
opName
- + "] return value can not be null");
- }
- }
-
retObj = syncOutputParams(inputParams, epInv);
}
-
+
return retObj;
}
catch (Exception ex)
@@ -535,6 +525,10 @@
retValue = epInv.getReturnValue();
if (opMetaData.isDocumentWrapped() && retMetaData.isMessageType() ==
false)
retValue = ParameterWrapping.unwrapResponseParameters(retMetaData, retValue,
inParams);
+ if (opMetaData.getEndpointMetaData().getType() != Type.JAXRPC &&
opMetaData.isRPCLiteral() && retValue == null)
+ throw new WebServiceException("The RPC/Literal Operation [" +
opMetaData.getQName()
+ + "] return value can not be null, it's WS-BP:2211
violation)");
+
}
// Set the holder values for INOUT parameters
@@ -547,6 +541,15 @@
{
QName xmlName = paramMetaData.getXmlName();
Object value = epInv.getResponseParamValue(xmlName);
+ //JBWS-2969:Check if reponse parameter or return value is null
+ if (opMetaData.getEndpointMetaData().getType() != Type.JAXRPC &&
opMetaData.isRPCLiteral())
+ {
+ if (value == null)
+ {
+ throw new WebServiceException("The RPC/Literal Operation ["
+ opMetaData.getQName()
+ + "] response parameter value can not be null, it's
WS-BP:2211 violation)");
+ }
+ }
// document/literal wrapped return value header
if (index == -1)
{
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2010-04-02
16:10:22 UTC (rev 11934)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2010-04-05
04:29:32 UTC (rev 11935)
@@ -223,7 +223,7 @@
for (QName qname : sepInv.getRequestParamNames())
{
ParameterMetaData paramMetaData = opMetaData.getParameter(qname);
- if (paramMetaData.getMode().equals(ParameterMode.IN) &&
sepInv.getRequestParamValue(qname) == null)
+ if ((paramMetaData.getMode().equals(ParameterMode.IN) ||
paramMetaData.getMode().equals(ParameterMode.INOUT)) &&
sepInv.getRequestParamValue(qname) == null)
{
throw new WebServiceException("The RPC/Literal Operation
[" + opMetaData.getQName()
+ "] parameters can not be null");
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-04-02
16:10:22 UTC (rev 11934)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-04-05
04:29:32 UTC (rev 11935)
@@ -625,7 +625,19 @@
<include name="jboss-web.xml"/>
</webinf>
</war>
+
+ <!-- jaxws-jbws2969 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2969.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2969/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2969/*.class"/>
+ <exclude
name="org/jboss/test/ws/jaxws/jbws2969/JBWS2969TestCase.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2969/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws-jbws2977 -->
<war warfile="${tests.output.dir}/test-libs/jaxws-jbws2977.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2977/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/Endpoint.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/Endpoint.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/Endpoint.java 2010-04-05
04:29:32 UTC (rev 11935)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2969;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.Holder;
+
+@WebService(name = "Endpoint", targetNamespace =
"http://ws.jboss.org")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Endpoint
+{
+
+ /**
+ *
+ * @param in
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(name = "out", partName = "out")
+ public String testPassNull(@WebParam(name = "in", partName = "in")
String in);
+
+ /**
+ *
+ * @param in
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(name = "out", partName = "out")
+ public String testReturnNull(@WebParam(name = "in", partName =
"in") String in);
+
+ @WebMethod
+ public void testInHolderNull(@WebParam(name = "arg0", partName =
"arg0") String arg0,
+ @WebParam(name = "arg1", mode = WebParam.Mode.INOUT, partName =
"arg1") Holder<String> arg1,
+ @WebParam(name = "arg2", mode = WebParam.Mode.OUT, partName =
"arg2") Holder<String> arg2,
+ @WebParam(name = "arg3", mode = WebParam.Mode.OUT, partName =
"arg3") Holder<String> arg3);
+
+ /**
+ *
+ * @param arg3
+ * @param arg2
+ * @param arg1
+ * @param arg0
+ */
+ @WebMethod
+ public void testInOutHolderNull(@WebParam(name = "arg0", partName =
"arg0") String arg0,
+ @WebParam(name = "arg1", mode = WebParam.Mode.INOUT, partName =
"arg1") Holder<String> arg1,
+ @WebParam(name = "arg2", mode = WebParam.Mode.OUT, partName =
"arg2") Holder<String> arg2,
+ @WebParam(name = "arg3", mode = WebParam.Mode.OUT, partName =
"arg3") Holder<String> arg3);
+
+ /**
+ *
+ * @param arg3
+ * @param arg2
+ * @param arg1
+ * @param arg0
+ */
+ @WebMethod
+ public void testOutHolderNull(@WebParam(name = "arg0", partName =
"arg0") String arg0,
+ @WebParam(name = "arg1", mode = WebParam.Mode.INOUT, partName =
"arg1") Holder<String> arg1,
+ @WebParam(name = "arg2", mode = WebParam.Mode.OUT, partName =
"arg2") Holder<String> arg2,
+ @WebParam(name = "arg3", mode = WebParam.Mode.OUT, partName =
"arg3") Holder<String> arg3);
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/EndpointImpl.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/EndpointImpl.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/EndpointImpl.java 2010-04-05
04:29:32 UTC (rev 11935)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2969;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@WebService(name = "Endpoint", serviceName= "EndpointService" ,
targetNamespace = "http://ws.jboss.org", endpointInterface =
"org.jboss.test.ws.jaxws.jbws2969.Endpoint")
+public class EndpointImpl implements Endpoint
+{
+ public String testPassNull(String in)
+ {
+ return "helloworld";
+ }
+
+ public String testReturnNull(String in) {
+ return null;
+ }
+
+
+ public void testInHolderNull(String arg0, Holder<String>
arg1,Holder<String> arg2, Holder<String> arg3)
+ {
+ arg2.value = "arg2";
+ arg3.value = "arg3";
+
+ }
+
+ public void testInOutHolderNull(String arg0, Holder<String>
arg1,Holder<String> arg2, Holder<String> arg3)
+ {
+ arg1.value = null;
+ arg2.value = "arg2";
+ arg3.value = "arg3";
+ }
+
+ public void testOutHolderNull(String arg0, Holder<String>
arg1,Holder<String> arg2, Holder<String> arg3)
+ {
+ arg2.value = "arg2";
+ arg3.value = null;
+ }
+
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/JBWS2969TestCase.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/JBWS2969TestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2969/JBWS2969TestCase.java 2010-04-05
04:29:32 UTC (rev 11935)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2969;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+
+
+/**
+ * A JBWS2969TestCase.
+ *
+ * @author <a href="ema(a)redhat.com">Jim Ma</a>
+ */
+public class JBWS2969TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws2969/";
+
+ private static Endpoint port;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2969TestCase.class,
"jaxws-jbws2969.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://ws.jboss.org",
"EndpointService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(Endpoint.class);
+ }
+
+ public void testRpcLitPassNull() throws Exception
+ {
+ // this should be successful
+ assertEquals("helloworld",port.testPassNull("hello"));
+ //Throw WebServiceException
+ try
+ {
+ port.testPassNull(null);
+ fail("WebServiceException is expected when the rpc lit pass in prameter is
null");
+ }
+ catch (WebServiceException e)
+ {
+ //do nothing
+ }
+
+ try
+ {
+ port.testReturnNull("hello");
+ fail("WebServiceException is expected when the rpc lit return value is
null");
+ }
+ catch (WebServiceException e)
+ {
+ //do nothing
+ }
+
+ //should be successful
+ Holder<String> arg1 = new Holder<String>();
+ arg1.value = "arg1";
+ port.testInHolderNull("arg0", arg1, new Holder<String>(), new
Holder<String>());
+
+
+ //Throw WebServiceException, inout holder pass in parameter is null
+ try
+ {
+ port.testInHolderNull("arg0", new Holder<String>() , new
Holder<String>(), new Holder<String>());
+ fail("WebServiceException is expected when the rpc lit pass in holder value
is null");
+ }
+ catch (WebServiceException e)
+ {
+ //do nothing
+ }
+
+
+ //Throw WebServiceException, inout holder response parameter is null
+ try
+ {
+ Holder<String> arg = new Holder<String>();
+ arg.value = "arg";
+ port.testInOutHolderNull("arg0", arg , new Holder<String>(), new
Holder<String>());
+ fail("WebServiceException is expected when the rpc lit inout holder return
value is null");
+ }
+ catch (WebServiceException e)
+ {
+ //do nothing
+ }
+
+
+ //Throw WebServiceException, inout holder response parameter is null
+ try
+ {
+ Holder<String> tmpArg = new Holder<String>();
+ tmpArg.value = "arg";
+ port.testOutHolderNull("arg0", tmpArg , new Holder<String>(),
new Holder<String>());
+ fail("WebServiceException is expected when the rpc lit out holder return
value is null");
+ }
+ catch (WebServiceException e)
+ {
+ //do nothing
+ }
+ }
+}
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/jboss-web.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/jboss-web.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/jboss-web.xml 2010-04-05
04:29:32 UTC (rev 11935)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <context-root>/jaxws-jbws2969</context-root>
+</jboss-web>
\ No newline at end of file
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/web.xml
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/web.xml
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2969/WEB-INF/web.xml 2010-04-05
04:29:32 UTC (rev 11935)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.jbws2969.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file