You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Martin Fernau <m....@cps-net.de> on 2010/10/28 18:13:10 UTC

how to embed axis2 using jetty as http-server?

Hello,

I try to find a way to use the axis2 engine with my embedded jetty-server. 
There must be a solution for this - but I can't find a way to get it to work.

I want to add webservices _programmatically_ - I don't want to use aar-Files 
for deploying. What I have so far:

1) I can embed axis2 in my application using SimpleHTTPServer and 
programmaticly add webservices using the ConfigurationContext object. But this 
way I need to use the SimpleHTTPServer which I don't want to.
2) I can use the embedded Jetty-Server and deploying axis2 like this:
--- cut
Server server = new Server(8080);		 
ServletContextHandler context = new
   ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);

AxisServlet axis = new AxisServlet();
ServletHolder sh = new ServletHolder(axis);
sh.setInitParameter("axis2.repository.path", "/some/where/repo");
context.addServlet(sh,"/services/*");
 
server.start();
--- cut
This way axis2 require a repository at "/some/where/repo". There I need to 
have the 'services' directory where I can place my aar-files. Axis will 
recognize the aar-files and add them during runtime. This works but this isn't 
what I want to have.

I need to develop a server for our application which needs to be extensible 
with plugins. These plugins needs to be able to add functionality to the 
server like adding a new servlet (thus I need to use jetty which allows me to 
programmatically add servlets during runtime) and/or adding a new webservice. 
To be as flexible as possible I try to find a way that I don't need to manage 
external aar-Files.

My question is: Is there a way to embed axis2 like I did with example 1 but 
use embedded jetty as http-server like I did in example 2??

Best Regards,
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

Call the service using httpunit or htmlunit.

**
Martin

2010/10/29 Martin Fernau <m....@cps-net.de>:
> Am Donnerstag 28 Oktober 2010 schrieb Martin Makundi:
>> > thanks for your reply. But I think there must be a way to get what we
>> > want. As I pointed out in my first message there is a way to
>> > programmatically control axis if you use the HTTPSimpleServer from axis2
>> > itself. Thus the axis2 engine allows us to control it via code.
>>
>> Well, you can call the deploy method programmatically.. [...]
>
> And how can I do this? I'm not able to find a deploy-method for axis if it's
> embeddid in jetty-server.
>
> For Example. This way I have control over axis programmatically if I use the
> SimpleHTTPServer:
> --- cut
> public class EmbeddedAxis2Server {
>        public static void main(String[] args) throws Exception {
>                ConfigurationContext context = ConfigurationContextFactory
>                        .createConfigurationContextFromFileSystem(null, null);
>                Map<String, MessageReceiver> map =
>                        new HashMap<String, MessageReceiver>();
>                map.put("http://www.w3.org/ns/wsdl/in-only",
>                                RPCInOnlyMessageReceiver.class.newInstance());
>                map.put("http://www.w3.org/ns/wsdl/in-out",
>                                RPCMessageReceiver.class.newInstance());
>                AxisService service =
>                        AxisService.createService(HelloServer.class.getName(),
>                                        context.getAxisConfiguration(),
>                                        map,
>                                        "http://server.helloworld.axis2",
>                                        "http://server.helloworld.axis2",
>                                        ClassLoader.getSystemClassLoader());
>                context.getAxisConfiguration().addService(service);
>                context.setContextRoot("");
>                context.setServicePath("/services/");
>                SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
>                server.start();
>        }
> }
> --- cut
> With the ConfigurationContext I can add further services programmatically.
> This works and I don't need one xml file to get axis2 to work. I'm able to
> invoke this webservice within an axis2 client without problems.
>
> And in my first post you see an example how to embed axis2 in jetty. But this
> way I don't have a ConfigurationContext to control axis2 and programmatically
> add services to axis. So - how can I get the same control over axis if I use
> jetty...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Fernau <m....@cps-net.de>.
Am Donnerstag 28 Oktober 2010 schrieb Martin Makundi:
> > thanks for your reply. But I think there must be a way to get what we
> > want. As I pointed out in my first message there is a way to
> > programmatically control axis if you use the HTTPSimpleServer from axis2
> > itself. Thus the axis2 engine allows us to control it via code.
> 
> Well, you can call the deploy method programmatically.. [...]

And how can I do this? I'm not able to find a deploy-method for axis if it's 
embeddid in jetty-server.

