DefaultMessagesProvider implements MessagesProvider { @Override public void addMessages(Definition definition) throws WSDLException { Types types = definition.getTypes(); Assert.notNull(types, "No types element present in definition"); for (Iterator<?> iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) { ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next(); if (extensibilityElement instanceof Schema) { Schema schema = (Schema) extensibilityElement; if (schema.getElement() != null) { createMessages(definition, schema.getElement()); } } } if (definition.getMessages().isEmpty() && logger.isWarnEnabled()) { logger.warn("No messages were created, make sure the referenced schema(s) contain elements"); } }  @Override void addMessages(Definition definition);  }
@Test public void testAddMessages() throws Exception { String definitionNamespace = "http: definition.addNamespace("tns", definitionNamespace); definition.setTargetNamespace(definitionNamespace); String schemaNamespace = "http: definition.addNamespace("schema", schemaNamespace); Resource resource = new ClassPathResource("schema.xsd", getClass()); Document schemaDocument = documentBuilder.parse(SaxUtils.createInputSource(resource)); Types types = definition.createTypes(); definition.setTypes(types); Schema schema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, new QName("http: types.addExtensibilityElement(schema); schema.setElement(schemaDocument.getDocumentElement()); provider.addMessages(definition); Assert.assertEquals("Invalid amount of messages created", 3, definition.getMessages().size()); Message message = definition.getMessage(new QName(definitionNamespace, "GetOrderRequest")); Assert.assertNotNull("Message not created", message); Part part = message.getPart("GetOrderRequest"); Assert.assertNotNull("Part not created", part); Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderRequest"), part.getElementName()); message = definition.getMessage(new QName(definitionNamespace, "GetOrderResponse")); Assert.assertNotNull("Message not created", message); part = message.getPart("GetOrderResponse"); Assert.assertNotNull("Part not created", part); Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderResponse"), part.getElementName()); message = definition.getMessage(new QName(definitionNamespace, "GetOrderFault")); Assert.assertNotNull("Message not created", message); part = message.getPart("GetOrderFault"); Assert.assertNotNull("Part not created", part); Assert.assertEquals("Invalid element on part", new QName(schemaNamespace, "GetOrderFault"), part.getElementName()); }