private ArrayList getServiceInfo(PortType porttype)throws WrapperFault {
//get opeation list
Iterator oplist = porttype.getOperations().iterator();
ArrayList methods = new ArrayList();
MethodInfo minfo;
Element element;
QName qname;
ParameterInfo pinfo;
Type type;
org.apache.axis.wsdl.symbolTable.Type ptype;
//for each operation
while (oplist.hasNext()) {
minfo = new MethodInfo();
methods.add(minfo);
//add operation to operation List
Operation op = (Operation) oplist.next();
minfo.setMethodname(op.getName());
//setting the faults
Map faults = op.getFaults();
addFaultInfo(faults,minfo);
Iterator paramlist = null;
//add each parameter to parameter list
if ("document".equals(bindingEntry.getBindingStyle().getName())){
paramlist = op.getInput().getMessage().getParts().values().iterator();
Part part = (Part) paramlist.next();
element = symbolTable.getElement(part.getElementName());
qname = element.getRefType().getQName();
if (qname != null){
minfo.setInputMessage(element.getQName());
type = this.typeMap.getType(qname);
boolean wrapped = true; //TODO take this from a commandline argument
if (wrapped){
if(type == null)
throw new WrapperFault("unregisterd type "+qname+" refered");
else{
/* if(type.getLanguageSpecificName().startsWith(">")){*/ //anyway skip the wrapping element type even if it is a named type.
//get inner attributes and elements and add them as parameters
ArrayList elementlist = new ArrayList();
Iterator names = type.getElementnames();
while (names.hasNext()){
elementlist.add(names.next());
}
Type innerType;
for (int i = 0 ; i < elementlist.size(); i++) {
String elementname = (String)elementlist.get(i);
innerType = type.getElementForElementName(elementname).getType();
pinfo = new ParameterInfo(innerType,elementname);
pinfo.setElementName(type.getElementForElementName(elementname).getName());
minfo.addInputParameter(pinfo);
}
//remove the type that represents the wrapping element so that such type is not created.
this.typeMap.removeType(qname);
}
}
else{
}
}
}
else{
if (op.getParameterOrdering() != null){
for (int ix=0; ix < op.getParameterOrdering().size(); ix++){
Part p = (Part)(op.getInput().getMessage().getParts().get((String)op.getParameterOrdering().get(ix)));
if (p == null) continue;
pinfo = createParameterInfo(p);
if (null != pinfo) minfo.addInputParameter(pinfo);
}
}
else {
paramlist = op.getInput().getMessage().getParts().values().iterator();
while (paramlist.hasNext()) { //RPC style messages can have multiple parts
Part p = (Part) paramlist.next();
pinfo = createParameterInfo(p);
if (null != pinfo) minfo.addInputParameter(pinfo);
}
}
}
//get the return type
if(op.getOutput()!=null){
Iterator returnlist = op.getOutput().getMessage().getParts().values().iterator();
if (returnlist.hasNext() && "document".equals(bindingEntry.getBindingStyle().getName())){
Part part = (Part) returnlist.next();
element = symbolTable.getElement(part.getElementName());
qname = element.getRefType().getQName();
if (qname != null){
minfo.setOutputMessage(element.getQName());
type = this.typeMap.getType(qname);
boolean wrapped = true; //TODO take this from a commandline argument
if (wrapped){
if(type == null)
throw new WrapperFault("unregisterd type "+qname+" refered");
else{
/*if(type.getLanguageSpecificName().startsWith(">")){*///anyway skip the wrapping element type even if it is a named type.
//get inner attributes and elements and add them as parameters
ArrayList elementlist = new ArrayList();
Iterator names = type.getElementnames();
while (names.hasNext()){
elementlist.add(names.next());
}
Type innerType;
for (int i = 0 ; i < elementlist.size(); i++) {
String elementname = (String)elementlist.get(i);
innerType = type.getElementForElementName(elementname).getType();
pinfo = new ParameterInfo(innerType,elementname);
pinfo.setElementName(type.getElementForElementName(elementname).getName());
minfo.addOutputParameter(pinfo);
}
pinfo = new ParameterInfo(type,part.getName());
pinfo.setElementName(part.getElementName());
//remove the type that represents the wrapping element so that such type is not created.
this.typeMap.removeType(qname);
}
}
else{
}
}
}
else{
if (op.getParameterOrdering() != null){
for (int ix=0; ix < op.getParameterOrdering().size(); ix++){
Part p = (Part)(op.getOutput().getMessage().getParts().get((String)op.getParameterOrdering().get(ix)));
if (p == null) continue;
pinfo = createParameterInfo(p);
if (null != pinfo) minfo.addOutputParameter(pinfo);
}
/* there can be more output parameters than in parameterOrder list (partial parameter ordering) */
returnlist = op.getOutput().getMessage().getParts().values().iterator();
while (returnlist.hasNext()) { //RPC style messages can have multiple parts
Part p = (Part) returnlist.next();
if (op.getParameterOrdering().contains(p.getName())) continue;
pinfo = createParameterInfo(p);
if (null != pinfo) minfo.addInputParameter(pinfo);
}
}
else {
returnlist = op.getOutput().getMessage().getParts().values().iterator();
while (returnlist.hasNext()) { //RPC style messages can have multiple parts
Part p = ((Part) returnlist.next());
pinfo = createParameterInfo(p);
if (null != pinfo) minfo.addOutputParameter(pinfo);
}
}
}
}
}