String opName = operation.getName();
// if input message has no parts, add one containing an empty wrapper
Input input = operation.getInput();
if (input != null) {
Message inputMsg = input.getMessage();
if (inputMsg.getParts().isEmpty()) {
// create wrapper element and add it to the schema DOM
Element wrapper =
document.createElementNS("http://www.w3.org/2001/XMLSchema", xsPrefix + ":element");
wrapper.setAttribute("name", opName);
schema.appendChild(wrapper);
Element complexType =
document.createElementNS("http://www.w3.org/2001/XMLSchema", xsPrefix + ":complexType");
wrapper.appendChild(complexType);
// create new part for the wrapper and add it to the message
Part part = definition.createPart();
part.setName("parameters");
part.setElementName(new QName(namespaceURI, opName, prefix));
inputMsg.addPart(part);
}
}
// if two-way operation has no output message, add one containing an empty wrapper
if (input != null && operation.getOutput() == null) {
boolean isOneWay = false;
Method[] methods = javaInterface.getMethods();
for (Method method : methods) {
if (method.getName().equals(opName) && method.getAnnotation(OneWay.class) != null) {
isOneWay = true;
}
}
if (!isOneWay) {
// create wrapper element and add it to the schema DOM
String msgName = opName + "Response";
Element wrapper =
document.createElementNS("http://www.w3.org/2001/XMLSchema", xsPrefix + ":element");
wrapper.setAttribute("name", msgName);
schema.appendChild(wrapper);
Element complexType =
document.createElementNS("http://www.w3.org/2001/XMLSchema", xsPrefix + ":complexType");
wrapper.appendChild(complexType);
// create new part for the wrapper
Part part = definition.createPart();
part.setName("parameters");
part.setElementName(new QName(namespaceURI, msgName, prefix));
// create new message for the part
Message outputMsg = definition.createMessage();
outputMsg.setQName(new QName(namespaceURI, msgName, prefix));
outputMsg.addPart(part);
outputMsg.setUndefined(false);
definition.addMessage(outputMsg);
// create output element for the operation
Output output = definition.createOutput();
output.setMessage(outputMsg);