|
|
<web-app>Next, We need a simple web service. Let's pick a Book service with 2 operations findBook and getBooks Snippet from BookService.java:
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
public Book[] getBooks() {
return new Book[]{onlyBook};
}
public Book findBook(String isbn) {
if (isbn.equals(onlyBook.getIsbn()))
return onlyBook;
return null;
}
Next we need a deployment descriptor for the BookService. As you can see, you can deploy a POJO using RPCMessageReceiver and you can specify a namespace for the schema as well as for the web service itself. <serviceGroup>Next, do we really need to create an aar? An aar is useful for hot deployment and service isolation, but this is an embedded scenario, so we go with the "Exploded deployment option" which means that we create a directory structure inside our WEB-INF as follows:
<service name="BookService"
targetNamespace="http://ws.apache.org/axis2/samples/book/">
<description>Book sample service</description>
<schema schemaNamespace="http://ws.apache.org/axis2/samples/book/xsd/"/>
<parameter name="ServiceClass" locked="false">samples.demo.BookService</parameter>
<operation name="getBooks">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
<operation name="findBook">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
</service>
</serviceGroup>
\---WEB-INFUsually we would have dropped a BookService.aar in the services directory, here we create a directory named BookService and drop the deployment descriptor (services.xml) inside the META-INF directory under it. Hmm, did we forget something? Yes, how about an easy build environment using maven2? Here's the layout of our files for maven2.
| web.xml
|
\---services
\---BookService
\---META-INF
services.xml
\---bookAll the jars needed as dependencies are automatically downloaded by maven2 from the Apache and Ibiblio respositories. So you don't even have to download Axis2 dist to build and deploy this sample. All you need to do is unzip the zip below and run
| pom.xml
| README
|
\---src
+---main
| | log4j.properties
| |
| \---samples
| \---demo
| Book.java
| BookService.java
|
+---test
\---webapp
\---WEB-INF
| web.xml
|
\---services
\---BookService
\---META-INF
services.xml
$ mvn install war:warthen rename the resultant war as axis2.war and drop it into any servlet engine. Once your servlet engine starts, you can view the wsdl for your service at:
http://yourhost:port/axis2/services/BookService?wsdl
Enjoy! Please drop an email to axis-dev@ws.apache.org if you run into problems or have comments.
Please download the entire zip here: book.zip
I was struggling with this
web development
had to edit pom.xml for woodstox wstx-asl
Glassfish + Axis2 1.5.1 + WSDL available after undeploy
How to Embed an Axis2 based Web Service in your Webapp?
re
Axis2 exposing Marker ADB boolean properties to soap response
Thanks ofr the healthy help,
axis 2 maven aar plugin
Problems when I try to add more services
we create a directory named
example works, but i 'can't get original wsdl (1.1)
FIXED (was example works, but i 'can't get original wsdl (1.1))
Same problem here
Deploying .aar with EJB .jar in Glassfish
Technology News
Thanks, very powerfull article.
What is your solution? I
Why Can I not see my custom web service listed from Axis2 Admin
Axis 2 service deploy
Regarding these examples
Can you give me some more guidance on this topic?
Does not work on OC4J either
jsp problem
Axis2 1.3 compatible with WebSphere 6.0.2.x?
I keep having issues too, no
Same problem using WebSphere 5.1
Jsp problem
Did you ever solved this problem?
Rename axis2.war ?
ugg boots
Undeploying, hot deploying embedded Axis2 service
Deployment Problem
class not found error
This worked for me too.
How to Embed an Axis2 based
How to Embed an Axis2 based
Oops!
Still no book.zip
Thanks
This worked for me, the jars went to webapp's lib directory. Now it's fully spring loaded. Thanks. I tried a similar excersize with CXF and did not have much luck based on their documentation. You can check my website coupon codes as an example. Thanks!
post reply
Embedding multiple WS?
I did actually see something
Very helpful, thanks
Does not work
Weblogic 8.1SP4
There might be something
Your RSS feed doesn't work in
web design company
This post actually save me