You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by li...@centrum.cz on 2008/09/03 23:15:29 UTC

issues with PHP integration (null is not sent)

Hi,

my web service is up and running and now the other developer starts to use it in his PHP project. It worked fine on local copies, but it behaves strange on live server :-( Suddenly I receive all parameters as "" instead of NULL, when not specified on PHP side.

I started implementation from java interface:
    public void registerUser(@WebParam(name = "login") String login, @WebParam(name = "password") String password,
                             @WebParam(name = "openId") String openId, @WebParam(name = "name") String name,
                             @WebParam(name = "portal") String portal, @WebParam(name = "portalPassword") String portalPassword)
            throws DuplicateKeyException, InvalidInputException, AccessDeniedException, LdapException;

And here you can see generated WSDL: http://www.abclinuxu.cz/services/users?wsdl
<xs:complexType name="registerUser">
<xs:sequence>
<xs:element minOccurs="0" name="login" type="xs:string"/>
<xs:element minOccurs="0" name="password" type="xs:string"/>
<xs:element minOccurs="0" name="openId" type="xs:string"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
<xs:element minOccurs="0" name="portal" type="xs:string"/>
<xs:element minOccurs="0" name="portalPassword" type="xs:string"/>
</xs:sequence>

1) How can I influence this WSDL? For example I want to specify minOccurs=1 to make login and password mandatory, but nillable=true for openid.

2) Do you know, why CXF sends "" instead of NULL? This is in SOAP body (different method):

<ns1:updateUser><acount><city/><country/><deliveryAddressCity/><deliveryAddressCountry>null</deliveryAddressCountry><deliveryAddressName/><deliveryAddressStreet/><deliveryAddressZIP/><emailAddress>literakl@abclinuxu.cz</emailAddress><emailBlocked/><emailVerified/><forgottenPasswordToken/><homepageURL/><invoicingAddressCity>Praha 3</invoicingAddressCity><invoicingAddressCountry>ceska republika</invoicingAddressCountry><invoicingAddressName/><invoicingAddressStreet>Konevova </invoicingAddressStreet><invoicingAddressZIP>130 83</invoicingAddressZIP><invoicingCompany/><invoicingCompanyDIC/><invoicingCompanyICO/><lastLoginDate/><login>literakl2</login><name>Leos Literak</name><openID/><passwordAnswer/><passwordHash/><passwordQuestion/><phone/><registrationDate/><sex/><userPassword/></acount><portal>secret/portal><portalPassword>secret</portalPassword></ns1:updateUser>

The developer tried to modify this SOAP message and sent <openID xsi:nil="true" /> but CXF though translated it into "" parameter.

I use CXF 2.0.5 in jetty 6.1.11, no spring, deploy the service with:
        Endpoint.publish(endpointUrlServices, new UserAccountServiceImpl());

public class AbcCxfServlet extends CXFNonSpringServlet {
    public void init(ServletConfig servletConfig) throws ServletException {
        super.init(servletConfig);
        Bus bus = this.getBus();
        BusFactory.setDefaultBus(bus);
    }
}

Any help will be appreciated.

Leos


Re: issues with PHP integration (null is not sent)

Posted by li...@centrum.cz.
Hi all,

I've added some annotations and I started to receive nulls :-)

@XmlType
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class UserAccount implements Serializable {
    @javax.xml.bind.annotation.XmlElement(nillable = true)
    private String city;

Leos

>> 2) Do you know, why CXF sends "" instead of NULL? 
>
>If there is an element in the soap message, it will be "".   For null, the 
>element should be eliminated.  (example: no openID element at all in the 
>message)



Re: issues with PHP integration (null is not sent)

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 03 September 2008 5:15:29 pm literakl@centrum.cz wrote:
> Hi,
>
> my web service is up and running and now the other developer starts to use
> it in his PHP project. It worked fine on local copies, but it behaves
> strange on live server :-( Suddenly I receive all parameters as "" instead
> of NULL, when not specified on PHP side.
>
> I started implementation from java interface:
>     public void registerUser(@WebParam(name = "login") String login,
> @WebParam(name = "password") String password, @WebParam(name = "openId")
> String openId, @WebParam(name = "name") String name, @WebParam(name =
> "portal") String portal, @WebParam(name = "portalPassword") String
> portalPassword) throws DuplicateKeyException, InvalidInputException,
> AccessDeniedException, LdapException;
>
> And here you can see generated WSDL:
> http://www.abclinuxu.cz/services/users?wsdl <xs:complexType
> name="registerUser">
> <xs:sequence>
> <xs:element minOccurs="0" name="login" type="xs:string"/>
> <xs:element minOccurs="0" name="password" type="xs:string"/>
> <xs:element minOccurs="0" name="openId" type="xs:string"/>
> <xs:element minOccurs="0" name="name" type="xs:string"/>
> <xs:element minOccurs="0" name="portal" type="xs:string"/>
> <xs:element minOccurs="0" name="portalPassword" type="xs:string"/>
> </xs:sequence>
>
> 1) How can I influence this WSDL? For example I want to specify minOccurs=1
> to make login and password mandatory, but nillable=true for openid.

