Empty SOAP element as argument to int[] parameter results in single-element of
0 int array
------------------------------------------------------------------------------------------
Key: CXF-3111
URL: https://issues.apache.org/jira/browse/CXF-3111
Project: CXF
Issue Type: Bug
Components: JAXB Databinding
Affects Versions: 2.2.11
Environment: Ubuntu Maverick 64-bit, Java SE 1.6.0_20, Eclipse 3.6 Web
Services Explorer, Tomcat 6.0.26
Reporter: Scott Van Wart
When I call a CXF-hosted web service that accepts an int array as a parameter,
and I give it an empty element as that parameter in the SOAP message, I end up
with an int array with a single element of '0'.
The SEI:
{noformat}
@WebService( name="intTest", targetNamespace="http://int.test.example.org" )
public interface IntTest
{
@WebMethod public String doTest(
@WebParam( name="intArray" ) int[] intArray );
}
{noformat}
Inbound SOAP message:
{noformat}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://int.test.example.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<q0:doTest>
<intArray/>
</q0:doTest>
</soapenv:Body>
</soapenv:Envelope>
{noformat}
My implementation:
{noformat}
@WebService( endpointInterface="IntTest" )
public class IntTestImpl implements IntTest {
public String doTest( int[] intArray ) {
StringBuilder s = new StringBuilder( "[" );
for ( int n = 0; n < intArray.length; ++n ) {
if ( n > 0 ) {
s.append( ',' );
}
s.append( Integer.toString( intArray[n] ) );
}
s.append( ']' );
return s.toString();
}
}
{noformat}
Outbound SOAP message:
{noformat}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:doTestResponse xmlns:ns2="http://int.test.example.org">
<return>[0]</return>
</ns2:doTestResponse>
</soap:Body>
</soap:Envelope>
{noformat}
Personally I would have expected either null or, more logically, an empty array
to be passed to my implementing method. By giving a sentinal value in the
array, it forces callers to have separate checks and avoid sending the
parameter if it has no value. I wasn't sure whether this was a data binding
issue, something with CXF, or something about a specification I don't
understand, but I thought I'd try under JAXB binding.
Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.