1 16 package org.apache.axis.wsdl.fromJava; 17 18 import com.ibm.wsdl.extensions.soap.SOAPAddressImpl; 19 import com.ibm.wsdl.extensions.soap.SOAPBindingImpl; 20 import com.ibm.wsdl.extensions.soap.SOAPBodyImpl; 21 import com.ibm.wsdl.extensions.soap.SOAPHeaderImpl; 22 import com.ibm.wsdl.extensions.soap.SOAPOperationImpl; 23 import org.apache.axis.AxisFault; 24 import org.apache.axis.Constants; 25 import org.apache.axis.InternalException; 26 import org.apache.axis.Version; 27 import org.apache.axis.components.logger.LogFactory; 28 import org.apache.axis.constants.Style; 29 import org.apache.axis.constants.Use; 30 import org.apache.axis.description.FaultDesc; 31 import org.apache.axis.description.JavaServiceDesc; 32 import org.apache.axis.description.OperationDesc; 33 import org.apache.axis.description.ParameterDesc; 34 import org.apache.axis.description.ServiceDesc; 35 import org.apache.axis.encoding.TypeMapping; 36 import org.apache.axis.encoding.TypeMappingRegistry; 37 import org.apache.axis.encoding.TypeMappingRegistryImpl; 38 import org.apache.axis.utils.ClassUtils; 39 import org.apache.axis.utils.JavaUtils; 40 import org.apache.axis.utils.Messages; 41 import org.apache.axis.utils.XMLUtils; 42 import org.apache.axis.wsdl.symbolTable.SymbolTable; 43 import org.apache.commons.logging.Log; 44 import org.w3c.dom.Comment ; 45 import org.w3c.dom.Document ; 46 import org.w3c.dom.Element ; 47 import org.w3c.dom.Text ; 48 import org.xml.sax.SAXException ; 49 50 import javax.wsdl.Binding; 51 import javax.wsdl.BindingFault; 52 import javax.wsdl.BindingInput; 53 import javax.wsdl.BindingOperation; 54 import javax.wsdl.BindingOutput; 55 import javax.wsdl.Definition; 56 import javax.wsdl.Fault; 57 import javax.wsdl.Import; 58 import javax.wsdl.Input; 59 import javax.wsdl.Message; 60 import javax.wsdl.Operation; 61 import javax.wsdl.OperationType; 62 import javax.wsdl.Output; 63 import javax.wsdl.Part; 64 import javax.wsdl.Port; 65 import javax.wsdl.PortType; 66 import javax.wsdl.Service; 67 import javax.wsdl.WSDLException; 68 import javax.wsdl.extensions.ExtensibilityElement; 69 import javax.wsdl.extensions.soap.SOAPAddress; 70 import javax.wsdl.extensions.soap.SOAPBinding; 71 import javax.wsdl.extensions.soap.SOAPBody; 72 import javax.wsdl.extensions.soap.SOAPFault; 73 import javax.wsdl.extensions.soap.SOAPHeader; 74 import javax.wsdl.extensions.soap.SOAPOperation; 75 import javax.wsdl.factory.WSDLFactory; 76 import javax.xml.namespace.QName ; 77 import javax.xml.parsers.ParserConfigurationException ; 78 import java.io.File ; 79 import java.io.FileOutputStream ; 80 import java.io.IOException ; 81 import java.io.StringWriter ; 82 import java.util.ArrayList ; 83 import java.util.HashMap ; 84 import java.util.Iterator ; 85 import java.util.List ; 86 import java.util.Map ; 87 import java.util.StringTokenizer ; 88 import java.util.Vector ; 89 90 98 public class Emitter { 99 100 101 protected static Log log = LogFactory.getLog(Emitter.class.getName()); 102 104 105 public static final int MODE_ALL = 0; 106 107 108 public static final int MODE_INTERFACE = 1; 109 110 111 public static final int MODE_IMPLEMENTATION = 2; 112 113 114 private Class cls; 115 116 117 private Class [] extraClasses; 119 120 private Class implCls; 122 123 private Vector allowedMethods = null; 125 126 private Vector disallowedMethods = null; 128 129 private ArrayList stopClasses = 130 new ArrayList (); 132 133 private boolean useInheritedMethods = false; 134 135 136 private String intfNS; 137 138 139 private String implNS; 140 141 142 private String inputSchema; 143 144 145 private String inputWSDL; 146 147 148 private String locationUrl; 149 150 151 private String importUrl; 152 153 154 private String servicePortName; 155 156 157 private String serviceElementName; 158 159 160 private String targetService = null; 161 162 163 private String description; 164 165 166 private Style style = Style.RPC; 167 168 169 private Use use = null; 171 172 private TypeMapping tm = null; 174 175 private TypeMappingRegistry tmr = new TypeMappingRegistryImpl(); 176 177 178 private Namespaces namespaces; 179 180 181 private Map exceptionMsg = null; 182 183 184 private Map usedElementNames; 185 186 187 private ArrayList encodingList; 188 189 190 protected Types types; 191 192 193 private String clsName; 194 195 196 private String portTypeName; 197 198 199 private String bindingName; 200 201 202 private ServiceDesc serviceDesc; 203 204 205 private JavaServiceDesc serviceDesc2; 206 207 208 private String soapAction = "DEFAULT"; 209 210 211 private boolean emitAllTypes = false; 212 213 214 private String versionMessage = null; 215 216 217 private HashMap qName2ClassMap; 218 219 221 222 public static final int MODE_RPC = 0; 223 224 225 public static final int MODE_DOCUMENT = 1; 226 227 228 public static final int MODE_DOC_WRAPPED = 2; 229 230 235 public Emitter() { 236 237 createDocumentFragment(); 238 239 namespaces = new Namespaces(); 240 exceptionMsg = new HashMap (); 241 usedElementNames = new HashMap (); 242 qName2ClassMap = new HashMap (); 243 } 244 245 255 public void emit(String filename1, String filename2) 256 throws IOException , WSDLException, SAXException , 257 ParserConfigurationException { 258 259 Definition intf = getIntfWSDL(); 261 Definition impl = getImplWSDL(); 262 263 if (filename1 == null) { 265 filename1 = getServicePortName() + "_interface.wsdl"; 266 } 267 268 if (filename2 == null) { 269 filename2 = getServicePortName() + "_implementation.wsdl"; 270 } 271 272 for (int i = 0; (extraClasses != null) && (i < extraClasses.length); 273 i++) { 274 types.writeTypeForPart(extraClasses[i], null); 275 } 276 277 Document doc = 280 WSDLFactory.newInstance().newWSDLWriter().getDocument(intf); 281 282 types.insertTypesFragment(doc); 283 prettyDocumentToFile(doc, filename1); 284 285 doc = WSDLFactory.newInstance().newWSDLWriter().getDocument(impl); 287 288 prettyDocumentToFile(doc, filename2); 289 } 290 291 300 public void emit(String filename) 301 throws IOException , WSDLException, SAXException , 302 ParserConfigurationException { 303 emit(filename, MODE_ALL); 304 } 305 306 320 public Document emit(int mode) 321 throws IOException , WSDLException, SAXException , 322 ParserConfigurationException { 323 324 Document doc; 325 Definition def; 326 327 switch (mode) { 328 329 default: 330 case MODE_ALL: 331 def = getWSDL(); 332 333 for (int i = 0; 334 (extraClasses != null) && (i < extraClasses.length); 335 i++) { 336 types.writeTypeForPart(extraClasses[i], null); 337 } 338 339 doc = WSDLFactory.newInstance().newWSDLWriter().getDocument( 341 def); 342 343 types.insertTypesFragment(doc); 344 break; 345 346 case MODE_INTERFACE: 347 def = getIntfWSDL(); 348 349 for (int i = 0; 350 (extraClasses != null) && (i < extraClasses.length); 351 i++) { 352 types.writeTypeForPart(extraClasses[i], null); 353 } 354 355 doc = WSDLFactory.newInstance().newWSDLWriter().getDocument( 357 def); 358 359 types.insertTypesFragment(doc); 360 break; 361 362 case MODE_IMPLEMENTATION: 363 def = getImplWSDL(); 364 doc = WSDLFactory.newInstance().newWSDLWriter().getDocument( 365 def); 366 break; 367 } 368 369 if (versionMessage == null) { 371 versionMessage = Messages.getMessage( 372 "wsdlCreated00", 373 XMLUtils.xmlEncodeString(Version.getVersion())); 374 } 375 if (versionMessage != null && versionMessage.length() > 0) { 377 Comment wsdlVersion = doc.createComment(versionMessage); 378 doc.getDocumentElement().insertBefore( 379 wsdlVersion, doc.getDocumentElement().getFirstChild()); 380 } 381 382 return doc; 384 } 385 386 400 public String emitToString(int mode) 401 throws IOException , WSDLException, SAXException , 402 ParserConfigurationException { 403 404 Document doc = emit(mode); 405 StringWriter sw = new StringWriter (); 406 407 XMLUtils.PrettyDocumentToWriter(doc, sw); 408 409 return sw.toString(); 410 } 411 412 426 public void emit(String filename, int mode) 427 throws IOException , WSDLException, SAXException , 428 ParserConfigurationException { 429 430 Document doc = emit(mode); 431 432 if (filename == null) { 434 filename = getServicePortName(); 435 436 switch (mode) { 437 438 case MODE_ALL: 439 filename += ".wsdl"; 440 break; 441 442 case MODE_INTERFACE: 443 filename += "_interface.wsdl"; 444 break; 445 446 case MODE_IMPLEMENTATION: 447 filename += "_implementation.wsdl"; 448 break; 449 } 450 } 451 452 prettyDocumentToFile(doc, filename); 453 } 454 455 465 public Definition getWSDL() 466 throws IOException , WSDLException, SAXException , 467 ParserConfigurationException { 468 469 init(MODE_ALL); 471 472 Definition def = createDefinition(); 474 475 writeDefinitions(def, intfNS); 477 478 types = createTypes(def); 480 481 Binding binding = writeBinding(def, true); 483 484 writePortType(def, binding); 485 writeService(def, binding); 486 487 return def; 488 } 489 490 500 public Definition getIntfWSDL() 501 throws IOException , WSDLException, SAXException , 502 ParserConfigurationException { 503 504 init(MODE_INTERFACE); 506 507 Definition def = createDefinition(); 509 510 writeDefinitions(def, intfNS); 512 513 types = createTypes(def); 515 516 Binding binding = writeBinding(def, true); 518 519 writePortType(def, binding); 520 521 return def; 522 } 523 524 534 public Definition getImplWSDL() 535 throws IOException , WSDLException, SAXException , 536 ParserConfigurationException { 537 538 init(MODE_IMPLEMENTATION); 540 541 Definition def = createDefinition(); 543 544 writeDefinitions(def, implNS); 546 writeImport(def, intfNS, importUrl); 547 548 Binding binding = writeBinding(def, false); 551 writeService(def, binding); 552 553 return def; 554 } 555 556 562 protected void init(int mode) { 563 564 if (use == null) { 566 if (style == Style.RPC) { 567 use = Use.ENCODED; 568 } else { 569 use = Use.LITERAL; 570 } 571 } 572 573 if (tm == null) { 574 String encodingStyle = ""; 575 if (use == Use.ENCODED) { 576 encodingStyle = Constants.URI_SOAP11_ENC; 577 578 } 579 tm = (TypeMapping)tmr.getTypeMapping(encodingStyle); 580 } 581 582 if (serviceDesc == null) { 584 JavaServiceDesc javaServiceDesc = new JavaServiceDesc(); 585 serviceDesc = javaServiceDesc; 586 587 javaServiceDesc.setImplClass(cls); 588 589 serviceDesc.setTypeMapping(tm); 591 592 javaServiceDesc.setStopClasses(stopClasses); 593 serviceDesc.setAllowedMethods(allowedMethods); 594 javaServiceDesc.setDisallowedMethods(disallowedMethods); 595 serviceDesc.setStyle(style); 596 serviceDesc.setUse(use); 597 598 if ((implCls != null) && (implCls != cls) 603 && (serviceDesc2 == null)) { 604 serviceDesc2 = new JavaServiceDesc(); 605 606 serviceDesc2.setImplClass(implCls); 607 608 serviceDesc2.setTypeMapping(tm); 610 611 serviceDesc2.setStopClasses(stopClasses); 612 serviceDesc2.setAllowedMethods(allowedMethods); 613 serviceDesc2.setDisallowedMethods(disallowedMethods); 614 serviceDesc2.setStyle(style); 615 } 616 } 617 618 if (encodingList == null) { 619 620 if (cls != null) { 623 clsName = cls.getName(); 624 clsName = clsName.substring(clsName.lastIndexOf('.') + 1); 625 } else { 626 clsName = getServiceDesc().getName(); 627 } 628 629 if (getPortTypeName() == null) { 631 setPortTypeName(clsName); 632 } 633 634 if (getServiceElementName() == null) { 636 setServiceElementName(getPortTypeName() + "Service"); 637 } 638 639 if (getServicePortName() == null) { 641 String name = getLocationUrl(); 642 643 if (name != null) { 644 if (name.lastIndexOf('/') > 0) { 645 name = name.substring(name.lastIndexOf('/') + 1); 646 } else if (name.lastIndexOf('\\') > 0) { 647 name = name.substring(name.lastIndexOf('\\') + 1); 648 } else { 649 name = null; 650 } 651 652 if ((name != null) && name.endsWith(".jws")) { 654 name = name.substring(0, (name.length() 655 - ".jws".length())); 656 } 657 } 658 659 if ((name == null) || name.equals("")) { 660 name = clsName; 661 } 662 663 setServicePortName(name); 664 } 665 666 if (getBindingName() == null) { 668 setBindingName(getServicePortName() + "SoapBinding"); 669 } 670 671 encodingList = new ArrayList (); 672 673 encodingList.add(Constants.URI_DEFAULT_SOAP_ENC); 674 675 if (intfNS == null) { 676 Package pkg = cls.getPackage(); 677 678 intfNS = namespaces.getCreate((pkg == null) 679 ? null 680 : pkg.getName()); 681 } 682 683 if (implNS == null) { 686 if (mode == MODE_ALL) { 687 implNS = intfNS; 688 } else { 689 implNS = intfNS + "-impl"; 690 } 691 } 692 693 serviceDesc.setDefaultNamespace(intfNS); 695 696 if (serviceDesc2 != null) { 697 serviceDesc2.setDefaultNamespace(implNS); 698 } 699 700 if (cls != null) { 701 String clsName = cls.getName(); 702 int idx = clsName.lastIndexOf("."); 703 if (idx > 0) { 704 String pkgName = clsName.substring(0, idx); 705 namespaces.put(pkgName, intfNS, "intf"); 706 } 707 } 708 709 namespaces.putPrefix(implNS, "impl"); 710 } 711 } 712 713 723 protected Definition createDefinition() 724 throws WSDLException, SAXException , IOException , 725 ParserConfigurationException { 726 727 Definition def; 728 729 if (inputWSDL == null) { 730 def = WSDLFactory.newInstance().newDefinition(); 731 } else { 732 javax.wsdl.xml.WSDLReader reader = 733 WSDLFactory.newInstance().newWSDLReader(); 734 Document doc = XMLUtils.newDocument(inputWSDL); 735 736 def = reader.readWSDL(null, doc); 737 738 def.setTypes(null); 741 } 742 743 return def; 744 } 745 746 747 protected static TypeMapping standardTypes = 748 (TypeMapping) new org.apache.axis.encoding.TypeMappingRegistryImpl().getTypeMapping( 749 null); 750 751 761 protected Types createTypes(Definition def) 762 throws IOException , WSDLException, SAXException , 763 ParserConfigurationException { 764 765 types = new Types(def, tm, (TypeMapping)tmr.getDefaultTypeMapping(), 766 namespaces, intfNS, stopClasses, serviceDesc, this); 767 768 if (inputWSDL != null) { 769 types.loadInputTypes(inputWSDL); 770 } 771 772 if (inputSchema != null) { 773 StringTokenizer tokenizer = new StringTokenizer (inputSchema, ", "); 774 775 while (tokenizer.hasMoreTokens()) { 776 String token = tokenizer.nextToken(); 777 778 types.loadInputSchema(token); 779 } 780 } 781 782 if (emitAllTypes && tm != null) { 784 Class [] mappedTypes = tm.getAllClasses(); 785 786 for (int i = 0; i < mappedTypes.length; i++) { 787 Class mappedType = mappedTypes[i]; 788 QName name = tm.getTypeQName(mappedType); 789 if (name.getLocalPart().indexOf(SymbolTable.ANON_TOKEN) != -1) { 790 continue; 794 } 795 796 800 if (standardTypes.getSerializer(mappedType) == null) { 801 types.writeTypeForPart(mappedType, name); 802 } 803 } 804 805 types.mappedTypes = null; 808 } 809 810 return types; 811 } 812 813 819 protected Element createDocumentationElement(String documentation) { 820 Element element = docHolder.createElementNS(Constants.NS_URI_WSDL11, "documentation"); 821 element.setPrefix(Constants.NS_PREFIX_WSDL); 822 Text textNode = 823 docHolder.createTextNode(documentation); 824 825 element.appendChild(textNode); 826 return element; 827 } 828 829 835 protected void writeDefinitions(Definition def, String tns) { 836 837 def.setTargetNamespace(tns); 838 def.addNamespace("intf", intfNS); 839 def.addNamespace("impl", implNS); 840 def.addNamespace(Constants.NS_PREFIX_WSDL_SOAP, 841 Constants.URI_WSDL11_SOAP); 842 namespaces.putPrefix(Constants.URI_WSDL11_SOAP, 843 Constants.NS_PREFIX_WSDL_SOAP); 844 def.addNamespace(Constants.NS_PREFIX_WSDL, Constants.NS_URI_WSDL11); 845 namespaces.putPrefix(Constants.NS_URI_WSDL11, Constants.NS_PREFIX_WSDL); 846 847 if (use == Use.ENCODED) { 848 def.addNamespace(Constants.NS_PREFIX_SOAP_ENC, 849 Constants.URI_DEFAULT_SOAP_ENC); 850 namespaces.putPrefix(Constants.URI_DEFAULT_SOAP_ENC, 851 Constants.NS_PREFIX_SOAP_ENC); 852 } 853 854 def.addNamespace(Constants.NS_PREFIX_SCHEMA_XSD, 855 Constants.URI_DEFAULT_SCHEMA_XSD); 856 namespaces.putPrefix(Constants.URI_DEFAULT_SCHEMA_XSD, 857 Constants.NS_PREFIX_SCHEMA_XSD); 858 def.addNamespace(Constants.NS_PREFIX_XMLSOAP, Constants.NS_URI_XMLSOAP); 859 namespaces.putPrefix(Constants.NS_URI_XMLSOAP, 860 Constants.NS_PREFIX_XMLSOAP); 861 } 862 863 870 protected void writeImport(Definition def, String tns, String loc) { 871 872 Import imp = def.createImport(); 873 874 imp.setNamespaceURI(tns); 875 876 if ((loc != null) && !loc.equals("")) { 877 imp.setLocationURI(loc); 878 } 879 880 def.addImport(imp); 881 } 882 883 890 protected Binding writeBinding(Definition def, boolean add) { 891 892 QName bindingQName = new QName (intfNS, getBindingName()); 893 894 Binding binding = def.getBinding(bindingQName); 896 897 if (binding != null) { 898 return binding; 899 } 900 901 binding = def.createBinding(); 903 904 binding.setUndefined(false); 905 binding.setQName(bindingQName); 906 907 SOAPBinding soapBinding = new SOAPBindingImpl(); 908 String styleStr = (style == Style.RPC) 909 ? "rpc" 910 : "document"; 911 912 soapBinding.setStyle(styleStr); 913 soapBinding.setTransportURI(Constants.URI_SOAP11_HTTP); 914 binding.addExtensibilityElement(soapBinding); 915 916 if (add) { 917 def.addBinding(binding); 918 } 919 920 return binding; 921 } 922 923 924 Document docHolder; 925 926 929 private void createDocumentFragment() { 930 931 try { 932 this.docHolder = XMLUtils.newDocument(); 933 } catch (ParserConfigurationException e) { 934 935 throw new InternalException(e); 937 } 938 } 939 940 946 protected void writeService(Definition def, Binding binding) { 947 948 QName serviceElementQName = new QName (implNS, getServiceElementName()); 949 950 Service service = def.getService(serviceElementQName); 952 953 if (service == null) { 954 service = def.createService(); 955 956 service.setQName(serviceElementQName); 957 def.addService(service); 958 } 959 960 if (description != null) { 961 service.setDocumentationElement( 962 createDocumentationElement(description)); 963 } else if (serviceDesc.getDocumentation() != null) { 964 service.setDocumentationElement( 965 createDocumentationElement( 966 serviceDesc.getDocumentation())); 967 } 968 969 Port port = def.createPort(); 971 972 port.setBinding(binding); 973 974 port.setName(getServicePortName()); 976 977 SOAPAddress addr = new SOAPAddressImpl(); 978 979 addr.setLocationURI(locationUrl); 980 port.addExtensibilityElement(addr); 981 service.addPort(port); 982 } 983 984 992 protected void writePortType(Definition def, Binding binding) 993 throws WSDLException, AxisFault { 994 995 QName portTypeQName = new QName (intfNS, getPortTypeName()); 996 997 PortType portType = def.getPortType(portTypeQName); 999 boolean newPortType = false; 1000 1001 if (portType == null) { 1002 portType = def.createPortType(); 1003 1004 portType.setUndefined(false); 1005 portType.setQName(portTypeQName); 1006 1007 newPortType = true; 1008 } else if (binding.getBindingOperations().size() > 0) { 1009 1010 return; 1013 } 1014 1015 ArrayList operations = serviceDesc.getOperations(); 1017 1018 for (Iterator i = operations.iterator(); i.hasNext();) { 1019 OperationDesc thisOper = (OperationDesc) i.next(); 1020 BindingOperation bindingOper = writeOperation(def, binding, 1021 thisOper); 1022 Operation oper = bindingOper.getOperation(); 1023 OperationDesc messageOper = thisOper; 1024 1025 if (messageOper.getDocumentation() != null) { 1027 oper.setDocumentationElement( 1028 createDocumentationElement( 1029 messageOper.getDocumentation())); 1030 } 1031 1032 if (serviceDesc2 != null) { 1033 1034 OperationDesc[] operArray = 1041 serviceDesc2.getOperationsByName(thisOper.getName()); 1042 boolean found = false; 1043 1044 if (operArray != null) { 1045 for (int j = 0; (j < operArray.length) && !found; j++) { 1046 OperationDesc tryOper = operArray[j]; 1047 1048 if (tryOper.getParameters().size() 1049 == thisOper.getParameters().size()) { 1050 boolean parmsMatch = true; 1051 1052 for (int k = 1053 0; (k < thisOper.getParameters().size()) 1054 && parmsMatch; k++) { 1055 if ((tryOper.getParameter( 1056 k).getMode() != thisOper.getParameter( 1057 k).getMode()) 1058 || (!tryOper.getParameter( 1059 k).getJavaType().equals( 1060 thisOper.getParameter( 1061 k).getJavaType()))) { 1062 parmsMatch = false; 1063 } 1064 } 1065 1066 if (parmsMatch) { 1067 messageOper = tryOper; 1068 found = true; 1069 } 1070 } 1071 } 1072 } 1073 } 1074 1075 writeMessages(def, oper, messageOper, bindingOper); 1076 1077 if (newPortType) { 1078 portType.addOperation(oper); 1079 } 1080 } 1081 1082 if (newPortType) { 1083 def.addPortType(portType); 1084 } 1085 1086 binding.setPortType(portType); 1087 } 1088 1089 1099 protected void writeMessages(Definition def, 1100 Operation oper, 1101 OperationDesc desc, 1102 BindingOperation bindingOper) 1103 throws WSDLException, AxisFault { 1104 1105 Input input = def.createInput(); 1106 Message msg = writeRequestMessage(def, desc, bindingOper); 1107 1108 input.setMessage(msg); 1109 1110 String name = msg.getQName().getLocalPart(); 1114 1115 input.setName(name); 1116 bindingOper.getBindingInput().setName(name); 1117 oper.setInput(input); 1118 def.addMessage(msg); 1119 1120 if (OperationType.REQUEST_RESPONSE.equals(desc.getMep())) { 1121 msg = writeResponseMessage(def, desc, bindingOper); 1122 1123 Output output = def.createOutput(); 1124 1125 output.setMessage(msg); 1126 1127 name = msg.getQName().getLocalPart(); 1131 1132 output.setName(name); 1133 bindingOper.getBindingOutput().setName(name); 1134 oper.setOutput(output); 1135 def.addMessage(msg); 1136 } 1137 1138 ArrayList exceptions = desc.getFaults(); 1139 1140 for (int i = 0; (exceptions != null) && (i < exceptions.size()); i++) { 1141 FaultDesc faultDesc = (FaultDesc) exceptions.get(i); 1142 1143 msg = writeFaultMessage(def, faultDesc); 1144 1145 Fault fault = def.createFault(); 1147 1148 fault.setMessage(msg); 1149 fault.setName(faultDesc.getName()); 1150 oper.addFault(fault); 1151 1152 BindingFault bFault = def.createBindingFault(); 1154 1155 bFault.setName(faultDesc.getName()); 1156 1157 SOAPFault soapFault = writeSOAPFault(faultDesc); 1158 1159 bFault.addExtensibilityElement(soapFault); 1160 bindingOper.addBindingFault(bFault); 1161 1162 if (def.getMessage(msg.getQName()) == null) { 1164 def.addMessage(msg); 1165 } 1166 } 1167 1168 ArrayList parameters = desc.getParameters(); 1170 Vector names = new Vector (); 1171 1172 for (int i = 0; i < parameters.size(); i++) { 1173 ParameterDesc param = (ParameterDesc) parameters.get(i); 1174 1175 names.add(param.getName()); 1176 } 1177 1178 if (names.size() > 0) { 1179 if (style == Style.WRAPPED) { 1180 names.clear(); 1181 } else { 1182 oper.setParameterOrdering(names); 1183 } 1184 } 1185 } 1186 1187 1195 protected BindingOperation writeOperation(Definition def, Binding binding, 1196 OperationDesc desc) { 1197 1198 Operation oper = def.createOperation(); 1199 1200 QName elementQName = desc.getElementQName(); 1201 if(elementQName != null && elementQName.getLocalPart() != null) { 1202 oper.setName(elementQName.getLocalPart()); 1203 } else { 1204 oper.setName(desc.getName()); 1205 } 1206 oper.setUndefined(false); 1207 1208 return writeBindingOperation(def, binding, oper, desc); 1209 } 1210 1211 1220 protected BindingOperation writeBindingOperation(Definition def, 1221 Binding binding, 1222 Operation oper, 1223 OperationDesc desc) { 1224 1225 BindingOperation bindingOper = def.createBindingOperation(); 1226 BindingInput bindingInput = def.createBindingInput(); 1227 BindingOutput bindingOutput = null; 1228 1229 if (OperationType.REQUEST_RESPONSE.equals(desc.getMep())) 1231 bindingOutput = def.createBindingOutput(); 1232 1233 bindingOper.setName(oper.getName()); 1234 bindingOper.setOperation(oper); 1235 1236 SOAPOperation soapOper = new SOAPOperationImpl(); 1237 1238 String soapAction; 1243 if (getSoapAction().equalsIgnoreCase("OPERATION")) { 1244 soapAction = oper.getName(); 1245 } else if (getSoapAction().equalsIgnoreCase("NONE")) { 1246 soapAction = ""; 1247 } else { 1248 soapAction = desc.getSoapAction(); 1249 1250 if (soapAction == null) { 1251 soapAction = ""; 1252 } 1253 } 1254 1255 soapOper.setSoapActionURI(soapAction); 1256 1257 bindingOper.addExtensibilityElement(soapOper); 1261 1262 ExtensibilityElement inputBody = writeSOAPBody(desc.getElementQName()); 1264 bindingInput.addExtensibilityElement(inputBody); 1265 1266 1269 if (bindingOutput != null) { 1271 ExtensibilityElement outputBody = writeSOAPBody(desc.getReturnQName()); 1272 bindingOutput.addExtensibilityElement(outputBody); 1273 bindingOper.setBindingOutput(bindingOutput); 1274 1275 } 1278 1279 bindingOper.setBindingInput(bindingInput); 1281 1282 1304 1305 binding.addBindingOperation(bindingOper); 1306 1307 return bindingOper; 1308 } 1309 1310 1313 protected SOAPHeader writeSOAPHeader(ParameterDesc p, QName messageQName, String partName) 1314 { 1315 SOAPHeaderImpl soapHeader = new SOAPHeaderImpl(); 1316 1317 if (use == Use.ENCODED) { 1319 soapHeader.setUse("encoded"); 1320 soapHeader.setEncodingStyles(encodingList); 1321 } else { 1322 soapHeader.setUse("literal"); 1323 } 1324 1325 if (targetService == null) { 1327 soapHeader.setNamespaceURI(intfNS); 1328 } else { 1329 soapHeader.setNamespaceURI(targetService); 1330 } 1331 QName headerQName = p.getQName(); 1332 if ((headerQName != null) && !headerQName.getNamespaceURI().equals("")) { 1333 soapHeader.setNamespaceURI(headerQName.getNamespaceURI()); 1334 } 1335 1336 soapHeader.setMessage(messageQName); 1338 soapHeader.setPart(partName); 1339 1340 return soapHeader; 1341 } 1342 1343 1349 protected ExtensibilityElement writeSOAPBody(QName operQName) { 1350 1351 SOAPBody soapBody = new SOAPBodyImpl(); 1352 1353 if (use == Use.ENCODED) { 1355 soapBody.setUse("encoded"); 1356 soapBody.setEncodingStyles(encodingList); 1357 } else { 1358 soapBody.setUse("literal"); 1359 } 1360 1361 if (style == Style.RPC) { 1362 if (targetService == null) { 1363 soapBody.setNamespaceURI(intfNS); 1364 } else { 1365 soapBody.setNamespaceURI(targetService); 1366 } 1367 1368 if ((operQName != null) && !operQName.getNamespaceURI().equals("")) { 1369 soapBody.setNamespaceURI(operQName.getNamespaceURI()); 1370 } 1371 } 1372 1373 1377 return soapBody; 1378 } 1380 1386 protected SOAPFault writeSOAPFault(FaultDesc faultDesc) { 1387 1388 SOAPFault soapFault = new com.ibm.wsdl.extensions.soap.SOAPFaultImpl(); 1389 1390 soapFault.setName(faultDesc.getName()); 1391 1392 if (use != Use.ENCODED) { 1393 soapFault.setUse("literal"); 1394 1395 } else { 1397 soapFault.setUse("encoded"); 1398 soapFault.setEncodingStyles(encodingList); 1399 1400 QName faultQName = faultDesc.getQName(); 1403 1404 if ((faultQName != null) 1405 && !faultQName.getNamespaceURI().equals("")) { 1406 soapFault.setNamespaceURI(faultQName.getNamespaceURI()); 1407 } else { 1408 if (targetService == null) { 1409 soapFault.setNamespaceURI(intfNS); 1410 } else { 1411 soapFault.setNamespaceURI(targetService); 1412 } 1413 } 1414 } 1415 1416 return soapFault; 1417 } 1419 1428 protected Message writeRequestMessage(Definition def, OperationDesc oper, BindingOperation bindop) 1429 throws WSDLException, AxisFault 1430 { 1431 1432 String partName; 1433 ArrayList bodyParts = new ArrayList (); 1434 ArrayList parameters = oper.getAllInParams(); 1435 1436 Message msg = def.createMessage(); 1437 QName qName = createMessageName(def, 1438 getRequestQName(oper).getLocalPart() + "Request"); 1439 1440 msg.setQName(qName); 1441 msg.setUndefined(false); 1442 1443 boolean headers = writeHeaderParts(def, parameters, bindop, msg, true); 1445 1446 if (oper.getStyle() == Style.MESSAGE) { 1447 1448 QName qname = oper.getElementQName(); 1452 types.writeElementDecl(qname, Object .class, 1453 Constants.XSD_ANYTYPE, false, null); 1454 1455 Part part = def.createPart(); 1456 1457 part.setName("part"); 1458 part.setElementName(qname); 1459 msg.addPart(part); 1460 bodyParts.add(part.getName()); 1461 1462 } else if (oper.getStyle() == Style.WRAPPED) { 1463 1464 partName = writeWrapperPart(def, msg, oper, true); 1468 bodyParts.add(partName); 1469 1470 } else { 1471 if(oper.getStyle() == Style.DOCUMENT && parameters.size()>1 ) { 1479 System.out.println(Messages.getMessage("warnDocLitInteropMultipleInputParts")); 1480 } 1481 1482 for (int i = 0; i < parameters.size(); i++) { 1484 ParameterDesc parameter = (ParameterDesc) parameters.get(i); 1485 if (!parameter.isInHeader() && !parameter.isOutHeader()) { 1486 partName = writePartToMessage(def, msg, true, parameter); 1487 bodyParts.add(partName); 1488 } 1489 } 1490 } 1491 1492 if (headers) { 1495 List extensibilityElements = bindop.getBindingInput().getExtensibilityElements(); 1497 for (int i = 0; i < extensibilityElements.size(); i++) 1498 { 1499 Object ele = extensibilityElements.get(i); 1500 if (ele instanceof SOAPBodyImpl) 1501 { 1502 SOAPBodyImpl soapBody = (SOAPBodyImpl) ele; 1503 soapBody.setParts(bodyParts); 1504 } 1505 } 1506 } 1507 1508 return msg; 1509 } 1510 1511 1522 private boolean writeHeaderParts(Definition def, 1523 ArrayList parameters, 1524 BindingOperation bindop, 1525 Message msg, 1526 boolean request) throws WSDLException, AxisFault 1527 { 1528 boolean wroteHeaderParts = false; 1529 String partName; 1530 1531 for (int i = 0; i < parameters.size(); i++) { 1533 ParameterDesc parameter = (ParameterDesc) parameters.get(i); 1534 1535 if (request && parameter.isInHeader()) { 1537 partName = writePartToMessage(def, msg, request, parameter); 1539 SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName); 1541 bindop.getBindingInput().addExtensibilityElement(hdr); 1543 wroteHeaderParts = true; 1544 } 1545 else if (!request && parameter.isOutHeader()) { 1546 partName = writePartToMessage(def, msg, request, parameter); 1548 SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName); 1550 bindop.getBindingOutput().addExtensibilityElement(hdr); 1552 wroteHeaderParts = true; 1553 } 1554 else { 1555 continue; } 1557 } 1558 return wroteHeaderParts; 1559 } 1560 1561 1567 protected QName getRequestQName(OperationDesc oper) { 1568 1569 qualifyOperation(oper); 1570 1571 QName qname = oper.getElementQName(); 1572 1573 if (qname == null) { 1574 qname = new QName (oper.getName()); 1575 } 1576 1577 return qname; 1578 } 1579 1580 1585 private void qualifyOperation(OperationDesc oper) { 1586 1587 if ((style == Style.WRAPPED) && (use == Use.LITERAL)) { 1588 QName qname = oper.getElementQName(); 1589 1590 if (qname == null) { 1591 qname = new QName (intfNS, oper.getName()); 1592 } else if (qname.getNamespaceURI().equals("")) { 1593 qname = new QName (intfNS, qname.getLocalPart()); 1594 } 1595 1596 oper.setElementQName(qname); 1597 } 1598 } 1599 1600 1606 protected QName getResponseQName(OperationDesc oper) { 1607 1608 qualifyOperation(oper); 1609 1610 QName qname = oper.getElementQName(); 1611 1612 if (qname == null) { 1613 return new QName (oper.getName() + "Response"); 1614 } 1615 1616 return new QName (qname.getNamespaceURI(), 1617 qname.getLocalPart() + "Response"); 1618 } 1619 1620 1631 public String writeWrapperPart( 1632 Definition def, Message msg, OperationDesc oper, boolean request) 1633 throws AxisFault { 1634 1635 QName qname = request 1636 ? getRequestQName(oper) 1637 : getResponseQName(oper); 1638 1639 boolean hasParams; 1640 if (request) { 1641 hasParams = (oper.getNumInParams() > 0); 1642 } else { 1643 if (oper.getReturnClass() != void.class) { 1644 hasParams = true; 1645 } else { 1646 hasParams = (oper.getNumOutParams() > 0); 1647 } 1648 } 1649 1650 Element sequence = types.writeWrapperElement(qname, request, hasParams); 1652 1653 if (sequence != null) { 1656 ArrayList parameters = request 1657 ? oper.getAllInParams() 1658 : oper.getAllOutParams(); 1659 1660 if (!request) { 1661 String retName; 1662 1663 if (oper.getReturnQName() == null) { 1664 retName = oper.getName() + "Return"; 1665 } else { 1666 retName = oper.getReturnQName().getLocalPart(); 1667 } 1668 1669 types.writeWrappedParameter(sequence, retName, 1670 oper.getReturnType(), 1671 oper.getReturnClass()); 1672 } 1673 1674 for (int i = 0; i < parameters.size(); i++) { 1675 ParameterDesc parameter = (ParameterDesc) parameters.get(i); 1676 1677 if (!parameter.isInHeader() && !parameter.isOutHeader()) 1679 { 1680 types.writeWrappedParameter(sequence, 1681 parameter.getName(), 1682 parameter.getTypeQName(), 1683 parameter.getJavaType()); 1684 } 1685 } 1686 } 1687 1688 Part part = def.createPart(); 1690 1691 part.setName("parameters"); part.setElementName(qname); 1693 msg.addPart(part); 1694 1695 return part.getName(); 1696 } 1697 1698 1707 protected Message writeResponseMessage(Definition def, OperationDesc desc, BindingOperation bindop) 1708 throws WSDLException, AxisFault 1709 { 1710 String partName; 1711 ArrayList bodyParts = new ArrayList (); 1712 ArrayList parameters = desc.getAllOutParams(); 1713 1714 Message msg = def.createMessage(); 1715 QName qName = 1716 createMessageName(def, getResponseQName(desc).getLocalPart()); 1717 1718 msg.setQName(qName); 1719 msg.setUndefined(false); 1720 1721 boolean headers = writeHeaderParts(def, parameters, bindop, msg, false); 1723 1724 if (desc.getStyle() == Style.WRAPPED) { 1725 partName = writeWrapperPart(def, msg, desc, false); 1726 bodyParts.add(partName); 1727 } else { 1728 1729 ParameterDesc retParam = new ParameterDesc(); 1731 1732 if (desc.getReturnQName() == null) { 1733 String ns = ""; 1734 1735 if (desc.getStyle() != Style.RPC) { 1736 ns = getServiceDesc().getDefaultNamespace(); 1737 1738 if ((ns == null) || "".equals(ns)) { 1739 ns = "http://ws.apache.org/axis/defaultNS"; 1740 } 1741 } 1742 1743 retParam.setQName(new QName (ns, desc.getName() + "Return")); 1744 } else { 1745 retParam.setQName(desc.getReturnQName()); 1746 } 1747 1748 retParam.setTypeQName(desc.getReturnType()); 1749 retParam.setMode(ParameterDesc.OUT); 1750 retParam.setIsReturn(true); 1751 retParam.setJavaType(desc.getReturnClass()); 1752 String returnPartName = writePartToMessage(def, msg, false, retParam); 1753 bodyParts.add(returnPartName); 1754 1755 for (int i = 0; i < parameters.size(); i++) { 1757 ParameterDesc parameter = (ParameterDesc) parameters.get(i); 1758 if (!parameter.isInHeader() && !parameter.isOutHeader()) { 1759 partName = writePartToMessage(def, msg, false, parameter); 1760 bodyParts.add(partName); 1761 } 1762 } 1763 1764 } 1765 if (headers) { 1768 List extensibilityElements = bindop.getBindingOutput().getExtensibilityElements(); 1770 for (int i = 0; i < extensibilityElements.size(); i++) 1771 { 1772 Object ele = extensibilityElements.get(i); 1773 if (ele instanceof SOAPBodyImpl) 1774 { 1775 SOAPBodyImpl soapBody = (SOAPBodyImpl) ele; 1776 soapBody.setParts(bodyParts); 1777 } 1778 } 1779 } 1780 1781 return msg; 1782 } 1783 1784 1793 protected Message writeFaultMessage(Definition def, FaultDesc exception) 1794 throws WSDLException, AxisFault { 1795 1796 String pkgAndClsName = exception.getClassName(); 1797 String clsName = 1798 pkgAndClsName.substring(pkgAndClsName.lastIndexOf('.') + 1, 1799 pkgAndClsName.length()); 1800 1801 exception.setName(clsName); 1803 1804 Message msg = (Message) exceptionMsg.get(pkgAndClsName); 1807 1808 if (msg == null) { 1809 msg = def.createMessage(); 1810 1811 QName qName = createMessageName(def, clsName); 1812 1813 msg.setQName(qName); 1814 msg.setUndefined(false); 1815 1816 ArrayList parameters = exception.getParameters(); 1817 1818 if (parameters != null) { 1819 for (int i = 0; i < parameters.size(); i++) { 1820 ParameterDesc parameter = (ParameterDesc) parameters.get(i); 1821 1822 writePartToMessage(def, msg, true, parameter); 1823 } 1824 } 1825 1826 exceptionMsg.put(pkgAndClsName, msg); 1827 } 1828 1829 return msg; 1830 } 1831 1832 1843 public String writePartToMessage( 1844 Definition def, Message msg, boolean request, ParameterDesc param) 1845 throws WSDLException, AxisFault { 1846 1847 if ((param == null) || (param.getJavaType() == java.lang.Void.TYPE)) { 1849 return null; 1850 } 1851 1852 if (request && (param.getMode() == ParameterDesc.OUT)) { 1855 return null; 1856 } 1857 1858 if (!request && (param.getMode() == ParameterDesc.IN)) { 1859 return null; 1860 } 1861 1862 Part part = def.createPart(); 1864 1865 if (param.getDocumentation() != null) { 1866 part.setDocumentationElement( 1867 createDocumentationElement( 1868 param.getDocumentation())); 1869 } 1870 1871 Class javaType = param.getJavaType(); 1877 1878 if ((param.getMode() != ParameterDesc.IN) 1879 && (param.getIsReturn() == false)) { 1880 javaType = JavaUtils.getHolderValueType(javaType); 1881 } 1882 1883 if ((use == Use.ENCODED) || (style == Style.RPC)) { 1884 1885 QName typeQName = param.getTypeQName(); 1888 1889 if (javaType != null) { 1890 typeQName = types.writeTypeAndSubTypeForPart(javaType, typeQName); 1891 } 1892 1893 if (typeQName != null) { 1895 part.setName(param.getName()); 1896 part.setTypeName(typeQName); 1897 msg.addPart(part); 1898 } 1899 } else if (use == Use.LITERAL) { 1900 1901 QName qname = param.getQName(); 1905 1906 if (param.getTypeQName() == null) { 1907 log.warn(Messages.getMessage("registerTypeMappingFor01", 1908 param.getJavaType().getName())); 1909 QName qName = types.writeTypeForPart(param.getJavaType(),null); 1910 if (qName != null) { 1911 param.setTypeQName(qName); 1912 } else { 1913 param.setTypeQName(Constants.XSD_ANYTYPE); 1914 } 1915 } 1916 1917 if (param.getTypeQName().getNamespaceURI().equals("")) { 1918 param.setTypeQName( 1919 new QName (intfNS, param.getTypeQName().getLocalPart())); 1920 } 1921 1922 if (param.getQName().getNamespaceURI().equals("")) { 1923 qname = new QName (intfNS, param.getQName().getLocalPart()); 1924 1925 param.setQName(qname); 1926 } 1927 1928 ArrayList names = (ArrayList ) 1930 usedElementNames.get(qname.getNamespaceURI()); 1931 if (names == null) { 1932 names = new ArrayList (1); 1933 usedElementNames.put(qname.getNamespaceURI(), names); 1934 } 1935 else if (names.contains(qname.getLocalPart())) { 1936 qname = new QName (qname.getNamespaceURI(), 1937 JavaUtils.getUniqueValue(names, qname.getLocalPart())); 1938 } 1939 names.add(qname.getLocalPart()); 1940 1941 types.writeElementDecl(qname, 1942 param.getJavaType(), 1943 param.getTypeQName(), 1944 false, 1945 param.getItemQName()); 1946 1947 part.setName(param.getName()); 1948 part.setElementName(qname); 1949 msg.addPart(part); 1950 } 1951 1952 return param.getName(); 1954 } 1955 1956 1959 1960 1967 protected QName createMessageName(Definition def, String methodName) { 1968 1969 QName qName = new QName (intfNS, methodName); 1970 1971 int messageNumber = 1; 1973 1974 while (def.getMessage(qName) != null) { 1975 StringBuffer namebuf = new StringBuffer (methodName); 1976 1977 namebuf.append(messageNumber); 1978 1979 qName = new QName (intfNS, namebuf.toString()); 1980 1981 messageNumber++; 1982 } 1983 1984 return qName; 1985 } 1986 1987 1994 protected void prettyDocumentToFile(Document doc, String filename) 1995 throws IOException { 1996 1997 FileOutputStream fos = new FileOutputStream (new File (filename)); 1998 1999 XMLUtils.PrettyDocumentToStream(doc, fos); 2000 fos.close(); 2001 } 2002 2003 2005 2010 public Class getCls() { 2011 return cls; 2012 } 2013 2014 2019 public void setCls(Class cls) { 2020 this.cls = cls; 2021 } 2022 2023 2029 public void setClsSmart(Class cls, String location) { 2030 2031 if ((cls == null) || (location == null)) { 2032 return; 2033 } 2034 2035 if (location.lastIndexOf('/') > 0) { 2037 location = location.substring(location.lastIndexOf('/') + 1); 2038 } else if (location.lastIndexOf('\\') > 0) { 2039 location = location.substring(location.lastIndexOf('\\') + 1); 2040 } 2041 2042 java.lang.reflect.Constructor [] constructors = 2044 cls.getDeclaredConstructors(); 2045 Class intf = null; 2046 2047 for (int i = 0; (i < constructors.length) && (intf == null); i++) { 2048 Class [] parms = constructors[i].getParameterTypes(); 2049 2050 if ((parms.length == 1) && parms[0].isInterface() 2054 && (parms[0].getName() != null) 2055 && Types.getLocalNameFromFullName( 2056 parms[0].getName()).equals(location)) { 2057 intf = parms[0]; 2058 } 2059 } 2060 2061 if (intf != null) { 2062 setCls(intf); 2063 2064 if (implCls == null) { 2065 setImplCls(cls); 2066 } 2067 } else { 2068 setCls(cls); 2069 } 2070 } 2071 2072 2078 public void setCls(String className) throws ClassNotFoundException { 2079 cls = ClassUtils.forName(className); 2080 } 2081 2082 2087 public Class getImplCls() { 2088 return implCls; 2089 } 2090 2091 2096 public void setImplCls(Class implCls) { 2097 this.implCls = implCls; 2098 } 2099 2100 2105 public void setImplCls(String className) { 2106 2107 try { 2108 implCls = ClassUtils.forName(className); 2109 } catch (Exception ex) { 2110 ex.printStackTrace(); 2111 } 2112 } 2113 2114 2119 public String getIntfNamespace() { 2120 return intfNS; 2121 } 2122 2123 2128 public void setIntfNamespace(String ns) { 2129 this.intfNS = ns; 2130 } 2131 2132 2137 public String getImplNamespace() { 2138 return implNS; 2139 } 2140 2141 2146 public void setImplNamespace(String ns) { 2147 this.implNS = ns; 2148 } 2149 2150 2155 public Vector getAllowedMethods() { 2156 return allowedMethods; 2157 } 2158 2159 2164 public void setAllowedMethods(String text) { 2165 2166 if (text != null) { 2167 StringTokenizer tokenizer = new StringTokenizer (text, " ,+"); 2168 2169 if (allowedMethods == null) { 2170 allowedMethods = new Vector (); 2171 } 2172 2173 while (tokenizer.hasMoreTokens()) { 2174 allowedMethods.add(tokenizer.nextToken()); 2175 } 2176 } 2177 } 2178 2179 2184 public void setAllowedMethods(Vector allowedMethods) { 2185 2186 if (this.allowedMethods == null) { 2187 this.allowedMethods = new Vector (); 2188 } 2189 2190 this.allowedMethods.addAll(allowedMethods); 2191 } 2192 2193 2198 public boolean getUseInheritedMethods() { 2199 return useInheritedMethods; 2200 } 2201 2202 2207 public void setUseInheritedMethods(boolean useInheritedMethods) { 2208 this.useInheritedMethods = useInheritedMethods; 2209 } 2210 2211 2216 public void setDisallowedMethods(Vector disallowedMethods) { 2217 2218 if (this.disallowedMethods == null) { 2219 this.disallowedMethods = new Vector (); 2220 } 2221 2222 this.disallowedMethods.addAll(disallowedMethods); 2223 } 2224 2225 2230 public void setDisallowedMethods(String text) { 2231 2232 if (text != null) { 2233 StringTokenizer tokenizer = new StringTokenizer (text, " ,+"); 2234 2235 if (disallowedMethods == null) { 2236 disallowedMethods = new Vector (); 2237 } 2238 2239 disallowedMethods = new Vector (); 2240 2241 while (tokenizer.hasMoreTokens()) { 2242 disallowedMethods.add(tokenizer.nextToken()); 2243 } 2244 } 2245 } 2246 2247 2252 public Vector getDisallowedMethods() { 2253 return disallowedMethods; 2254 } 2255 2256 2262 public void setStopClasses(ArrayList stopClasses) { 2263 2264 if (this.stopClasses == null) { 2265 this.stopClasses = new ArrayList (); 2266 } 2267 2268 this.stopClasses.addAll(stopClasses); 2269 } 2270 2271 2277 public void setStopClasses(String text) { 2278 2279 if (text != null) { 2280 StringTokenizer tokenizer = new StringTokenizer (text, " ,+"); 2281 2282 if (stopClasses == null) { 2283 stopClasses = new ArrayList (); 2284 } 2285 2286 while (tokenizer.hasMoreTokens()) { 2287 stopClasses.add(tokenizer.nextToken()); 2288 } 2289 } 2290 } 2291 2292 2297 public ArrayList getStopClasses() { 2298 return stopClasses; 2299 } 2300 2301 2306 public Map getNamespaceMap() { 2307 return namespaces; 2308 } 2309 2310 2315 public void setNamespaceMap(Map map) { 2316 2317 if (map != null) { 2318 namespaces.putAll(map); 2319 } 2320 } 2321 2322 2327 public String getInputWSDL() { 2328 return inputWSDL; 2329 } 2330 2331 2336 public void setInputWSDL(String inputWSDL) { 2337 this.inputWSDL = inputWSDL; 2338 } 2339 2340 2343 public String getInputSchema() { 2344 return inputSchema; 2345 } 2346 2347 2352 public void setInputSchema(String inputSchema) { 2353 this.inputSchema = inputSchema; 2354 } 2355 2356 2361 public String getLocationUrl() { 2362 return locationUrl; 2363 } 2364 2365 2370 public void setLocationUrl(String locationUrl) { 2371 this.locationUrl = locationUrl; 2372 } 2373 2374 2379 public String getImportUrl() { 2380 return importUrl; 2381 } 2382 2383 2390 public void setImportUrl(String importUrl) { 2391 this.importUrl = importUrl; 2392 } 2393 2394 2399 public String getServicePortName() { 2400 return servicePortName; 2401 } 2402 2403 2408 public void setServicePortName(String servicePortName) { 2409 this.servicePortName = servicePortName; 2410 } 2411 2412 2417 public String getServiceElementName() { 2418 return serviceElementName; 2419 } 2420 2421 2426 public void setServiceElementName(String serviceElementName) { 2427 this.serviceElementName = serviceElementName; 2428 } 2429 2430 2435 public String getPortTypeName() { 2436 return portTypeName; 2437 } 2438 2439 2444 public void setPortTypeName(String portTypeName) { 2445 this.portTypeName = portTypeName; 2446 } 2447 2448 2453 public String getBindingName() { 2454 return bindingName; 2455 } 2456 2457 2462 public void setBindingName(String bindingName) { 2463 this.bindingName = bindingName; 2464 } 2465 2466 2471 public String getTargetService() { 2472 return targetService; 2473 } 2474 2475 2480 public void setTargetService(String targetService) { 2481 this.targetService = targetService; 2482 } 2483 2484 2489 public String getDescription() { 2490 return description; 2491 } 2492 2493 2498 public void setDescription(String description) { 2499 this.description = description; 2500 } 2501 2502 2507 public String getSoapAction() { 2508 return soapAction; 2509 } 2510 2511 2516 public void setSoapAction(String value) { 2517 soapAction = value; 2518 } 2519 2520 2525 public TypeMapping getTypeMapping() { 2526 return tm; 2527 } 2528 2529 2534 public void setTypeMapping(TypeMapping tm) { 2535 this.tm = tm; 2536 } 2537 2538 2543 public TypeMapping getDefaultTypeMapping() { 2544 return (TypeMapping) tmr.getDefaultTypeMapping(); 2545 } 2546 2547 2552 public void setDefaultTypeMapping(TypeMapping tm) { 2553 tmr.registerDefault(tm); 2554 } 2555 2556 2559 public void setTypeMappingRegistry(TypeMappingRegistry tmr) { 2560 this.tmr = tmr; 2561 } 2562 2567 public Style getStyle() { 2568 return style; 2569 } 2570 2571 2582 public void setStyle(String value) { 2583 setStyle(Style.getStyle(value)); 2584 } 2585 2586 2591 public void setStyle(Style value) { 2592 2593 style = value; 2594 2595 if (style.equals(Style.WRAPPED)) { 2596 setUse(Use.LITERAL); 2597 } 2598 } 2599 2600 2605 public Use getUse() { 2606 return use; 2607 } 2608 2609 2619 public void setUse(String value) { 2620 use = Use.getUse(value); 2621 } 2622 2623 2628 public void setUse(Use value) { 2629 use = value; 2630 } 2631 2632 2638 public void setMode(int mode) { 2639 2640 if (mode == MODE_RPC) { 2641 setStyle(Style.RPC); 2642 setUse(Use.ENCODED); 2643 } else if (mode == MODE_DOCUMENT) { 2644 setStyle(Style.DOCUMENT); 2645 setUse(Use.LITERAL); 2646 } else if (mode == MODE_DOC_WRAPPED) { 2647 setStyle(Style.WRAPPED); 2648 setUse(Use.LITERAL); 2649 } 2650 } 2651 2652 2658 public int getMode() { 2659 2660 if (style == Style.RPC) { 2661 return MODE_RPC; 2662 } else if (style == Style.DOCUMENT) { 2663 return MODE_DOCUMENT; 2664 } else if (style == Style.WRAPPED) { 2665 return MODE_DOC_WRAPPED; 2666 } 2667 2668 return -1; 2669 } 2670 2671 2676 public ServiceDesc getServiceDesc() { 2677 return serviceDesc; 2678 } 2679 2680 2685 public void setServiceDesc(ServiceDesc serviceDesc) { 2686 this.serviceDesc = serviceDesc; 2687 } 2688 2689 2694 public Class [] getExtraClasses() { 2695 return extraClasses; 2696 } 2697 2698 2704 public void setExtraClasses(Class [] extraClasses) { 2705 this.extraClasses = extraClasses; 2706 } 2707 2708 2716 public void setExtraClasses(String text) throws ClassNotFoundException { 2717 2718 ArrayList clsList = new ArrayList (); 2719 2720 if (text != null) { 2721 StringTokenizer tokenizer = new StringTokenizer (text, " ,"); 2722 2723 while (tokenizer.hasMoreTokens()) { 2724 String clsName = tokenizer.nextToken(); 2725 2726 Class cls = ClassUtils.forName(clsName); 2728 2729 clsList.add(cls); 2730 } 2731 } 2732 2733 Class [] ec; 2735 2736 if (extraClasses != null) { 2737 ec = new Class [clsList.size() + extraClasses.length]; 2738 2739 for (int i = 0; i < extraClasses.length; i++) { 2741 Class c = extraClasses[i]; 2742 2743 ec[i] = c; 2744 } 2745 } else { 2746 ec = new Class [clsList.size()]; 2747 } 2748 2749 for (int i = 0; i < clsList.size(); i++) { 2751 Class c = (Class ) clsList.get(i); 2752 2753 ec[i] = c; 2754 } 2755 2756 this.extraClasses = ec; 2758 } 2759 2760 public void setEmitAllTypes(boolean emitAllTypes) { 2761 this.emitAllTypes = emitAllTypes; 2762 } 2763 2764 2768 public String getVersionMessage() 2769 { 2770 return versionMessage; 2771 } 2772 2773 2779 public void setVersionMessage(String versionMessage) 2780 { 2781 this.versionMessage = versionMessage; 2782 } 2783 2784 2788 public HashMap getQName2ClassMap() { 2789 return qName2ClassMap; 2790 } 2791} 2792 | Popular Tags |