9 import java.util.Iterator;
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.apache.axis2.util.LoggingControl;
17 import org.apache.axis2.AxisFault;
18 import org.apache.axis2.Constants;
19 import org.apache.axis2.context.ConfigurationContext;
20 import org.apache.axis2.context.ConfigurationContextFactory;
21 import org.apache.axis2.engine.ListenerManager;
22 import org.apache.axis2.transport.TransportListener;
23 import org.apache.axis2.description.TransportInDescription;
25 import org.apache.axis2.engine.AxisConfigurator;
26 import org.apache.axis2.deployment.FileSystemConfigurator;
27 import org.apache.axis2.engine.AxisConfiguration;
28 import org.apache.axis2.engine.AxisServer;
29 import org.apache.axis2.description.AxisService;
30 import org.apache.axis2.description.Parameter;
31 import org.apache.axis2.engine.MessageReceiver;
32 import org.apache.axis2.AxisFault;
33 import org.apache.axis2.transport.http.SimpleHTTPServer;
34 import org.apache.axis2.description.java2wsdl.SchemaGenerator;
35 import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
37 import org.apache.axis2.deployment.util.Utils;
47 public void start() throws AxisFault {
49 ConfigurationContext cctx = getConfigurationContext();
51 ListenerManager listenerManager = cctx.getListenerManager();
52 TransportInDescription trsIn =
53 new TransportInDescription(Constants.TRANSPORT_HTTP);
54 trsIn.setReceiver(
this);
55 if (listenerManager == null) {
56 listenerManager =
new ListenerManager();
57 listenerManager.init(cctx);
59 listenerManager.addListener(trsIn,
true);
61 Iterator<String> iter = cctx.getAxisConfiguration().
62 getTransportsIn().keySet().iterator();
63 while (iter.hasNext()) {
64 String trp = iter.next();
65 if (!Constants.TRANSPORT_HTTP.equals(trp)) {
66 trsIn = (TransportInDescription)
67 cctx.getAxisConfiguration().getTransportsIn().get(trp);
68 listenerManager.addListener(trsIn,
false);
72 catch (Exception ex) {
73 log.error(ex.getMessage(),ex);
74 throw AxisFault.makeFault(ex);
79 throws Exception,ClassNotFoundException,InstantiationException,
80 IllegalAccessException,AxisFault {
85 throws Exception,ClassNotFoundException,AxisFault {
86 String resourcePath = ss.getSchemaResourcePath();
87 Class implClass = ss.getClass();
88 String implClassName = implClass.getCanonicalName();
89 int index = implClassName.lastIndexOf(
".");
90 String serviceName = ss.getServiceName();
91 if (serviceName == null) {
94 implClassName.substring(index + 1,implClassName.length());
96 serviceName = implClassName;
100 SchemaGenerator sg = null;
101 AxisService as = null;
102 if (resourcePath != null) {
103 AxisConfiguration ac =
104 getConfigurationContext().getAxisConfiguration();
105 as =
new AxisService();
107 as.setName(serviceName);
111 if (java.lang.Thread.currentThread().getContextClassLoader() != null) {
113 java.lang.Thread.currentThread().getContextClassLoader();
114 rurl = cl.getResource(resourcePath);
116 else if (implClass != null) {
117 rurl = implClass.getResource(resourcePath);
120 rurl = implClass.getClassLoader().getResource(resourcePath);
126 ss.getSchemaNamespace(),
127 ss.getSchemaNamespacePrefix(),
128 ss.getMethodClassNameMapping(),
129 ss.getDynamicTypeMapping(),
130 ss.getStaticTypeMapping(),
132 sg.setElementFormDefault(Java2WSDLConstants.FORM_DEFAULT_UNQUALIFIED);
135 return buildService(ss.getClass().getCanonicalName(),serviceName,
137 ss.getMessageReceiverClassMap(),
138 ss.getTargetNamespace(),ss.getSchemaNamespace(),sg,as);
142 Map<String,MessageReceiver> msgReceiverClassMap,
143 String targetNamespace,String schemaNamespace,
144 SchemaGenerator sg,AxisService as)
145 throws Exception,ClassNotFoundException,AxisFault {
146 AxisConfiguration ac = getConfigurationContext().getAxisConfiguration();
149 as = AxisService.createService(implClass,serviceName,
150 ac,msgReceiverClassMap,targetNamespace,
151 this.getClass().getClassLoader(),
155 as = AxisService.createService(implClass,ac,msgReceiverClassMap,
156 targetNamespace,schemaNamespace,
157 this.getClass().getClassLoader());
169 public static void main(String[] args) {
171 ConfigurationContext cctx;
175 ac =
new FileSystemConfigurator(null,null);
180 cctx = ConfigurationContextFactory.createConfigurationContext(ac);
198 ss.getConfigurationContext().setServicePath(
"vmi/1");
199 ss.getConfigurationContext().setContextRoot(
"/");
201 for (
int i = 0;
i < args.length; ++
i) {
206 System.out.println(
"Started HTTP server on port "
207 + ss.getHttpFactory().getPort());
209 catch (Throwable
t) {
210 System.err.println(
"Could not start server:");
AxisService buildService(String implClass, String serviceName, Map< String, MessageReceiver > msgReceiverClassMap, String targetNamespace, String schemaNamespace, SchemaGenerator sg, AxisService as)
static uint64_t unsigned int i
AxisService buildService(String className)
SimpleServiceServer(ConfigurationContext cctx, int port)
static void main(String[] args)
AxisService buildService(SimpleService ss)