Package org.jboss.ws.extensions.validation

Examples of org.jboss.ws.extensions.validation.SchemaExtractor


      return prevState;
   }

   private void validatePayload(Source source)
   {
      SchemaExtractor schemaExtractor = new SchemaExtractor();
      try
      {
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
         feature = epMetaData.getFeature(SchemaValidationFeature.class);
         URL xsdURL = feature.getSchemaLocation() != null ? new URL(feature.getSchemaLocation()) : null;
         if (xsdURL == null)
         {
            URL wsdlURL = epMetaData.getServiceMetaData().getWsdlFileOrLocation();
            if (wsdlURL == null)
            {
               log.warn("Validation error: Cannot obtain wsdl URL");
            }
            else
            {
               xsdURL = schemaExtractor.getSchemaUrl(wsdlURL);
            }
         }
         if (xsdURL != null)
         {
            ErrorHandler errorHandler = feature.getErrorHandler();
            Element xmlDOM = DOMUtils.sourceToElement(source);
            new SchemaValidationHelper(xsdURL).setErrorHandler(errorHandler).validateDocument(xmlDOM);
         }
      }
      catch (RuntimeException rte)
      {
         throw rte;
      }
      catch (Exception ex)
      {
         WSException.rethrow(ex);
      }
      finally
      {
         schemaExtractor.close();
      }
   }
View Full Code Here


   }

   public void testSchemaValidationPositive() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
      String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>1000</Code></performTest>";
      new SchemaValidationHelper(xsdURL).validateDocument(inxml);
   }
View Full Code Here

   }

   public void testSchemaValidationNegative() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
      String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>2000</Code></performTest>";
      try
      {
         new SchemaValidationHelper(xsdURL).validateDocument(inxml);
      }
View Full Code Here

   }

   public void testEndpointWsdlValidation() throws Exception
   {
      URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-jbws1172/noval?wsdl");
      URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
      String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>1000</Code></performTest>";
      new SchemaValidationHelper(xsdURL).validateDocument(inxml);
   }
View Full Code Here

   }
  
   public void testValidatingClientWithExplicitSchema() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
     
      Service service = Service.create(wsdlURL, SERVICE_NAME);
      SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
      MyTest port = service.getPort(MyTest.class, feature);
      try
View Full Code Here

   }
  
   public void testValidatingClientWithErrorHandler() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
     
      Service service = Service.create(wsdlURL, SERVICE_NAME);
      SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
     
      TestErrorHandler errorHandler = new TestErrorHandler();
View Full Code Here

      return prevState;
   }

   private void validatePayload(Source source)
   {
      SchemaExtractor schemaExtractor = new SchemaExtractor();
      try
      {
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
         feature = epMetaData.getFeature(SchemaValidationFeature.class);
         URL xsdURL = feature.getSchemaLocation() != null ? new URL(feature.getSchemaLocation()) : null;
         if (xsdURL == null)
         {
            URL wsdlURL = epMetaData.getServiceMetaData().getWsdlFileOrLocation();
            if (wsdlURL == null)
            {
               log.warn("Validation error: Cannot obtain wsdl URL");
            }
            else
            {
               xsdURL = schemaExtractor.getSchemaUrl(wsdlURL);
            }
         }
         if (xsdURL != null)
         {
            ErrorHandler errorHandler = feature.getErrorHandler();
            Element xmlDOM = DOMUtils.sourceToElement(source);
            new SchemaValidationHelper(xsdURL).setErrorHandler(errorHandler).validateDocument(xmlDOM);
         }
      }
      catch (RuntimeException rte)
      {
         throw rte;
      }
      catch (Exception ex)
      {
         WSException.rethrow(ex);
      }
      finally
      {
         schemaExtractor.close();
      }
   }
View Full Code Here

      return prevState;
   }

   private void validatePayload(Source source)
   {
      SchemaExtractor schemaExtractor = new SchemaExtractor();
      try
      {
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
         feature = epMetaData.getFeature(SchemaValidationFeature.class);
         URL xsdURL = feature.getSchemaLocation() != null ? new URL(feature.getSchemaLocation()) : null;
         Map<String, byte[]> xsdStreams = new HashMap<String, byte[]>();
         if (xsdURL == null)
         {
            URL wsdlURL = epMetaData.getServiceMetaData().getWsdlFileOrLocation();
            if (wsdlURL == null)
            {
               log.warn("Validation error: Cannot obtain wsdl URL");
            }
            else
            {
               xsdStreams = schemaExtractor.getSchemas(wsdlURL);
            }
         }
         if (xsdURL != null)
         {
            ErrorHandler errorHandler = feature.getErrorHandler();
View Full Code Here

   }
   
   public void testSchemaValidationPositive() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      Map<String, byte[]> xsdStreams = new SchemaExtractor().getSchemas(wsdlURL);
      String inxml = "<tns:performTest xmlns:tns='http://www.my-company.it/ws/my-test'><Code>1000</Code></tns:performTest>";
      new SchemaValidationHelper(xsdStreams).validateDocument(inxml);
   }
View Full Code Here

   }
  
   public void testSchemaValidationNegative() throws Exception
   {
      URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
      Map<String, byte[]> xsdStreams = new SchemaExtractor().getSchemas(wsdlURL);
      String inxml = "<tns:performTest xmlns:tns='http://www.my-company.it/ws/my-test'><Code>2000</Code></tns:performTest>";
      try
      {
         new SchemaValidationHelper(xsdStreams).validateDocument(inxml);
      }
View Full Code Here

TOP

Related Classes of org.jboss.ws.extensions.validation.SchemaExtractor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.