Server-side validation of non-nillable elements
neilf Nov 21, 2005 11:14 PMHi.
Am I incorrect in assuming that JBoss WS will validate for non-nillable elements on the server-side?
To illustrate, I've created a very simple web service. Here's the WSDL:
<?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloService" targetNamespace="http://hello.ws.jboss.org/" xmlns:tns="http://hello.ws.jboss.org/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://hello.ws.jboss.org/types" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <schema targetNamespace="http://hello.ws.jboss.org/types" xmlns:tns="http://hello.ws.jboss.org/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="hello"> <sequence> <element name="NameObj_1" type="tns:NameObj" nillable="true"/></sequence></complexType> <complexType name="NameObj"> <sequence> <element name="name" type="string" nillable="false" minOccurs="1"/></sequence></complexType> <complexType name="helloResponse"> <sequence> <element name="result" type="string" nillable="true"/></sequence></complexType> <complexType name="ServiceLayerException"> <sequence> <element name="code" type="string" nillable="true"/></sequence></complexType> <element name="hello" type="tns:hello"/> <element name="helloResponse" type="tns:helloResponse"/> <element name="ServiceLayerException" type="tns:ServiceLayerException"/></schema></types> <message name="Hello_hello"> <part name="parameters" element="ns2:hello"/></message> <message name="Hello_helloResponse"> <part name="result" element="ns2:helloResponse"/></message> <message name="ServiceLayerException"> <part name="ServiceLayerException" element="ns2:ServiceLayerException"/></message> <portType name="Hello"> <operation name="hello"> <input message="tns:Hello_hello"/> <output message="tns:Hello_helloResponse"/> <fault name="ServiceLayerException" message="tns:ServiceLayerException"/></operation></portType> <binding name="HelloBinding" type="tns:Hello"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <operation name="hello"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/></input> <output> <soap:body use="literal"/></output> <fault name="ServiceLayerException"> <soap:fault name="ServiceLayerException" use="literal"/></fault></operation></binding> <service name="HelloService"> <port name="HelloPort" binding="tns:HelloBinding"> <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>
And here's the SOAP request I'm sending (from Axis):
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <hello xmlns="http://hello.ws.jboss.org/types"> <NameObj_1 xmlns=""> <name xsi:nil="true"/> </NameObj_1> </hello> </soapenv:Body> </soapenv:Envelope>
Now, since xsi:nil is set to true I would assume that JBoss WS would throw up some validation errors, since this type is specified as both nillable="false" and minOccurs="1" in the WSDL, but it doesn't seems to.
Perhaps this sort of validation is just disabled by default, and I have to enable it?
I can attach a complete test case if necessary.
BTW, I'm trying this on JBoss 4.0.2.
Thanks.
Neil.