Search in sources :

Example 1 with SchemaValidationService

use of org.apache.schema_validation.SchemaValidationService in project cxf by apache.

the class ValidationClientServerTest method testHeaderValidation.

@Test
public void testHeaderValidation() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
    assertNotNull(wsdl);
    SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
    assertNotNull(service);
    String smsg = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Header>" + "<SomeHeader soap:mustUnderstand='1' xmlns='http://apache.org/schema_validation/types'>" + "<id>1111111111</id></SomeHeader>" + "</soap:Header><soap:Body><SomeRequestWithHeader xmlns='http://apache.org/schema_validation/types'>" + "<id>1111111111</id></SomeRequestWithHeader></soap:Body></soap:Envelope>";
    Dispatch<Source> dsp = service.createDispatch(SchemaValidationService.SoapPort, Source.class, Mode.MESSAGE);
    updateAddressPort(dsp, PORT);
    dsp.invoke(new StreamSource(new StringReader(smsg)));
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) SchemaValidationService(org.apache.schema_validation.SchemaValidationService) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) Test(org.junit.Test)

Example 2 with SchemaValidationService

use of org.apache.schema_validation.SchemaValidationService in project cxf by apache.

the class ValidationClientServerTest method createService.

private SchemaValidation createService(Object validationConfig, String postfix) throws Exception {
    URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
    assertNotNull(wsdl);
    SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
    assertNotNull(service);
    SchemaValidation validation = service.getPort(portName, SchemaValidation.class);
    setAddress(validation, "http://localhost:" + PORT + "/SoapContext/" + postfix);
    ((BindingProvider) validation).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    ((BindingProvider) validation).getResponseContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    new LoggingFeature().initialize((Client) validation, getBus());
    return validation;
}
Also used : LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) SchemaValidationService(org.apache.schema_validation.SchemaValidationService) URL(java.net.URL) SchemaValidation(org.apache.schema_validation.SchemaValidation)

Aggregations

URL (java.net.URL)2 SchemaValidationService (org.apache.schema_validation.SchemaValidationService)2 StringReader (java.io.StringReader)1 Source (javax.xml.transform.Source)1 StreamSource (javax.xml.transform.stream.StreamSource)1 LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)1 SchemaValidation (org.apache.schema_validation.SchemaValidation)1 Test (org.junit.Test)1