You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Raffaele Spazzoli <rs...@imolinfo.it> on 2009/08/28 14:17:22 UTC

how to pass a null value to a wrapped parameter in consumer mode

Hi,
I have a java first use case with a document literal wrapped service.
Here is a part of the annotated service:

@WebService(name="AlarmIRP",
targetNamespace="http://AlarmIRPSystem.AlarmIRP")
@SOAPBinding(use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
public abstract interface AlarmIRPOperations

...

@WebMethod(operationName="acknowledge_alarms")
  public abstract Signal
acknowledge_alarms(@WebParam(name="alarm_information_id_and_sev_list")
AlarmInformationIdAndSev[] paramArrayOfAlarmInformationIdAndSev,
@WebParam(name="ack_user_id") String paramString,
@WebParam(name="ack_system_id") StringTypeOptWrapper
paramStringTypeOptWrapper, @WebParam(name="bad_ack_alarm_info_list",
mode=WebParam.Mode.INOUT) Holder<BadAcknowledgeAlarmInfo[]> paramHolder)
    throws AcknowledgeAlarms, ParameterNotSupported, InvalidParameter;

...

Before creating the service I set the following service factory
properties:


endpointFactory.getServiceFactory().setAnonymousWrapperTypes(true);
endpointFactory.getServiceFactory().setQualifyWrapperSchema(true);     
endpointFactory.getServiceFactory().setWrapped(true);

The generated schema for the wrapped parameter is the following:

    <xs:element name="acknowledge_alarms">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded"
name="alarm_information_id_and_sev_list"
type="ns1:alarmInformationIdAndSev"/>
                <xs:element name="ack_user_id" type="xs:string"/>
                <xs:element name="ack_system_id"
type="ns2:StringTypeOpt"/>
                <xs:element maxOccurs="unbounded"
name="bad_ack_alarm_info_list" type="ns1:badAcknowledgeAlarmInfo"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

If, in consumer mode, I pass a null value to the
Holder<BadAcknowledgeAlarmInfo[]> paramHolder parameter I get a marshall
exceprion:

java.lang.NullPointerException
        at
it.imolinfo.jbi4corba.jbi.cxf.OutMarshallerHelper.marshal(OutMarshallerHelper.java:141)

I'm using CXF version 2.1.4.

First of all is this behaviour correct? Secondly what modification
should I do to the annotations or service configuration to allow null
values to be passed?

thanks
Raffaele



Re: how to pass a null value to a wrapped parameter in consumer mode

Posted by Daniel Kulp <dk...@apache.org>.
To clarify, are you passing null as the value of the Holder or for the Holder 
itself?

Aka:

acknowledge_alarms("blah", "blah", null);
or
Holder<...> holder = new Holder<...>(null);
acknowledge_alarms("blah", "blah", holder);

If it's the former, it's definitely kind of expected.   With INOUT/OUT 
parameters, you HAVE to specify the holder.   When you make the invoke, even 
if what you pass in is null, you don't know if what comes back will be null.   
Thus, we need to have the Holder there so we can place the OUT when it comes 
back.

Second:
 java.lang.NullPointerException
         at
 it.imolinfo.jbi4corba.jbi.cxf.OutMarshallerHelper.marshal(OutMarshallerHelp
er.java:141)

This seems to be in your own code.   That's not CXF code.   

Dan




On Fri August 28 2009 8:17:22 am Raffaele Spazzoli wrote:
> Hi,
> I have a java first use case with a document literal wrapped service.
> Here is a part of the annotated service:
>
> @WebService(name="AlarmIRP",
> targetNamespace="http://AlarmIRPSystem.AlarmIRP")
> @SOAPBinding(use=SOAPBinding.Use.LITERAL,
> parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
> public abstract interface AlarmIRPOperations
>
> ...
>
> @WebMethod(operationName="acknowledge_alarms")
>   public abstract Signal
> acknowledge_alarms(@WebParam(name="alarm_information_id_and_sev_list")
> AlarmInformationIdAndSev[] paramArrayOfAlarmInformationIdAndSev,
> @WebParam(name="ack_user_id") String paramString,
> @WebParam(name="ack_system_id") StringTypeOptWrapper
> paramStringTypeOptWrapper, @WebParam(name="bad_ack_alarm_info_list",
> mode=WebParam.Mode.INOUT) Holder<BadAcknowledgeAlarmInfo[]> paramHolder)
>     throws AcknowledgeAlarms, ParameterNotSupported, InvalidParameter;
>
> ...
>
> Before creating the service I set the following service factory
> properties:
>
>
> endpointFactory.getServiceFactory().setAnonymousWrapperTypes(true);
> endpointFactory.getServiceFactory().setQualifyWrapperSchema(true);
> endpointFactory.getServiceFactory().setWrapped(true);
>
> The generated schema for the wrapped parameter is the following:
>
>     <xs:element name="acknowledge_alarms">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element maxOccurs="unbounded"
> name="alarm_information_id_and_sev_list"
> type="ns1:alarmInformationIdAndSev"/>
>                 <xs:element name="ack_user_id" type="xs:string"/>
>                 <xs:element name="ack_system_id"
> type="ns2:StringTypeOpt"/>
>                 <xs:element maxOccurs="unbounded"
> name="bad_ack_alarm_info_list" type="ns1:badAcknowledgeAlarmInfo"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>
> If, in consumer mode, I pass a null value to the
> Holder<BadAcknowledgeAlarmInfo[]> paramHolder parameter I get a marshall
> exceprion:
>
> java.lang.NullPointerException
>         at
> it.imolinfo.jbi4corba.jbi.cxf.OutMarshallerHelper.marshal(OutMarshallerHelp
>er.java:141)
>
> I'm using CXF version 2.1.4.
>
> First of all is this behaviour correct? Secondly what modification
> should I do to the annotations or service configuration to allow null
> values to be passed?
>
> thanks
> Raffaele

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog