> Should it be validated or the only option is
> adding an interceptor to do it?

If mapped to an JAXB object parameter on the method, it SHOULD be validated.   
The SoapHeaderInterceptor uses the same readers/databinding as the normal body 
stuff and thus should have the schema set in it.   If it's not working a full 
testcase attached to a JIRA would be useful.

Dan


On Friday, August 19, 2011 9:05:44 AM Evangelina wrote:
> Daniel  Kulp wrote:
> > On Thursday, August 18, 2011 5:57:02 AM Evangelina wrote:
> >> Hi! Thanks for answering.
> >> I'm pretty new to CXF so please correct me if I'm wrong, but doesn't
> >> the
> >> 'mustUnderstand' attribute specifies if a header entry is mandatory or
> >> not?
> >> From what I saw in the code it just checks if the QName is understood
> >> or
> >> not, but I haven't seen that it checks the semantics.
> >> In my case I would like to be able to validate the header entries
> >> against the schema the way I can do with the body.
> >> 
> >> Surely I can have that logic on an interceptor. But I also wanted to
> >> make sure that the 'schema-validation-enabled' attribute is indeed
> >> only validating the body, and this is so by design.
> > 
> > Well, it should also validate any headers that are mapped into
> > parameters
> > on
> > the method.   Anything not mapped to parameters will not be processed by
> > CXF.
> 
> Hi Dan,
> 
> I could resolve the problem by implementing an interceptor, but now that you
> mention I am mapping the header as a parameter on the operation. In that
> should the header fields be validated?
> 
> This is the wsdl and schema I'm using:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="validationWS"
>       targetNamespace="http://services.mule.org/";
>       xmlns:ns1="http://schemas.xmlsoap.org/soap/http";
>       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
>       xmlns:tns="http://services.mule.org/";
>       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>       xmlns:val="http://www.example.org/schema";>
>   <wsdl:types>
> <xs:schema elementFormDefault="unqualified"
> targetNamespace="http://services.mule.org/"; version="1.0"
>       xmlns:tns="http://services.mule.org/";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";>
> <xs:import namespace="http://www.example.org/schema";
> schemaLocation="./validationSchema.xsd" />
> </xs:schema>
>   </wsdl:types>
> 
>   <wsdl:message name="validationOperationResponse">
>     <wsdl:part  name="operationResponse" element="val:validationResponse" />
> </wsdl:message>
> 
>   <wsdl:message name="validationOperationMessage">
>     <wsdl:part name="requestHeader" element="val:validationHead" />
>     <wsdl:part name="requestBody" element="val:validationBody"  />
>   </wsdl:message>
> 
>   <wsdl:portType name="ValidationWebService">
>     <wsdl:operation name="validationOperation">
>       <wsdl:input message="tns:validationOperationMessage" >
>     </wsdl:input>
>       <wsdl:output message="tns:validationOperationResponse" >
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:portType>
> 
>   <wsdl:binding name="validationWSSoapBinding"
> type="tns:ValidationWebService">
>     <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"; required="true"/>
>     <wsdl:operation name="validationOperation">
>       <soap:operation soapAction="" style="document"/>
>       <wsdl:input name="validationOperationRequest" >
>         <soap:header use="literal" part="requestHeader"
> message="tns:validationOperationMessage" />
>         <soap:body use="literal" parts="requestBody" />
>       </wsdl:input>
>       <wsdl:output name="validationOperationResponse">
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:service name="validationWS">
>     <wsdl:port binding="tns:validationWSSoapBinding"
> name="validationWebServicePort">
>       <soap:address location="http://localhost:9999/validationws"/>
>     </wsdl:port>
>   </wsdl:service>
> </wsdl:definitions>
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema";
>       targetNamespace="http://www.example.org/schema";
>       xmlns:tns="http://www.example.org/schema";
>       elementFormDefault="qualified">
>       <element name="validationMessage" type="tns:ValidationMessage" />
>       <element name="validationBody" type="tns:ValidationBody" />
>       <element name="validationHead" type="tns:ValidationHeader" />
>       <element name="validationResponse" type="string" />
>     <complexType name="ValidationHeader">
>       <sequence>
>               <element name="head1" type="double"></element>
>               <element name="head2" type="string"></element>
>       </sequence>
>     </complexType>
>     <complexType name="ValidationBody">
>       <sequence>
>               <element name="body1" type="double"></element>
>               <element name="body2" type="tns:restrictionType"></element>
>       </sequence>
>     </complexType>
>     <complexType name="ValidationMessage">
>       <sequence>
>               <element name="header" type="tns:ValidationHeader" />
>               <element name="body" type="tns:ValidationBody" />
>       </sequence>
>     </complexType>
>       <simpleType name="restrictionType">
>         <restriction base="string">
>             <pattern value="[0-9]{5}" />
>         </restriction>
>       </simpleType>
> 
> </schema>
> 
> 
> And this is the Soap message:
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:sch="http://www.example.org/schema";>
>    <soapenv:Header>
>       <sch:validationHead>
>          <sch:head1>1f2</sch:head1>
>          <sch:head2>string</sch:head2>
>       </sch:validationHead>
>    </soapenv:Header>
>    <soapenv:Body>
>       <sch:validationBody>
>          <sch:body1>1</sch:body1>
>          <sch:body2>24273</sch:body2>
>       </sch:validationBody>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> Since the head1 field doesn't have a double value, it should fail according
> to the schema but it isn't. Should it be validated or the only option is
> adding an interceptor to do it?
> 
> Thanks
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Schema-validation-is-not-validating-element
> s-from-SoapHeader-tp4705565p4716134.html Sent from the cxf-user mailing list
> archive at Nabble.com.
-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com

Reply via email to