cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Freeman Fang <freeman.f...@gmail.com>
Subject Re: no WebServiceException caught when invoking a method which returns null using the rpc/literal style
Date Thu, 17 Jan 2013 06:28:22 GMT
Hi,

I just added a test[1] which demonstrate how cxf follow this spec. Please take a look.

[1]http://svn.apache.org/viewvc?rev=1434564&view=rev


-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-1-17, at 下午1:27, Bin Zhu wrote:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message