The only way to do this with JAX-WS is to generate a wrapper bean and modify 
the annotations on the wrapper bean to add the required/nillable attributes 
to the XmlElement annotations.

You can us the java2ws -wrapperbean tool to create a first pass at the beans.   

>
> 2) Do you know, why CXF sends "" instead of NULL? 

If there is an element in the soap message, it will be "".   For null, the 
element should be eliminated.  (example: no openID element at all in the 
message)


Dan

> This is in SOAP body 
> (different method):
>
> <ns1:updateUser><acount><city/><country/><deliveryAddressCity/><deliveryAdd
>ressCountry>null</deliveryAddressCountry><deliveryAddressName/><deliveryAddr
>essStreet/><deliveryAddressZIP/><emailAddress>literakl@abclinuxu.cz</emailAd
>dress><emailBlocked/><emailVerified/><forgottenPasswordToken/><homepageURL/>
><invoicingAddressCity>Praha
> 3</invoicingAddressCity><invoicingAddressCountry>ceska
> republika</invoicingAddressCountry><invoicingAddressName/><invoicingAddress
>Street>Konevova </invoicingAddressStreet><invoicingAddressZIP>130
> 83</invoicingAddressZIP><invoicingCompany/><invoicingCompanyDIC/><invoicing
>CompanyICO/><lastLoginDate/><login>literakl2</login><name>Leos
> Literak</name><openID/><passwordAnswer/><passwordHash/><passwordQuestion/><
>phone/><registrationDate/><sex/><userPassword/></acount><portal>secret/porta
>l><portalPassword>secret</portalPassword></ns1:updateUser>
>
> The developer tried to modify this SOAP message and sent <openID
> xsi:nil="true" /> but CXF though translated it into "" parameter.
>
> I use CXF 2.0.5 in jetty 6.1.11, no spring, deploy the service with:
>         Endpoint.publish(endpointUrlServices, new
> UserAccountServiceImpl());
>
> public class AbcCxfServlet extends CXFNonSpringServlet {
>     public void init(ServletConfig servletConfig) throws ServletException {
>         super.init(servletConfig);
>         Bus bus = this.getBus();
>         BusFactory.setDefaultBus(bus);
>     }
> }
>
> Any help will be appreciated.
>
> Leos



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

Re: issues with PHP integration (null is not sent)

Posted by Benson Margulies <bi...@gmail.com>.
Set up the LoggingInInterceptor and see what it arriving on the wire.

JAX-WS has a limited willingness to let you control these attributes.
If you want detailed control, switch to BARE and then you can set them
with JAXB, which is another way of repeating what Dan wrote.




On Fri, Sep 5, 2008 at 1:46 AM,  <li...@centrum.cz> wrote:
> Nobody has idea, why my method receives "" instead of NULL?
>
> Leos
>
> ______________________________________________________________
>> Od: literakl@centrum.cz
>> Komu: <us...@cxf.apache.org>
>> Datum: 03.09.2008 23:16
>> Předmět: issues with PHP integration (null is not sent)
>>
>>Hi,
>>
>>my web service is up and running and now the other developer starts to use it in his PHP project. It worked fine on local copies, but it behaves strange on live server :-( Suddenly I receive all parameters as "" instead of NULL, when not specified on PHP side.
>>
>>I started implementation from java interface:
>>    public void registerUser(@WebParam(name = "login") String login, @WebParam(name = "password") String password,
>>                             @WebParam(name = "openId") String openId, @WebParam(name = "name") String name,
>>                             @WebParam(name = "portal") String portal, @WebParam(name = "portalPassword") String portalPassword)
>>            throws DuplicateKeyException, InvalidInputException, AccessDeniedException, LdapException;
>>
>>And here you can see generated WSDL: http://www.abclinuxu.cz/services/users?wsdl
>><xs:complexType name="registerUser">
>><xs:sequence>
>><xs:element minOccurs="0" name="login" type="xs:string"/>
>><xs:element minOccurs="0" name="password" type="xs:string"/>
>><xs:element minOccurs="0" name="openId" type="xs:string"/>
>><xs:element minOccurs="0" name="name" type="xs:string"/>
>><xs:element minOccurs="0" name="portal" type="xs:string"/>
>><xs:element minOccurs="0" name="portalPassword" type="xs:string"/>
>></xs:sequence>
>>
>>1) How can I influence this WSDL? For example I want to specify minOccurs=1 to make login and password mandatory, but nillable=true for openid.
>>
>>2) Do you know, why CXF sends "" instead of NULL? This is in SOAP body (different method):
>>
>><ns1:updateUser><acount><city/><country/><deliveryAddressCity/><deliveryAddressCountry>null</deliveryAddressCountry><deliveryAddressName/><deliveryAddressStreet/><deliveryAddressZIP/><emailAddress>literakl@abclinuxu.cz</emailAddress><emailBlocked/><emailVerified/><forgottenPasswordToken/><homepageURL/><invoicingAddressCity>Praha 3</invoicingAddressCity><invoicingAddressCountry>ceska republika</invoicingAddressCountry><invoicingAddressName/><invoicingAddressStreet>Konevova </invoicingAddressStreet><invoicingAddressZIP>130 83</invoicingAddressZIP><invoicingCompany/><invoicingCompanyDIC/><invoicingCompanyICO/><lastLoginDate/><login>literakl2</login><name>Leos Literak</name><openID/><passwordAnswer/><passwordHash/><passwordQuestion/><phone/><registrationDate/><sex/><userPassword/></acount><portal>secret/portal><portalPassword>secret</portalPassword></ns1:updateUser>
>>
>>The developer tried to modify this SOAP message and sent <openID xsi:nil="true" /> but CXF though translated it into "" parameter.
>>
>>I use CXF 2.0.5 in jetty 6.1.11, no spring, deploy the service with:
>>        Endpoint.publish(endpointUrlServices, new UserAccountServiceImpl());
>>
>>public class AbcCxfServlet extends CXFNonSpringServlet {
>>    public void init(ServletConfig servletConfig) throws ServletException {
>>        super.init(servletConfig);
>>        Bus bus = this.getBus();
>>        BusFactory.setDefaultBus(bus);
>>    }
>>}
>>
>>Any help will be appreciated.
>>
>>Leos
>>
>>
>
>

Re: issues with PHP integration (null is not sent)

Posted by li...@centrum.cz.
Nobody has idea, why my method receives "" instead of NULL?

Leos

______________________________________________________________
> Od: literakl@centrum.cz
> Komu: <us...@cxf.apache.org>
> Datum: 03.09.2008 23:16
> Předmět: issues with PHP integration (null is not sent)
>
>Hi,
>
>my web service is up and running and now the other developer starts to use it in his PHP project. It worked fine on local copies, but it behaves strange on live server :-( Suddenly I receive all parameters as "" instead of NULL, when not specified on PHP side.
>
>I started implementation from java interface:
>    public void registerUser(@WebParam(name = "login") String login, @WebParam(name = "password") String password,
>                             @WebParam(name = "openId") String openId, @WebParam(name = "name") String name,
>                             @WebParam(name = "portal") String portal, @WebParam(name = "portalPassword") String portalPassword)
>            throws DuplicateKeyException, InvalidInputException, AccessDeniedException, LdapException;
>
>And here you can see generated WSDL: http://www.abclinuxu.cz/services/users?wsdl
><xs:complexType name="registerUser">
><xs:sequence>
><xs:element minOccurs="0" name="login" type="xs:string"/>
><xs:element minOccurs="0" name="password" type="xs:string"/>
><xs:element minOccurs="0" name="openId" type="xs:string"/>
><xs:element minOccurs="0" name="name" type="xs:string"/>
><xs:element minOccurs="0" name="portal" type="xs:string"/>
><xs:element minOccurs="0" name="portalPassword" type="xs:string"/>
></xs:sequence>
>
>1) How can I influence this WSDL? For example I want to specify minOccurs=1 to make login and password mandatory, but nillable=true for openid.
>
>2) Do you know, why CXF sends "" instead of NULL? This is in SOAP body (different method):
>
><ns1:updateUser><acount><city/><country/><deliveryAddressCity/><deliveryAddressCountry>null</deliveryAddressCountry><deliveryAddressName/><deliveryAddressStreet/><deliveryAddressZIP/><emailAddress>literakl@abclinuxu.cz</emailAddress><emailBlocked/><emailVerified/><forgottenPasswordToken/><homepageURL/><invoicingAddressCity>Praha 3</invoicingAddressCity><invoicingAddressCountry>ceska republika</invoicingAddressCountry><invoicingAddressName/><invoicingAddressStreet>Konevova </invoicingAddressStreet><invoicingAddressZIP>130 83</invoicingAddressZIP><invoicingCompany/><invoicingCompanyDIC/><invoicingCompanyICO/><lastLoginDate/><login>literakl2</login><name>Leos Literak</name><openID/><passwordAnswer/><passwordHash/><passwordQuestion/><phone/><registrationDate/><sex/><userPassword/></acount><portal>secret/portal><portalPassword>secret</portalPassword></ns1:updateUser>
>
>The developer tried to modify this SOAP message and sent <openID xsi:nil="true" /> but CXF though translated it into "" parameter.
>
>I use CXF 2.0.5 in jetty 6.1.11, no spring, deploy the service with:
>        Endpoint.publish(endpointUrlServices, new UserAccountServiceImpl());
>
>public class AbcCxfServlet extends CXFNonSpringServlet {
>    public void init(ServletConfig servletConfig) throws ServletException {
>        super.init(servletConfig);
>        Bus bus = this.getBus();
>        BusFactory.setDefaultBus(bus);
>    }
>}
>
>Any help will be appreciated.
>
>Leos
>
>