For Example. This way I have control over axis programmatically if I use the 
SimpleHTTPServer:
--- cut
public class EmbeddedAxis2Server {
	public static void main(String[] args) throws Exception {
		ConfigurationContext context = ConfigurationContextFactory
			.createConfigurationContextFromFileSystem(null, null);
		Map<String, MessageReceiver> map = 
			new HashMap<String, MessageReceiver>();
		map.put("http://www.w3.org/ns/wsdl/in-only", 
				RPCInOnlyMessageReceiver.class.newInstance());
		map.put("http://www.w3.org/ns/wsdl/in-out", 
				RPCMessageReceiver.class.newInstance());
		AxisService service = 
			AxisService.createService(HelloServer.class.getName(), 
					context.getAxisConfiguration(), 
					map, 
					"http://server.helloworld.axis2", 
					"http://server.helloworld.axis2", 
					ClassLoader.getSystemClassLoader());
		context.getAxisConfiguration().addService(service);
		context.setContextRoot("");
		context.setServicePath("/services/");
		SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
		server.start();
	}
}
--- cut
With the ConfigurationContext I can add further services programmatically.
This works and I don't need one xml file to get axis2 to work. I'm able to 
invoke this webservice within an axis2 client without problems.

And in my first post you see an example how to embed axis2 in jetty. But this 
way I don't have a ConfigurationContext to control axis2 and programmatically 
add services to axis. So - how can I get the same control over axis if I use 
jetty...

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi Martin!

> thanks for your reply. But I think there must be a way to get what we want. As
> I pointed out in my first message there is a way to programmatically control
> axis if you use the HTTPSimpleServer from axis2 itself. Thus the axis2 engine
> allows us to control it via code.

Well, you can call the deploy method programmatically.. or edit
server-config. programmatically.

> I think there must be a way to get the same type of control if one use jetty
> as the server. I can't believe that it change things so much...

You can maybe invoke the Axis server that is running within jetty.
Instead of java methods configure it using "web methods" (servlet
invocations). Ofcourse debugging source while doing that might reveal
how to do it in java also.

> I really hope that someone can help us...
>
> Regards,
> Martin
>
> Am Donnerstag 28 Oktober 2010 schrieb Martin Makundi:
>> Hi Martin!
>>
>> I have been seeking to do the same. I also use jetty also but have not
>> found a way to deploy PROGRAMMATICALLY.
>>
>> I have found that I always need to configure my services to
>> server-config.wsdd file. Without that it doesn't seem to work, at
>> least with JAX-WS web services.
>>
>> However, if you find a way to do it, let me know ;)
>>
>> http://efreedom.com/Question/1-3545492/Howto-Specify-BeanSerializer-Complex
>> -DataType-Jax-Ws-Using-Axis2
>> http://efreedom.com/Question/1-3479663/Deploy-JAX-WS-Service-Jetty-Axis2-C
>> omplex-Datatypes **
>> Martin
>>
>> 2010/10/28 Martin Fernau <m....@cps-net.de>:
>> > Hello,
>> >
>> > I try to find a way to use the axis2 engine with my embedded
>> > jetty-server. There must be a solution for this - but I can't find a way
>> > to get it to work.
>> >
>> > I want to add webservices _programmatically_ - I don't want to use
>> > aar-Files for deploying. What I have so far:
>> >
>> > 1) I can embed axis2 in my application using SimpleHTTPServer and
>> > programmaticly add webservices using the ConfigurationContext object. But
>> > this way I need to use the SimpleHTTPServer which I don't want to.
>> > 2) I can use the embedded Jetty-Server and deploying axis2 like this:
>> > --- cut
>> > Server server = new Server(8080);
>> > ServletContextHandler context = new
>> >   ServletContextHandler(ServletContextHandler.SESSIONS);
>> > context.setContextPath("/");
>> > server.setHandler(context);
>> >
>> > AxisServlet axis = new AxisServlet();
>> > ServletHolder sh = new ServletHolder(axis);
>> > sh.setInitParameter("axis2.repository.path", "/some/where/repo");
>> > context.addServlet(sh,"/services/*");
>> >
>> > server.start();
>> > --- cut
>> > This way axis2 require a repository at "/some/where/repo". There I need
>> > to have the 'services' directory where I can place my aar-files. Axis
>> > will recognize the aar-files and add them during runtime. This works but
>> > this isn't what I want to have.
>> >
>> > I need to develop a server for our application which needs to be
>> > extensible with plugins. These plugins needs to be able to add
>> > functionality to the server like adding a new servlet (thus I need to
>> > use jetty which allows me to programmatically add servlets during
>> > runtime) and/or adding a new webservice. To be as flexible as possible I
>> > try to find a way that I don't need to manage external aar-Files.
>> >
>> > My question is: Is there a way to embed axis2 like I did with example 1
>> > but use embedded jetty as http-server like I did in example 2??
>> >
>> > Best Regards,
>> > Martin
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
>> > For additional commands, e-mail: java-user-help@axis.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: java-user-help@axis.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Fernau <m....@cps-net.de>.
Hi Martin,

thanks for your reply. But I think there must be a way to get what we want. As 
I pointed out in my first message there is a way to programmatically control 
axis if you use the HTTPSimpleServer from axis2 itself. Thus the axis2 engine 
allows us to control it via code.
I think there must be a way to get the same type of control if one use jetty 
as the server. I can't believe that it change things so much... 
I really hope that someone can help us...

