1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
18
19 import org.apache.axis.wsdl.symbolTable.SymbolTable;
20 import org.apache.axis.wsdl.toJava.Emitter;
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
24 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
25 import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
26 import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
27
28 /***
29 * <p>This genarated the Client side SEI and other classes required in the
30 * Axis.</p>
31 * * <h3>Service Endpoint Interface</h3>
32 * <p>The JAX-RPC specification requires that a JAX-RPC service endpoint interface must
33 * follow the following rules:</p>
34 * <ol>
35 * <li>Service endpoint interface must extend java.rmi.Remote either directly or indirectly</li>
36 * <li>All methods in the interface must throw java.rmi.RemoteException. Methods may
37 * throw service specific exceptions in addition to the RemoteException.</li>
38 * <li>Method parameters and return types must be the JAX-RPC supported Java types
39 * (refer to the section 5.1, ?JAX-RPC Supported Java Types?). At runtime, values of a
40 * supported Java type must be serializable to and from the corresponding XML
41 * representation.
42 * </li>
43 * <li>Holder classes may be used as method parameters. These Holder classes are either
44 * generated or those packaged in the standard javax.xml.rpc.holders package.</li>
45 * <li>Service endpoint interface must not include constant (as public final static)
46 * declarations. WSDL 1.1 specification does not define any standard representation for
47 * constants in a wsdl:portType definition.</li>
48 * </ol>
49 *
50 * @author Srinath Perera(hemapani@opensource.lk)
51 */
52 public class WSDLOnlyClientSideWsGenerator implements Generator {
53 protected static Log log =
54 LogFactory.getLog(ServerSideWsGenerator.class.getName());
55 private J2EEWebServiceContext j2eewscontext;
56 private Ws4J2eeFactory factory;
57
58 private String wsdlfile;
59 private String outputDir;
60 private boolean verbose;
61
62 public WSDLOnlyClientSideWsGenerator(J2EEWebServiceContext j2eewscontext) throws GenerationFault {
63 this.j2eewscontext = j2eewscontext;
64 this.wsdlfile = j2eewscontext.getMiscInfo().getWsdlFile().fileName();
65 this.outputDir = j2eewscontext.getMiscInfo().getOutPutPath();
66 verbose = j2eewscontext.getMiscInfo().isVerbose();
67 factory = j2eewscontext.getFactory();
68 }
69
70 public WSDLOnlyClientSideWsGenerator(String wsdlFile, String outputDir) throws GenerationFault {
71 this.wsdlfile = wsdlFile;
72 this.outputDir = outputDir;
73 }
74
75 public void generate() throws GenerationFault {
76 try {
77 Emitter emitter = new Emitter();
78 if (verbose) {
79 log.info("wsdl file = " + wsdlfile);
80 log.info("calling the WSDL2Java >> ");
81 }
82 emitter.setOutputDir(outputDir);
83 emitter.setServerSide(false);
84 emitter.setVerbose(verbose);
85 emitter.setHelperWanted(true);
86 emitter.setTestCaseWanted(true);
87 emitter.run(wsdlfile);
88 if (j2eewscontext != null) {
89 SymbolTable axisSymboltable = emitter.getSymbolTable();
90 j2eewscontext.setWSDLContext(factory.getContextFactory().createWSDLContext(axisSymboltable));
91 }
92 } catch (Exception e) {
93 e.printStackTrace();
94 throw GenerationFault.createGenerationFault(e);
95 }
96 }
97
98 public static void main(String[] args) throws GenerationFault {
99 if (args.length < 2) {
100 System.out.println("the input should be\n WSDLOnlyClientSideWsGenerator wsdlfile ourputdir");
101 }
102 WSDLOnlyClientSideWsGenerator gen
103 = new WSDLOnlyClientSideWsGenerator(args[0], args[1]);
104 gen.generate();
105 }
106 }