Source Code Cross Referenced for GSoapAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » tools » gsoap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.actions.iface.tools.gsoap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.actions.iface.tools.gsoap;
014:
015:        import java.io.File;
016:        import java.util.ArrayList;
017:        import java.util.List;
018:
019:        import com.eviware.soapui.SoapUI;
020:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.AbstractToolsAction;
021:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ArgumentBuilder;
022:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ProcessToolRunner;
023:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolHost;
024:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
025:        import com.eviware.soapui.model.iface.Interface;
026:        import com.eviware.soapui.settings.ToolsSettings;
027:        import com.eviware.soapui.support.Tools;
028:        import com.eviware.soapui.support.UISupport;
029:        import com.eviware.soapui.support.types.StringToStringMap;
030:        import com.eviware.x.form.XForm;
031:        import com.eviware.x.form.XFormDialog;
032:        import com.eviware.x.form.XFormDialogBuilder;
033:        import com.eviware.x.form.XFormFactory;
034:
035:        /**
036:         * Invokes GSoap wsdl2h
037:         * 
038:         * @author Ole.Matzura
039:         */
040:
041:        /*
042:         * http://www.cs.fsu.edu/~engelen/soap.html
043:         * 
044:         * Option 	Description
045:         -a 	generate indexed struct names for local elements with anonymous types
046:         -c 	generate C source code
047:         -d 	use DOM to populate xs:any and xsd:anyType elements
048:         -e 	don't qualify enum names
049:         This option is for backward compatibility with gSOAP 2.4.1 and earlier.
050:         The option does not produce code that conforms to WS-I Basic Profile 1.0a.
051:         -f 	generate flat C++ class hierarchy for schema extensions
052:         -g 	generate global top-level element declarations
053:         -h 	print help information
054:         -I path 	use path to find files
055:         -l 	include license information in output
056:         -m 	use xsd.h module to import primitive types
057:         -n name 	use name as the base namespace prefix name instead of ns
058:         -N name 	use name as the base namespace prefix name for service namespaces
059:         -o file 	output to file
060:         -p 	create polymorphic types with C++ inheritance hierarchy with base xsd__anyType
061:         This is automatically performed when WSDL contains polymorphic definitions
062:         -r host:port 	connect via proxy host and port
063:         -s 	don't generate STL code (no std::string and no std::vector)
064:         -t file 	use type map file instead of the default file typemap.dat
065:         -u 	don't generate unions
066:         -v 	verbose output
067:         -w 	always wrap response parameters in a response struct
068:         -x 	don't generate _XML any/anyAttribute extensibility elements
069:         -y 	generate typedef synonyms for structs and enums
070:         -? 	print help information
071:         */
072:
073:        public class GSoapAction extends AbstractToolsAction<Interface> {
074:            //	private static final String WSDL2H_PATH = "path";
075:            private static final String WSDL2H_OUTPUT = "file";
076:
077:            //WSDL2H settings
078:            private static final String GENERATE_INDEXED_STRUCT = "generate indexed struct names";
079:            private static final String GENERATE_C_SOURCE = "generate C source code";
080:            private static final String DOM = "use DOM";
081:            private static final String DONT_QUALIFY_ENUM_NAMES = "don't qualify enum names";
082:            private static final String FLAT_CPP_CLASS_HIERARCHY = "generate flat C++ class hierarchy";
083:            private static final String GLOBAL_TOP_LEVEL_DECLARATIONS = "generate global top-level declarations";
084:            private static final String PATH = "path to find files";
085:            private static final String INCLUDE_LICENSE_INFORMATION = "include license information";
086:            private static final String USE_XSD_H = "use xsd.h module";
087:            private static final String BASE_NAMESPACE_PREFIX_INSTEAD_OF_NS = "prefixNs";
088:            private static final String BASE_NAMESPACE_PREFIX_FOR_SERVICE_NS = "servicePrefixNs";
089:            private static final String POLYMORPHIC_TYPES = "create polymorphic types";
090:            private static final String PROXY_HOST_PORT = "proxy host:port";
091:            private static final String NO_STL = "don't generate STL code";
092:            private static final String TYPE_MAP_FILE = "use type map file";
093:            private static final String NO_UNIONS = "don't generate unions";
094:            private static final String VERBOSE = "verbose output";
095:            private static final String WRAP_RESPONSE_STRUCT = "wrap response in struct";
096:            private static final String NO_ANY = "don't generate _XML any/anyAttribute";
097:            private static final String TYPEDEF_SYNONYMS = "generate typedef synonyms for structs and enums";
098:
099:            //SOAPCPP2 settings
100:            private static final String SOAP_11 = "generate SOAP 1.1 bindings";
101:            private static final String SOAP_12 = "generate SOAP 1.2 bindings";
102:            private static final String CLIENT_SIDE = "generate client-side code only";
103:            private static final String SERVER_SIDE = "generate server-side code only";
104:            private static final String NO_LIB = "don't generate soapClientLib/soapServerLib";
105:            private static final String SOAP_ACTION = "use value of SOAPAction HTTP header to dispatch method at server side";
106:            private static final String GENERATE_C_SOURCE_CPP = "generate C source code";
107:            //	private static final String SAVE_PATH = "use path to save files";                                                    
108:            private static final String SOAP_RPC = "generate SOAP RPC encoding style bindings";
109:            private static final String SERVICE_PROXIES = "generate service proxies and objects inherited from soap struct";
110:            private static final String IMPORT_PATH = "import path(s)";
111:            private static final String GENERATE_LINKABLE_MODULES = "generate linkable modules (experimental)";
112:            private static final String GENERATE_MATLAB_CODE = "generate Matlab(tm) code for MEX compiler";
113:            private static final String SERVICE_NAME = "use service name to rename service functions and namespace table";
114:            private static final String NAME_PREFIX = "file prefix";
115:            private static final String XSI_TYPED = "generate code for fully xsi:type typed SOAP/XML messaging";
116:            private static final String NO_GEN_WSDL_SCHEMA = "don't generate WSDL and schema files";
117:            private static final String NO_GEN_SAMPLE_XML = "don't generate sample XML message files";
118:
119:            private static final String WSDL2H = "run wsdl2h";
120:            private static final String SOAPCPP2 = "run soapcpp2";
121:            public static final String SOAPUI_ACTION_ID = "GSoapAction";
122:
123:            public GSoapAction() {
124:                super ("GSoap Artifacts",
125:                        "Generates GSoap artifacts using wsdl2h and soap2cpp");
126:            }
127:
128:            protected StringToStringMap initValues(Interface modelItem) {
129:                StringToStringMap values = super .initValues(modelItem);
130:
131:                values.putIfMissing(WSDL2H, Boolean.toString(true));
132:                values.putIfMissing(SOAPCPP2, Boolean.toString(true));
133:                return values;
134:            }
135:
136:            protected XFormDialog buildDialog(Interface modelItem) {
137:                XFormDialogBuilder builder = XFormFactory
138:                        .createDialogBuilder("GSoap Artifacts");
139:
140:                XForm wsdl2hAdvForm = builder.createForm("wsdl2h");
141:
142:                wsdl2hAdvForm.addCheckBox(WSDL2H, null);
143:                addWSDLFields(wsdl2hAdvForm, modelItem);
144:
145:                wsdl2hAdvForm.addTextField(WSDL2H_OUTPUT,
146:                        "name of output file", XForm.FieldType.PROJECT_FILE);
147:
148:                XForm soapcpp2AdvForm = builder.createForm("soapcpp2");
149:
150:                soapcpp2AdvForm.addCheckBox(SOAPCPP2, null);
151:
152:                wsdl2hAdvForm.addCheckBox(GENERATE_INDEXED_STRUCT, null);
153:                wsdl2hAdvForm.addCheckBox(GENERATE_C_SOURCE, null);
154:                wsdl2hAdvForm.addCheckBox(DOM, null);
155:                wsdl2hAdvForm.addCheckBox(DONT_QUALIFY_ENUM_NAMES, null);
156:                wsdl2hAdvForm.addCheckBox(FLAT_CPP_CLASS_HIERARCHY, null);
157:                wsdl2hAdvForm.addCheckBox(GLOBAL_TOP_LEVEL_DECLARATIONS, null);
158:                wsdl2hAdvForm.addTextField(PATH, "use path to find files",
159:                        XForm.FieldType.PROJECT_FOLDER);
160:                wsdl2hAdvForm.addCheckBox(INCLUDE_LICENSE_INFORMATION, null);
161:                wsdl2hAdvForm.addCheckBox(USE_XSD_H, null);
162:                wsdl2hAdvForm
163:                        .addTextField(
164:                                BASE_NAMESPACE_PREFIX_INSTEAD_OF_NS,
165:                                "use name as the base namespace prefix name instead of ns",
166:                                XForm.FieldType.TEXT);
167:                wsdl2hAdvForm
168:                        .addTextField(
169:                                BASE_NAMESPACE_PREFIX_FOR_SERVICE_NS,
170:                                "use name as the base namespace prefix name for service namespaces",
171:                                XForm.FieldType.TEXT);
172:
173:                wsdl2hAdvForm.addCheckBox(POLYMORPHIC_TYPES, null);
174:                wsdl2hAdvForm.addTextField(PROXY_HOST_PORT,
175:                        "connect via proxy host and port (host:port)",
176:                        XForm.FieldType.TEXT);
177:                wsdl2hAdvForm.addCheckBox(NO_STL, null);
178:                wsdl2hAdvForm
179:                        .addTextField(
180:                                TYPE_MAP_FILE,
181:                                "use type map file instead of the default file typemap.dat",
182:                                XForm.FieldType.PROJECT_FILE);
183:                wsdl2hAdvForm.addCheckBox(NO_UNIONS, null);
184:                wsdl2hAdvForm.addCheckBox(VERBOSE, null);
185:                wsdl2hAdvForm.addCheckBox(WRAP_RESPONSE_STRUCT, null);
186:                wsdl2hAdvForm.addCheckBox(NO_ANY, null);
187:                wsdl2hAdvForm.addCheckBox(TYPEDEF_SYNONYMS, null);
188:
189:                soapcpp2AdvForm.addCheckBox(SOAP_11, null);
190:                soapcpp2AdvForm.addCheckBox(SOAP_12, null);
191:                soapcpp2AdvForm.addCheckBox(CLIENT_SIDE, null);
192:                soapcpp2AdvForm.addCheckBox(SERVER_SIDE, null);
193:                soapcpp2AdvForm.addCheckBox(NO_LIB, null);
194:                soapcpp2AdvForm.addCheckBox(SOAP_ACTION, null);
195:                soapcpp2AdvForm.addCheckBox(GENERATE_C_SOURCE_CPP, null);
196:                //soapcpp2AdvForm.addTextField(SAVE_PATH, "", XForm.FieldType.DIRECTORY);
197:                soapcpp2AdvForm.addCheckBox(SOAP_RPC, null);
198:                soapcpp2AdvForm.addCheckBox(SERVICE_PROXIES, null);
199:                soapcpp2AdvForm.addTextField(IMPORT_PATH,
200:                        "use path(s) for #import",
201:                        XForm.FieldType.PROJECT_FOLDER);
202:                soapcpp2AdvForm.addCheckBox(GENERATE_LINKABLE_MODULES, null);
203:                soapcpp2AdvForm.addCheckBox(GENERATE_MATLAB_CODE, null);
204:                soapcpp2AdvForm.addCheckBox(SERVICE_NAME, null);
205:                soapcpp2AdvForm.addTextField(NAME_PREFIX,
206:                        "save files with new prefix name instead of 'soap'",
207:                        XForm.FieldType.TEXT);
208:                soapcpp2AdvForm.addCheckBox(XSI_TYPED, null);
209:                soapcpp2AdvForm.addCheckBox(NO_GEN_WSDL_SCHEMA, null);
210:                soapcpp2AdvForm.addCheckBox(NO_GEN_SAMPLE_XML, null);
211:
212:                return builder.buildDialog(buildDefaultActions(
213:                        HelpUrls.GSOAP_HELP_URL, modelItem),
214:                        "Specify arguments for GSoap wsdl2h and soap2cpp",
215:                        UISupport.TOOL_ICON);
216:            }
217:
218:            protected void generate(StringToStringMap values,
219:                    ToolHost toolHost, Interface modelItem) throws Exception {
220:                String gsoapDir = SoapUI.getSettings().getString(
221:                        ToolsSettings.GSOAP_LOCATION, null);
222:                if (Tools.isEmpty(gsoapDir)) {
223:                    UISupport
224:                            .showErrorMessage("GSoap directory must be set in global preferences");
225:                    return;
226:                }
227:
228:                List<ProcessBuilder> builders = new ArrayList<ProcessBuilder>();
229:
230:                if (values.getBoolean(WSDL2H)) {
231:                    ProcessBuilder wsdl2hBuilder = new ProcessBuilder();
232:                    ArgumentBuilder wsdl2hArgs = buildWsdl2HArgs(modelItem);
233:                    wsdl2hBuilder.command(wsdl2hArgs.getArgs());
234:                    //wsdl2hBuilder.directory(new File(gsoapDir));
235:                    wsdl2hBuilder.directory(new File(Tools.getDir(values
236:                            .get(WSDL2H_OUTPUT))));
237:                    builders.add(wsdl2hBuilder);
238:                }
239:
240:                if (values.getBoolean(SOAPCPP2)) {
241:                    ProcessBuilder soapcpp2Builder = new ProcessBuilder();
242:                    ArgumentBuilder soapcpp2Args = buildSoapcpp2Args();
243:                    soapcpp2Builder.command(soapcpp2Args.getArgs());
244:                    soapcpp2Builder.directory(new File(Tools.getDir(values
245:                            .get(WSDL2H_OUTPUT))));
246:
247:                    builders.add(soapcpp2Builder);
248:                }
249:
250:                if (builders.isEmpty())
251:                    UISupport.showErrorMessage("Nothing to run!");
252:                else
253:                    toolHost.run(new ProcessToolRunner(builders
254:                            .toArray(new ProcessBuilder[builders.size()]),
255:                            "GSoap", modelItem));
256:            }
257:
258:            private ArgumentBuilder buildWsdl2HArgs(Interface modelItem) {
259:                String gsoapDir = SoapUI.getSettings().getString(
260:                        ToolsSettings.GSOAP_LOCATION, null);
261:                StringToStringMap values = dialog.getValues();
262:                ArgumentBuilder builder = new ArgumentBuilder(values);
263:                builder.startScript(gsoapDir + File.separator + "wsdl2h", "",
264:                        "");
265:                builder.addArgs(new String[] { "-v" });
266:
267:                values.put(WSDL2H_OUTPUT, Tools.getFilename(values
268:                        .get(WSDL2H_OUTPUT)));
269:
270:                builder.addString(WSDL2H_OUTPUT, "-o", "");
271:                builder.addArgs(getWsdlUrl(values, modelItem));
272:
273:                builder.addBoolean(GENERATE_INDEXED_STRUCT, "-a");
274:                builder.addBoolean(GENERATE_C_SOURCE, "-c");
275:                builder.addBoolean(DOM, "-c");
276:                builder.addBoolean(DONT_QUALIFY_ENUM_NAMES, "-e");
277:                builder.addBoolean(FLAT_CPP_CLASS_HIERARCHY, "-f");
278:                builder.addBoolean(GLOBAL_TOP_LEVEL_DECLARATIONS, "-g");
279:                builder.addString(PATH, "-I", "");
280:                builder.addBoolean(INCLUDE_LICENSE_INFORMATION, "-l");
281:                builder.addBoolean(USE_XSD_H, "-m");
282:                builder
283:                        .addString(BASE_NAMESPACE_PREFIX_INSTEAD_OF_NS, "-n",
284:                                "");
285:                builder.addString(BASE_NAMESPACE_PREFIX_FOR_SERVICE_NS, "-N",
286:                        "");
287:                builder.addBoolean(POLYMORPHIC_TYPES, "-p");
288:                builder.addString(PROXY_HOST_PORT, "-r", "");
289:                builder.addBoolean(NO_STL, "-s");
290:                builder.addString(TYPE_MAP_FILE, "-t", "");
291:                builder.addBoolean(NO_UNIONS, "-u");
292:                builder.addBoolean(VERBOSE, "-v");
293:                builder.addBoolean(WRAP_RESPONSE_STRUCT, "-w");
294:                builder.addBoolean(NO_ANY, "-x");
295:                builder.addBoolean(TYPEDEF_SYNONYMS, "-y");
296:                return builder;
297:            }
298:
299:            private ArgumentBuilder buildSoapcpp2Args() {
300:                String gsoapDir = SoapUI.getSettings().getString(
301:                        ToolsSettings.GSOAP_LOCATION, null);
302:                StringToStringMap values = dialog.getValues();
303:                ArgumentBuilder builder = new ArgumentBuilder(values);
304:                builder.startScript(gsoapDir + File.separator + "soapcpp2", "",
305:                        "");
306:                builder.addArgs(new String[] { "-Iimport",
307:                        values.get(WSDL2H_OUTPUT) });
308:
309:                builder.addBoolean(SOAP_11, "-1");
310:                builder.addBoolean(SOAP_12, "-2");
311:                builder.addBoolean(CLIENT_SIDE, "-C");
312:                builder.addBoolean(SERVER_SIDE, "-S");
313:                builder.addBoolean(NO_LIB, "-L");
314:                builder.addBoolean(SOAP_ACTION, "-a");
315:                builder.addBoolean(GENERATE_C_SOURCE_CPP, "-c");
316:                builder.addBoolean(SOAP_RPC, "-e");
317:                builder.addBoolean(SERVICE_PROXIES, "-i");
318:                builder.addString(IMPORT_PATH, "-I", "");
319:                builder.addBoolean(GENERATE_LINKABLE_MODULES, "-l");
320:                builder.addBoolean(GENERATE_MATLAB_CODE, "-m");
321:                builder.addBoolean(SERVICE_NAME, "-n");
322:                builder.addString(NAME_PREFIX, "-p", "");
323:                builder.addBoolean(XSI_TYPED, "-t");
324:                builder.addBoolean(NO_GEN_WSDL_SCHEMA, "-w");
325:                builder.addBoolean(NO_GEN_SAMPLE_XML, "-x");
326:
327:                return builder;
328:            }
329:        }
w___w__w_._j___a___v_a__2__s___.__c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.