Regards,
Martin

Am Donnerstag 28 Oktober 2010 schrieb Martin Makundi:
> Hi Martin!
> 
> I have been seeking to do the same. I also use jetty also but have not
> found a way to deploy PROGRAMMATICALLY.
> 
> I have found that I always need to configure my services to
> server-config.wsdd file. Without that it doesn't seem to work, at
> least with JAX-WS web services.
> 
> However, if you find a way to do it, let me know ;)
> 
> http://efreedom.com/Question/1-3545492/Howto-Specify-BeanSerializer-Complex
> -DataType-Jax-Ws-Using-Axis2
> http://efreedom.com/Question/1-3479663/Deploy-JAX-WS-Service-Jetty-Axis2-C
> omplex-Datatypes **
> Martin
> 
> 2010/10/28 Martin Fernau <m....@cps-net.de>:
> > Hello,
> > 
> > I try to find a way to use the axis2 engine with my embedded
> > jetty-server. There must be a solution for this - but I can't find a way
> > to get it to work.
> > 
> > I want to add webservices _programmatically_ - I don't want to use
> > aar-Files for deploying. What I have so far:
> > 
> > 1) I can embed axis2 in my application using SimpleHTTPServer and
> > programmaticly add webservices using the ConfigurationContext object. But
> > this way I need to use the SimpleHTTPServer which I don't want to.
> > 2) I can use the embedded Jetty-Server and deploying axis2 like this:
> > --- cut
> > Server server = new Server(8080);
> > ServletContextHandler context = new
> >   ServletContextHandler(ServletContextHandler.SESSIONS);
> > context.setContextPath("/");
> > server.setHandler(context);
> > 
> > AxisServlet axis = new AxisServlet();
> > ServletHolder sh = new ServletHolder(axis);
> > sh.setInitParameter("axis2.repository.path", "/some/where/repo");
> > context.addServlet(sh,"/services/*");
> > 
> > server.start();
> > --- cut
> > This way axis2 require a repository at "/some/where/repo". There I need
> > to have the 'services' directory where I can place my aar-files. Axis
> > will recognize the aar-files and add them during runtime. This works but
> > this isn't what I want to have.
> > 
> > I need to develop a server for our application which needs to be
> > extensible with plugins. These plugins needs to be able to add
> > functionality to the server like adding a new servlet (thus I need to
> > use jetty which allows me to programmatically add servlets during
> > runtime) and/or adding a new webservice. To be as flexible as possible I
> > try to find a way that I don't need to manage external aar-Files.
> > 
> > My question is: Is there a way to embed axis2 like I did with example 1
> > but use embedded jetty as http-server like I did in example 2??
> > 
> > Best Regards,
> > Martin
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> > For additional commands, e-mail: java-user-help@axis.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
BTW: This might be useful for the basic use case, web.xml:

    <listener>
      <listener-class>
        org.apache.axis.transport.http.AxisHTTPSessionListener
      </listener-class>
    </listener>

    <servlet>
        <servlet-name>quickstart</servlet-name>
        <!--
        <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
        -->
        <servlet-class>wicket.quickstart.TakpServlet</servlet-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>wicket.quickstart.TakpApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
      <servlet-name>AxisServlet</servlet-name>
      <display-name>Apache-Axis Servlet</display-name>
      <servlet-class>
        org.apache.axis.transport.http.AxisServlet
      </servlet-class>
    </servlet>
    <servlet>
      <servlet-name>AdminServlet</servlet-name>
      <display-name>Apache-Axis AdminServlet</display-name>
      <servlet-class>
        org.apache.axis.transport.http.AdminServlet
      </servlet-class>
      <load-on-startup>100</load-on-startup>
    </servlet>

    <servlet-mapping>
    	<servlet-name>quickstart</servlet-name>
    	<url-pattern>/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    	<servlet-name>AxisServlet</servlet-name>
    	<url-pattern>/servlet/AxisServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    	<servlet-name>AxisServlet</servlet-name>
    	<url-pattern>/axis/services/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    	<servlet-name>AdminServlet</servlet-name>
    	<url-pattern>/servlet/AdminServlet</url-pattern>
    </servlet-mapping>

    <mime-mapping>
    	<extension>wsdl</extension>
    	<mime-type>text/xml</mime-type>
    </mime-mapping>
    <mime-mapping>
    	<extension>xsd</extension>
    	<mime-type>text/xml</mime-type>
    </mime-mapping>


