cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bin Zhu <luckyzhu...@gmail.com>
Subject no WebServiceException caught when invoking a method which returns null using the rpc/literal style
Date Thu, 17 Jan 2013 05:27:49 GMT
Hi all,
Accdoring to jsr224 3.6.2.3, due to the limitations described in
section 5.3.1 of theWS-I Basic Profile specification (see [8]), null
values cannot be used as method arguments or as the return value from
a method which uses the rpc/literal binding.
 (Null Values in rpc/literal): If a null value is passed as an
argument to amethod, or returned
from amethod, that uses the rpc/literal style, then an implementation
MUST throw a WebServiceException.

However, in my test application using CXF 2.6.2, when when invoking a
method which returns null using the rpc/literal style, their will be
no  WebServiceException caught. Is this possible an issue in CXF?

Here is the test code:
            try{
                System.out.flush(); System.err.flush();
                System.out.println("invoking method that returns null,
expecting exception");
                System.out.println("s.returnNull="+s.returnNull("hello
there null"));
            } catch (WebServiceException e){
                System.out.println("caught expected WebserviceException");
                e.printStackTrace();
                System.out.flush(); System.err.flush();
                ok = true;
            }
             Assert.assertTrue("Wrong/No exception received for null
return", ok);

I looked into the SOAP message/CXF code, there is Fault thrown in CXF,
however, the test code can't get the WebServiceException as requested
in the spec.
SOAP message:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:returnNullResponse
xmlns:ns1="http://serverrpc.testdata.soapbinding.annotations/"><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Cannot
write part return. RPC/Literal parts cannot be null. (WS-I BP
R2211)</faultstring></soap:Fault></ns1:returnNullResponse></soap:Body></soap:Envelope>"

Related code in
/cxf-rt-bindings-soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java

                if (objs.hasValue(part)) {
                    Object o = objs.get(part);
                    if (o == null) {
                        //WSI-BP R2211 - RPC/Lit parts are not allowed
to be xsi:nil
                        throw new Fault(
                            new
org.apache.cxf.common.i18n.Message("BP_2211_RPCLIT_CANNOT_BE_NULL",

LOG, part.getConcreteName()));
                    }

Mime
View raw message