diff --git a/core/src/main/groovy/com/predic8/wsdl/style/DocumentLiteralStyle.groovy b/core/src/main/groovy/com/predic8/wsdl/style/DocumentLiteralStyle.groovy index b577290d..458ac24c 100644 --- a/core/src/main/groovy/com/predic8/wsdl/style/DocumentLiteralStyle.groovy +++ b/core/src/main/groovy/com/predic8/wsdl/style/DocumentLiteralStyle.groovy @@ -32,8 +32,6 @@ class DocumentLiteralStyle extends BindingStyle { def value = value.capitalize() - //??? style == mixed ==> Error ??? - def usages = (([operations.input]+ [operations.output]).bindingElements.use).flatten().unique() def err = [:] @@ -97,30 +95,61 @@ class DocumentLiteralStyle extends BindingStyle { } result } - - private checkDocLitErrors(List operations, PortType portType) { + + private checkDocLitErrors(List operations, PortType portType) { def errors = [] operations.each {op -> - //Check if every message in an operation uses only one part and if the part references an element. - def opMessages = ([portType.getOperation(op.name).input] + [portType.getOperation(op.name).output]).message - errors.addAll(checkPartErrors(op, opMessages)) - } - errors - } - - private checkPartErrors(BindingOperation op, List messages){ - def errors = [] - messages.each { msg -> - if(msg.parts?.size() > 1) { + //Check input soap body + def inputSoapBodyParts = op.input.bindingElements.grep(AbstractSOAPBody).partNames.flatten() + if(inputSoapBodyParts.size() == 1) { + return + } + if(inputSoapBodyParts.size() > 1) { def err = [:] - err['message'] = "The operation '${op.name}' uses the message '${msg.name}' which has more than one part." + err['message'] = "The operation '${op.name}' uses more than one part in soap body of the input element." err['operation'] = op - err['element'] = msg + err['element'] = op.input err['type'] = "moreThanOnePart" errors << err + } else { + //Check if the referenced message in the operation uses only one part and if the part references an element. + def opInputMessage = (portType.getOperation(op.name).input).message + errors.addAll(checkMessageParts(op, opInputMessage)) } - errors.addAll(checkElementInPart(msg)) + + //Check output soap body + def outputSoapBodyParts = op.output.bindingElements.grep(AbstractSOAPBody).partNames.flatten() + if(outputSoapBodyParts.size() == 1) { + return + } + if(outputSoapBodyParts.size() > 1) { + def err = [:] + err['message'] = "The operation '${op.name}' uses more than one part in soap body of the output element." + err['operation'] = op + err['element'] = op.output + err['type'] = "moreThanOnePart" + errors << err + } else { + //Check if the referenced message in the operation uses only one part and if the part references an element. + def opOutputMessage = (portType.getOperation(op.name).output).message + errors.addAll(checkMessageParts(op, opOutputMessage)) + } + + } + errors + } + + private checkMessageParts(BindingOperation op, Message message){ + def errors = [] + if(message.parts?.size() > 1) { + def err = [:] + err['message'] = "The operation '${op.name}' uses the message '${message.name}' which has more than one part." + err['operation'] = op + err['element'] = message + err['type'] = "moreThanOnePart" + errors << err } + errors.addAll(checkElementInPart(message)) errors }