2010/10/28 Martin Makundi <ma...@koodaripalvelut.com>:
> Hi Martin!
>
> I have been seeking to do the same. I also use jetty also but have not
> found a way to deploy PROGRAMMATICALLY.
>
> I have found that I always need to configure my services to
> server-config.wsdd file. Without that it doesn't seem to work, at
> least with JAX-WS web services.
>
> However, if you find a way to do it, let me know ;)
>
> http://efreedom.com/Question/1-3545492/Howto-Specify-BeanSerializer-Complex-DataType-Jax-Ws-Using-Axis2
> http://efreedom.com/Question/1-3479663/Deploy-JAX-WS-Service-Jetty-Axis2-Complex-Datatypes
> **
> Martin
>
>
> 2010/10/28 Martin Fernau <m....@cps-net.de>:
>> Hello,
>>
>> I try to find a way to use the axis2 engine with my embedded jetty-server.
>> There must be a solution for this - but I can't find a way to get it to work.
>>
>> I want to add webservices _programmatically_ - I don't want to use aar-Files
>> for deploying. What I have so far:
>>
>> 1) I can embed axis2 in my application using SimpleHTTPServer and
>> programmaticly add webservices using the ConfigurationContext object. But this
>> way I need to use the SimpleHTTPServer which I don't want to.
>> 2) I can use the embedded Jetty-Server and deploying axis2 like this:
>> --- cut
>> Server server = new Server(8080);
>> ServletContextHandler context = new
>>   ServletContextHandler(ServletContextHandler.SESSIONS);
>> context.setContextPath("/");
>> server.setHandler(context);
>>
>> AxisServlet axis = new AxisServlet();
>> ServletHolder sh = new ServletHolder(axis);
>> sh.setInitParameter("axis2.repository.path", "/some/where/repo");
>> context.addServlet(sh,"/services/*");
>>
>> server.start();
>> --- cut
>> This way axis2 require a repository at "/some/where/repo". There I need to
>> have the 'services' directory where I can place my aar-files. Axis will
>> recognize the aar-files and add them during runtime. This works but this isn't
>> what I want to have.
>>
>> I need to develop a server for our application which needs to be extensible
>> with plugins. These plugins needs to be able to add functionality to the
>> server like adding a new servlet (thus I need to use jetty which allows me to
>> programmatically add servlets during runtime) and/or adding a new webservice.
>> To be as flexible as possible I try to find a way that I don't need to manage
>> external aar-Files.
>>
>> My question is: Is there a way to embed axis2 like I did with example 1 but
>> use embedded jetty as http-server like I did in example 2??
>>
>> Best Regards,
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: java-user-help@axis.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: how to embed axis2 using jetty as http-server?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi Martin!

I have been seeking to do the same. I also use jetty also but have not
found a way to deploy PROGRAMMATICALLY.

I have found that I always need to configure my services to
server-config.wsdd file. Without that it doesn't seem to work, at
least with JAX-WS web services.

However, if you find a way to do it, let me know ;)

http://efreedom.com/Question/1-3545492/Howto-Specify-BeanSerializer-Complex-DataType-Jax-Ws-Using-Axis2
http://efreedom.com/Question/1-3479663/Deploy-JAX-WS-Service-Jetty-Axis2-Complex-Datatypes
**
Martin


2010/10/28 Martin Fernau <m....@cps-net.de>:
> Hello,
>
> I try to find a way to use the axis2 engine with my embedded jetty-server.
> There must be a solution for this - but I can't find a way to get it to work.
>
> I want to add webservices _programmatically_ - I don't want to use aar-Files
> for deploying. What I have so far:
>
> 1) I can embed axis2 in my application using SimpleHTTPServer and
> programmaticly add webservices using the ConfigurationContext object. But this
> way I need to use the SimpleHTTPServer which I don't want to.
> 2) I can use the embedded Jetty-Server and deploying axis2 like this:
> --- cut
> Server server = new Server(8080);
> ServletContextHandler context = new
>   ServletContextHandler(ServletContextHandler.SESSIONS);
> context.setContextPath("/");
> server.setHandler(context);
>
> AxisServlet axis = new AxisServlet();
> ServletHolder sh = new ServletHolder(axis);
> sh.setInitParameter("axis2.repository.path", "/some/where/repo");
> context.addServlet(sh,"/services/*");
>
> server.start();
> --- cut
> This way axis2 require a repository at "/some/where/repo". There I need to
> have the 'services' directory where I can place my aar-files. Axis will
> recognize the aar-files and add them during runtime. This works but this isn't
> what I want to have.
>
> I need to develop a server for our application which needs to be extensible
> with plugins. These plugins needs to be able to add functionality to the
> server like adding a new servlet (thus I need to use jetty which allows me to
> programmatically add servlets during runtime) and/or adding a new webservice.
> To be as flexible as possible I try to find a way that I don't need to manage
> external aar-Files.
>
> My question is: Is there a way to embed axis2 like I did with example 1 but
> use embedded jetty as http-server like I did in example 2??
>
> Best Regards,
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org