1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
package org.apache.geronimo.ews.ws4j2ee.toWs;
|
18
|
|
|
19
|
|
import org.apache.commons.logging.Log;
|
20
|
|
import org.apache.commons.logging.LogFactory;
|
21
|
|
import org.apache.geronimo.ews.ws4j2ee.context.ContextValidator;
|
22
|
|
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
23
|
|
import org.apache.geronimo.ews.ws4j2ee.context.MiscInfo;
|
24
|
|
import org.apache.geronimo.ews.ws4j2ee.context.webservices.client.interfaces.ServiceReferanceContext;
|
25
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.impl.Ws4J2eeFactoryImpl;
|
26
|
|
import org.apache.geronimo.ews.ws4j2ee.utils.MiscFactory;
|
27
|
|
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
28
|
|
|
29
|
|
import java.io.FileInputStream;
|
30
|
|
import java.util.HashMap;
|
31
|
|
|
32
|
|
|
33
|
|
|
34
|
|
|
35
|
|
public class Ws4J2EEClientwithWSDL implements Generator {
|
36
|
|
private String wsConfFileLocation;
|
37
|
|
private boolean verbose = false;
|
38
|
|
private Ws4J2eeCLOptionParser clparser;
|
39
|
|
private Ws4J2eeFactory factory;
|
40
|
|
protected static Log log =
|
41
|
|
LogFactory.getLog(Ws4J2EEClientwithWSDL.class.getName());
|
42
|
|
|
43
|
|
private MiscInfo misc;
|
44
|
|
|
45
|
4
|
public Ws4J2EEClientwithWSDL(String[] args) throws Exception {
|
46
|
4
|
clparser = new Ws4J2eeCLOptionParser(args);
|
47
|
|
}
|
48
|
|
|
49
|
|
|
50
|
|
|
51
|
|
|
52
|
|
|
53
|
|
|
54
|
4
|
public void generate() throws GenerationFault {
|
55
|
4
|
try {
|
56
|
4
|
factory = new Ws4J2eeFactoryImpl();
|
57
|
4
|
J2EEWebServiceContext wscontext = factory.getContextFactory().getJ2EEWsContext(true);
|
58
|
4
|
wscontext.setFactory(factory);
|
59
|
|
|
60
|
4
|
misc = factory.getContextFactory().createMiscInfo(new HashMap());
|
61
|
4
|
wscontext.setMiscInfo(misc);
|
62
|
4
|
String wscfClientfile = clparser.getWscffile();
|
63
|
4
|
misc.setWsconffile(MiscFactory.getInputFile(wscfClientfile));
|
64
|
4
|
misc.setOutputPath(clparser.getOutputDirectory());
|
65
|
4
|
wsConfFileLocation = Utils.getRootDirOfFile(wscfClientfile);
|
66
|
4
|
wscontext.getMiscInfo().setImplStyle(clparser.getImplStyle());
|
67
|
4
|
wscontext.getMiscInfo().setTargetJ2EEContainer(clparser.getContanier());
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
4
|
ServiceReferanceContext serviceContext =
|
72
|
|
factory.getParserFactory().parseServiceReferance(wscontext,
|
73
|
|
new FileInputStream(wscfClientfile));
|
74
|
4
|
if (verbose) {
|
75
|
0
|
log.info(wscfClientfile + " parsed ..");
|
76
|
0
|
log.info(serviceContext.getJaxrpcmappingFile());
|
77
|
0
|
log.info(serviceContext.getWsdlFile());
|
78
|
|
}
|
79
|
4
|
wscontext.getMiscInfo().setJaxrpcfile(MiscFactory.getInputFile(Utils.getAbsolutePath(serviceContext.getJaxrpcmappingFile(),
|
80
|
|
wsConfFileLocation)));
|
81
|
4
|
wscontext.getMiscInfo().setWsdlFile(MiscFactory.getInputFile(Utils.getAbsolutePath(serviceContext.getWsdlFile(),
|
82
|
|
wsConfFileLocation)));
|
83
|
4
|
wscontext.getMiscInfo().setVerbose(verbose);
|
84
|
4
|
wscontext.getMiscInfo().setHandlers(serviceContext.getHandlers());
|
85
|
|
|
86
|
|
|
87
|
4
|
if (verbose)
|
88
|
0
|
log.info("starting client side code genaration .. ");
|
89
|
4
|
Generator clientStubGen = factory.getGenerationFactory().createClientSideWsGenerator(wscontext);
|
90
|
4
|
clientStubGen.generate();
|
91
|
4
|
ContextValidator cvalidator = new ContextValidator(wscontext);
|
92
|
|
|
93
|
4
|
Generator handlerGen = factory.getGenerationFactory().createHandlerGenerator(wscontext);
|
94
|
4
|
handlerGen.generate();
|
95
|
|
} catch (Exception e) {
|
96
|
0
|
e.printStackTrace();
|
97
|
0
|
throw GenerationFault.createGenerationFault(e);
|
98
|
|
}
|
99
|
|
}
|
100
|
|
|
101
|
4
|
public static void main(String[] args) throws Exception {
|
102
|
4
|
Ws4J2EEClientwithWSDL gen = new Ws4J2EEClientwithWSDL(args);
|
103
|
4
|
gen.generate();
|
104
|
|
}
|
105
|
|
}
|
106
|
|
|