cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filipe Amaral (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-5194) SoapHeaderInterceptor fails to validate SOAP header
Date Fri, 09 Aug 2013 15:21:49 GMT

     [ https://issues.apache.org/jira/browse/CXF-5194?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Filipe Amaral updated CXF-5194:
-------------------------------

    Description: 
Soap message includes a custom Header, let's call it "RequestHeader":

{code:xml}
<xs:complexType name="RequestHeader">
  <xs:sequence>
    <xs:element name="TimeStamp" type="xs:dateTime" />
  </xs:sequence>
</xs:complexType>
{code}

A contract-first approach is done through wsdl2java.

Service endpoint is created through:
{code:title=TestWsService.java|borderStyle=solid}
...
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

final String wsdlLocation = (String) properties.get(WSDL_LOCATION_PROPERTY);
URL url = getClass().getResource(wsdlLocation);

if (url == null) {
    throw new IOException("WSDL not found at bundle location " + wsdlLocation); //$NON-NLS-1$
}

factory.setWsdlLocation(url.toString());
factory.setAddress((String) properties.get(WS_ADDRESS_PROPERTY));
factory.setServiceBean(new TestPortImpl());
factory.setServiceClass(TestPortImpl.class);
factory.setEndpointName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestPort"));
//$NON-NLS-1$
factory.setServiceName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestService"));
//$NON-NLS-1$

// turn up schema validation (executes inbound and outbound validations)
factory.getProperties(Boolean.TRUE).put("schema-validation-enabled", Boolean.TRUE); //$NON-NLS-1$

webService = factory.create();
webService.start();
...
{code}

A SOAP request is made with an invalid timestamp. Validation doesn't occur and request traverses
SoapHeaderInterceptor without even being validated.
After doing some debug inside the interceptor, problem relies on _validateHeader()_.
When _findHeader()_ is called inside _validateHeader()_ it simply returns null, although the
SoapMessage is correct and apparently the MessagePartInfo too.
Inside _findHeader()_ the _mpi.getConcreteName()_ returns "RequestHeaderElement" as localPart
where it should simply return "RequestHeader".
If _mpi.getConcreteName()_ returned value is changed at runtime through live debug to "RequestHeader",
validation is done successfully, failing with soapfault:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Could not validate soapheader caused by: org.xml.sax.SAXParseException:
cvc-datatype-valid.1.2.1: '2012-05-1T00:00:00' is not a valid value for 'dateTime'..</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

If more detailed info is needed, please advise.

Regards

  was:
Soap message includes a custom Header, let's call it _RequestHeader_:

{code:xml}
<xs:complexType name="RequestHeader">
  <xs:sequence>
    <xs:element name="TimeStamp" type="xs:dateTime" />
  </xs:sequence>
</xs:complexType>
{code}

A contract-first approach is done through wsdl2java.

Service endpoint is created through:
{code:title=TestWsService.java|borderStyle=solid}
...
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

final String wsdlLocation = (String) properties.get(WSDL_LOCATION_PROPERTY);
URL url = getClass().getResource(wsdlLocation);

if (url == null) {
    throw new IOException("WSDL not found at bundle location " + wsdlLocation); //$NON-NLS-1$
}

factory.setWsdlLocation(url.toString());
factory.setAddress((String) properties.get(WS_ADDRESS_PROPERTY));
factory.setServiceBean(new TestPortImpl());
factory.setServiceClass(TestPortImpl.class);
factory.setEndpointName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestPort"));
//$NON-NLS-1$
factory.setServiceName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestService"));
//$NON-NLS-1$

// turn up schema validation (executes inbound and outbound validations)
factory.getProperties(Boolean.TRUE).put("schema-validation-enabled", Boolean.TRUE); //$NON-NLS-1$

webService = factory.create();
webService.start();
...
{code}

A SOAP request is made with an invalid timestamp. Validation doesn't occur and request traverses
SoapHeaderInterceptor without even being validated.
After doing some debug inside the interceptor, problem relies on validateHeader().
When findHeader() is called inside validateHeader() it simply returns null, although the SoapMessage
is correct and apparently the MessagePartInfo too.
Inside findHeader() the mpi.getConcreteName() returns "RequestHeaderElement" as localPart
where it should simply return "RequestHeader". If mpi.getConcreteName() returned value is
changed in runtime, through live debug, to "RequestHeader" validation is done successfuly,
failing with soapfault:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Could not validate soapheader caused by: org.xml.sax.SAXParseException:
cvc-datatype-valid.1.2.1: '2012-05-1T00:00:00' is not a valid value for 'dateTime'..</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

If more detailed info is needed, please advise.

Regards

    
> SoapHeaderInterceptor fails to validate SOAP header
> ---------------------------------------------------
>
>                 Key: CXF-5194
>                 URL: https://issues.apache.org/jira/browse/CXF-5194
>             Project: CXF
>          Issue Type: Bug
>          Components: Soap Binding
>    Affects Versions: 2.7.0
>         Environment: Windows/Solaris, JBoss, JavaSE-1.6
>            Reporter: Filipe Amaral
>            Priority: Critical
>
> Soap message includes a custom Header, let's call it "RequestHeader":
> {code:xml}
> <xs:complexType name="RequestHeader">
>   <xs:sequence>
>     <xs:element name="TimeStamp" type="xs:dateTime" />
>   </xs:sequence>
> </xs:complexType>
> {code}
> A contract-first approach is done through wsdl2java.
> Service endpoint is created through:
> {code:title=TestWsService.java|borderStyle=solid}
> ...
> JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
> final String wsdlLocation = (String) properties.get(WSDL_LOCATION_PROPERTY);
> URL url = getClass().getResource(wsdlLocation);
> if (url == null) {
>     throw new IOException("WSDL not found at bundle location " + wsdlLocation); //$NON-NLS-1$
> }
> factory.setWsdlLocation(url.toString());
> factory.setAddress((String) properties.get(WS_ADDRESS_PROPERTY));
> factory.setServiceBean(new TestPortImpl());
> factory.setServiceClass(TestPortImpl.class);
> factory.setEndpointName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestPort"));
//$NON-NLS-1$
> factory.setServiceName(new QName((String) properties.get(WS_NAMESPACE_PROPERTY), "TestService"));
//$NON-NLS-1$
> // turn up schema validation (executes inbound and outbound validations)
> factory.getProperties(Boolean.TRUE).put("schema-validation-enabled", Boolean.TRUE); //$NON-NLS-1$
> webService = factory.create();
> webService.start();
> ...
> {code}
> A SOAP request is made with an invalid timestamp. Validation doesn't occur and request
traverses SoapHeaderInterceptor without even being validated.
> After doing some debug inside the interceptor, problem relies on _validateHeader()_.
> When _findHeader()_ is called inside _validateHeader()_ it simply returns null, although
the SoapMessage is correct and apparently the MessagePartInfo too.
> Inside _findHeader()_ the _mpi.getConcreteName()_ returns "RequestHeaderElement" as localPart
where it should simply return "RequestHeader".
> If _mpi.getConcreteName()_ returned value is changed at runtime through live debug to
"RequestHeader", validation is done successfully, failing with soapfault:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body>
>       <soap:Fault>
>          <faultcode>soap:Client</faultcode>
>          <faultstring>Could not validate soapheader caused by: org.xml.sax.SAXParseException:
cvc-datatype-valid.1.2.1: '2012-05-1T00:00:00' is not a valid value for 'dateTime'..</faultstring>
>       </soap:Fault>
>    </soap:Body>
> </soap:Envelope>
> If more detailed info is needed, please advise.
> Regards

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message