Hashtable namespaceMap = new Hashtable();
String namespacePrefix = null;
String namespaceURI = null;
QName messagePartType = null;
for (int i = 0; i < method.length; i++) {
JMethod jmethod = method[i];
if (jmethod.isPublic()) {
// Request Message
OMElement requestMessge = fac.createOMElement(MESSAGE_LOCAL_NAME,
wsdl);
requestMessge.addAttribute(ATTRIBUTE_NAME,
jmethod.getSimpleName() + MESSAGE_SUFFIX,
null);
definitions.addChild(requestMessge);
// only if a type for the message part has already been defined
if ((messagePartType = typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(),
jmethod.getSimpleName())) != null) {
namespaceURI = messagePartType.getNamespaceURI();
// avoid duplicate namespaces
if ((namespacePrefix = (String) namespaceMap.get(namespaceURI)) == null) {
namespacePrefix = generatePrefix();
namespaceMap.put(namespaceURI,
namespacePrefix);
}
OMElement requestPart = fac.createOMElement(PART_ATTRIBUTE_NAME,
wsdl);
requestMessge.addChild(requestPart);
requestPart.addAttribute(ATTRIBUTE_NAME,
"part1",
null);
requestPart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
namespacePrefix + COLON_SEPARATOR
+ jmethod.getSimpleName(),
null);
}
// only if a type for the message part has already been defined
if ((messagePartType = typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(),
jmethod.getSimpleName()
+ RESPONSE)) != null) {
namespaceURI = messagePartType.getNamespaceURI();
if ((namespacePrefix = (String) namespaceMap.get(namespaceURI)) == null) {
namespacePrefix = generatePrefix();
namespaceMap.put(namespaceURI,
namespacePrefix);
}
// Response Message
OMElement responseMessge = fac.createOMElement(MESSAGE_LOCAL_NAME,
wsdl);
responseMessge.addAttribute(ATTRIBUTE_NAME,
jmethod.getSimpleName() + RESPONSE_MESSAGE,
null);
definitions.addChild(responseMessge);
OMElement responsePart = fac.createOMElement(PART_ATTRIBUTE_NAME,
wsdl);
responseMessge.addChild(responsePart);
responsePart.addAttribute(ATTRIBUTE_NAME,
"part1",
null);
responsePart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
namespacePrefix + COLON_SEPARATOR
+ jmethod.getSimpleName() + RESPONSE,
null);
}
}
}