1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.description.FaultDesc; 19 import org.apache.axis.description.OperationDesc; 20 import org.apache.axis.description.ParameterDesc; 21 import org.apache.axis.description.ServiceDesc; 22 import org.apache.axis.encoding.SerializationContext; 23 import org.apache.axis.utils.JavaUtils; 24 import org.apache.axis.utils.XMLUtils; 25 import org.w3c.dom.Element ; 26 import org.xml.sax.helpers.AttributesImpl ; 27 28 import javax.xml.namespace.QName ; 29 import java.io.IOException ; 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 33 43 public class WSDDOperation extends WSDDElement 44 { 45 46 OperationDesc desc = new OperationDesc(); 47 48 51 public WSDDOperation(OperationDesc desc) { 52 this.desc = desc; 53 } 54 55 62 public WSDDOperation(Element e, ServiceDesc parent) 63 throws WSDDException 64 { 65 super(e); 66 67 desc.setParent(parent); 68 desc.setName(e.getAttribute(ATTR_NAME)); 69 70 String qNameStr = e.getAttribute(ATTR_QNAME); 71 if (qNameStr != null && !qNameStr.equals("")) 72 desc.setElementQName(XMLUtils.getQNameFromString(qNameStr, e)); 73 74 String retQNameStr = e.getAttribute(ATTR_RETQNAME); 75 if (retQNameStr != null && !retQNameStr.equals("")) 76 desc.setReturnQName(XMLUtils.getQNameFromString(retQNameStr, e)); 77 78 String retTypeStr = e.getAttribute(ATTR_RETTYPE); 79 if (retTypeStr != null && !retTypeStr.equals("")) 80 desc.setReturnType(XMLUtils.getQNameFromString(retTypeStr, e)); 81 82 String retHStr = e.getAttribute(ATTR_RETHEADER); 83 if (retHStr != null) { 84 desc.setReturnHeader(JavaUtils.isTrueExplicitly(retHStr)); 85 } 86 87 String retItemQName = e.getAttribute(ATTR_RETITEMQNAME); 88 if (retItemQName != null && !retItemQName.equals("")) { 89 ParameterDesc param = desc.getReturnParamDesc(); 90 param.setItemQName(XMLUtils.getQNameFromString(retItemQName, e)); 91 } 92 93 String retItemType = e.getAttribute(ATTR_RETITEMTYPE); 94 if (retItemType != null && !retItemType.equals("")) { 95 ParameterDesc param = desc.getReturnParamDesc(); 96 param.setItemType(XMLUtils.getQNameFromString(retItemType, e)); 97 } 98 99 String soapAction = e.getAttribute(ATTR_SOAPACTION); 100 if (soapAction != null) { 101 desc.setSoapAction(soapAction); 102 } 103 104 String mepString = e.getAttribute(ATTR_MEP); 105 if (mepString != null) { 106 desc.setMep(mepString); 107 } 108 109 Element [] parameters = getChildElements(e, ELEM_WSDD_PARAM); 110 for (int i = 0; i < parameters.length; i++) { 111 Element paramEl = parameters[i]; 112 WSDDParameter parameter = new WSDDParameter(paramEl, desc); 113 desc.addParameter(parameter.getParameter()); 114 } 115 116 Element [] faultElems = getChildElements(e, ELEM_WSDD_FAULT); 117 for (int i = 0; i < faultElems.length; i++) { 118 Element faultElem = faultElems[i]; 119 WSDDFault fault = new WSDDFault(faultElem); 120 desc.addFault(fault.getFaultDesc()); 121 } 122 123 Element docElem = getChildElement(e, ELEM_WSDD_DOC); 124 if (docElem != null) { 125 WSDDDocumentation documentation = new WSDDDocumentation(docElem); 126 desc.setDocumentation(documentation.getValue()); 127 } 128 } 129 130 133 public void writeToContext(SerializationContext context) 134 throws IOException { 135 AttributesImpl attrs = new AttributesImpl (); 136 137 if (desc.getReturnQName() != null) { 138 attrs.addAttribute("", ATTR_RETQNAME, ATTR_RETQNAME, 139 "CDATA", 140 context.qName2String(desc.getReturnQName())); 141 } 142 143 if (desc.getReturnType() != null) { 144 attrs.addAttribute("", ATTR_RETTYPE, ATTR_RETTYPE, 145 "CDATA", 146 context.qName2String(desc.getReturnType())); 147 } 148 if (desc.isReturnHeader()) { 149 attrs.addAttribute("", ATTR_RETHEADER, ATTR_RETHEADER, 150 "CDATA", "true"); 151 } 152 153 if (desc.getName() != null) { 154 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", desc.getName()); 155 } 156 157 if (desc.getElementQName() != null) { 158 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, 159 "CDATA", 160 context.qName2String(desc.getElementQName())); 161 } 162 163 QName retItemQName = desc.getReturnParamDesc().getItemQName(); 164 if (retItemQName != null) { 165 attrs.addAttribute("", ATTR_RETITEMQNAME, ATTR_RETITEMQNAME, 166 "CDATA", 167 context.qName2String(retItemQName)); 168 } 169 170 if (desc.getSoapAction() != null) { 171 attrs.addAttribute("", ATTR_SOAPACTION, ATTR_SOAPACTION, "CDATA", desc.getSoapAction()); 172 } 173 174 context.startElement(getElementName(), attrs); 175 176 if (desc.getDocumentation() != null) { 177 WSDDDocumentation documentation = new WSDDDocumentation(desc.getDocumentation()); 178 documentation.writeToContext(context); 179 } 180 181 ArrayList params = desc.getParameters(); 182 for (Iterator i = params.iterator(); i.hasNext();) { 183 ParameterDesc parameterDesc = (ParameterDesc) i.next(); 184 WSDDParameter p = new WSDDParameter(parameterDesc); 185 p.writeToContext(context); 186 } 187 188 ArrayList faults = desc.getFaults(); 189 if (faults != null) { 190 for (Iterator i = faults.iterator(); i.hasNext();) { 191 FaultDesc faultDesc = (FaultDesc) i.next(); 192 WSDDFault f = new WSDDFault(faultDesc); 193 f.writeToContext(context); 194 } 195 } 196 197 context.endElement(); 198 } 199 200 protected QName getElementName() { 201 return QNAME_OPERATION; 202 } 203 204 public OperationDesc getOperationDesc() 205 { 206 return desc; 207 } 208 } 209 | Popular Tags |