|
|
<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
How to Embed an Axis2 based Web Service in your Webapp?
Hi I followed the same steps which you expalined.
I used Tomcat 6 and Axis 2(1.5.1).
My war file look like this
MyService.war
WEB-INF
classes
web.xml
services
MyService
META-INF
services.xml
lib
My Web Service name is MyService, and i configured web.xml correctly. when i try to access the wsdl file. It is giving following error. Caused by: org.apache.axis2.deployment.DeploymentException: Invalid service. META-INF directory not found. please help me in this.
Axis2 exposing Marker ADB boolean properties to soap response
Hi ,
I have used Axis2 1.5.1 version and -d adb in wsdl2java to deploy a service. But while testing it
I have found that response soap contains some boolean parameters which were not in generated wsdl.
Actually these boolean fields are coming from axis2 generated adb stubs .
/**
* field for Description
*/
protected java.lang.String localDescription ;
/* This tracker boolean wil be used to detect whether the user called the set method
* for this attribute. It will be used to determine whether to include this field
* in the serialized XML
*/
protected boolean localDescriptionTracker = false ;
I am getting both these "localDescription" & "localDescriptionTracker" in response soap , in place of "description".
Please help.
Siddhartha
Thanks ofr the healthy help,
Thanks ofr the healthy help, jucarii
axis 2 maven aar plugin
I am new to maven. In our project, we have used axis-2 to create webservices using OMElement and POJO based approach. We were using ant build.xml to create the AARs. Now we want to mavenize all those applications.So I spent some time and found that we can use axis 2 aar maven plugin(1.4.1) to create a AAR out of it. I don't know exactly how to use it. Also Do I need to change the package structure altogether before mavenizing the AAR. Does anyone have any sample example for this. Any help will be greatly appreciated. Thanks in advance!
Axis2 based Web Service in your Webapp
Thank you or your information.
car insurance comparison
Problems when I try to add more services
Hi there,
I have followed the instructions to integrate AXIS2 in my web application (TOMCAT + STRUTS + SPRING + HIBERNATE ).
It correctly operates when there is only one service, but if I add another service it seems that only the first deployed service works. If I try to call the second service the server says "The service cannot be found for the endpoint reference (EPR) /sun/servicesAxis2/SAPws".
The application structure is the following:
\---webapp
\---WEB-INF
| web.xml
|
\---services
\---BookService
\---META-INF
services.xml
\---AuthorService
\---META-INF
services.xml
Is there someone that can help me ?
Thanks
Paolo
we create a directory named
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?
Library App
example works, but i 'can't get original wsdl (1.1)
i've been using this approach with a service for over a year and it works great (on Tomcat, WebSphere, and Weblogic) - except that i can't get the original wsdl.
i can reach my app via http://myhostname/myapp/services/myservice
i want to get the original wsdl from http://myhostname/myapp/services/myservice?wsdl
at present, invoking this url in a web browser produces this message:
"Unable to generate WSDL 1.1 for this service. If you wish Axis2 to automatically generate the WSDL 1.1, then please +set useOriginalwsdl as false in your services.xml"
invoking http://myhostname/myapp/services/myservice?wsdl2 succeeds, but i need to return the 1.1 wsdl.
in Tomcat, he original wsdl file is deployed to .../tomcat/webapps/myapp/WEB-INF/services/myapp/myservice/META-INF
i've searched online and found 2 hints:
1) in services.xml, set both "useOriginalwsdl" and "modifyUserWSDLPortAddress" to true.
This doesn't work. When i invoke http://myhostname/myapp/services/myservice?wsdl i get the error mentioned above.
If i set "useOriginalwsdl" to false, i get a wsdl but it doesn't match the original closely enough to be useful for dynamic clients.
2) add a file named "wsdl.list" containing the name of the wsdl file to META-INF.
This makes no difference.
Any ideas most appreciated!
FIXED (was example works, but i 'can't get original wsdl (1.1))
A bit more digging through the Axis2 user list mail archives did the trick:
The value of the "name" attribute of the "service" tag in the wsdl file MUST match the same tag/attribute in the wsdl file.
e.g., both must be <service name="myService">
Same problem here
I've had the same problem and tried all the above but had no result. The only difference is that I was trying to deploy on a Weblogic with the axis servlet...
Eventually I gived up and if needed the WSDL is sent via e-mail :( (Yes, I know: lame!)
I would also much appreciate any ideas or comments on how to make this work...
Thanks.
Deploying .aar with EJB .jar in Glassfish
Hi All!
Thanx for the tutorial, it is really helpful.
However I cannot solve a problem with the help of it. I am new to Axis2 and I want to deploy my webservice in glassfish. My problem is that from my webservice I would like to call an EJB class, so if I uderstood it right, I should deploy my webservice with this jar file somehow (or in it?). The whole application (consists of more war files) is in an ear file.
Could you, please, explain, how I can deploy my .aar in/with a .jar? (I did not find any help on the matter)
Thank you really much in advance!
Regards,
Anna
Technology News
Technology News
Thanks for this, although html language is bit confusing. You explained so well.
Thanks, very powerfull article.
I spent few hours for searching some good articles about Spring + Maven + Webservice, and finally I have founded it here.
Thanks a lot.
What is your solution? I
What is your solution? I still don't have one.
Thanks
- James @ auto insurance quotes
Why Can I not see my custom web service listed from Axis2 Admin
I am using the link for learning:
https://www.wso2.org/library/90
Why can I not see getBooks and findBooks method of my new service (BookService) in the url above?
Ax2
|
---src
|
---samples.demo
|
---Book.java
----BookService.java
WebContent
|
----WEB-INF
|
---lib (has all jars from Axis 2)
|
----services
|
----BookService
|
----META-INF
|
---services.xml
///////////////////
package samples.demo;
public class Book {
private String title;
private String isbn;
private String author;
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
///////////////////
package samples.demo;
public class BookService {
private Book onlyBook;
public BookService() {
onlyBook = new Book();
onlyBook.setAuthor("Dan Diephouse");
onlyBook.setTitle("Using Axis2");
onlyBook.setIsbn("0123456789");
}
public Book[] getBooks() {
return new Book[]{onlyBook};
}
public Book findBook(String isbn) {
if (isbn.equals(onlyBook.getIsbn()))
return onlyBook;
return null;
}
}
////////////////
services.xml
Book sample service
samples.demo.BookService
/////////////////////////
web.xml
<?xml version="1.0" encoding="UTF-8"?>
Axis2WebWs
Apache-Axis Servlet
AxisServlet
org.apache.axis2.transport.http.AxisServlet
1
AxisServlet
/servlet/AxisServlet
AxisServlet
*.jws
AxisServlet
/services/*
/////////////////
I have successfully deployed axis2.war. I can successfully see:
http://localhost:9081/axis2/services/listServices
which only shows getVersion
My question:
Why can I not see getBooks and findBooks method of my new service (BookService) in the url above?
I can successfully see WSDL under:
http://localhost:9081/Ax2/services/BookService?wsdl
Axis 2 service deploy
Hi,
i need a help on how to deploy services as a separate war file.
I am working on web application. i am going to write few services with in this web application.
can i include these service files(class files and service.xml) to the existing web application war file?
I dont want to use axis2/services in the below url.
http://localhost:9081/axis2/services/listServices
I want service url like below.
http://localhost:8080/api_commercialization-1.0.0.0/soap/DocDelivery?WSDL
is it possible to cretae like above?
if possible could you please help me how to achive this..
thanks in advance
Regards,
chinna
Regarding these examples
and many more
I am able to run these examples and get to
http://yourhost:port/axis2/services/BookService?wsdl
but what do I need to do in order to get to:
http://yourhost:port/axis2/services/BookService/getBooks
or
http://yourhost:port/axis2/services/BookService/findBook?isbn="test"
Thanks.
Can you give me some more guidance on this topic?
Hi,
Thanks for this great and useful article.
Recently I need to add a SOAP server service using Axis2 to my web application.
I think the approach mentioned in your article is what I need, but I don't understand it very well.
Would you be so kind to give me some guidance?
My questions are.
1. Are those mentioned in yoru article the only things need to be done to embed Axis2 to my web applicaiton?
2. Since I'm adding a SOAP server serivce, is there anything more I should do?
For example, where to define the SOAPAction etc.?
3. There is a command '$ mvn install war:war' to build the war file.
I'm using Windows XP, can I do the same thing?
I'm a newbie on Axis. I'd really appreciate it if you can elaborate more on this topic.
thansk in advance,
-Tian Chi
Does not work on OC4J either
I am trying to deploy the book.zip on an OC4J (10.1.3.1) container. After building it successfully, I deploy it. The OC4J container says deployment went fine. But when I access the wsdl mentioned above I get the 404- /axis2/services/BookService not found Error. It looks like OC4j is trying to look for a listServices.jsp file and of course it is not there? Why would this happen and I how would I fix it? Any suggestions?
jsp problem
hi
i am getting same error what is solution of this error
Axis2 1.3 compatible with WebSphere 6.0.2.x?
Hello,
Is Axis2 1.3 compatible with WebSphere 6.0.2.x? I found an example, http://wso2.org/library/90 , which works like a champ on Tomcat 5.5 where I can deploy it and hit the wsdl. The problem is trying to hit the wsdl with WebSphere 6.0.2.x, I just get a 404. I have looked at the server logs and it starts fine with no errors. The only suspicious entries in the log are
[3/26/08 16:42:55:934 EDT] 00000021 ApplicationMg A WSVR0200I: Starting application: axis2_war
[3/26/08 16:42:56:293 EDT] 00000021 WebGroup A SRVE0169I: Loading Web Module: axis2.war.
[3/26/08 16:42:57:527 EDT] 00000021 DeploymentEng I org.apache.axis2.deployment.DeploymentEngine prepareRepository no modules directory found , new one created
[3/26/08 16:42:57:871 EDT] 00000021 SystemOut O [JAM] Warning: You are running under a pre-1.5 JDK. JSR175-style source annotations will not be available
[3/26/08 16:42:58:043 EDT] 00000021 ServletWrappe A SRVE0242I: [axis2_war] [/axis2] [AxisServlet]: Initialization successful.
[3/26/08 16:42:58:059 EDT] 00000021 VirtualHost I SRVE0250I: Web Module <null> has been bound to default_host[*:9080,*:80,*:9443].
[3/26/08 16:42:58:074 EDT] 00000021 ApplicationMg A WSVR0221I: Application started: axis2_war
Any help or information would be greatly appreciated
I keep having issues too, no
I keep having issues too, no matter what I try I keep getting errors popping up. I have been trying to get it working for a couple days now... might have to end up hiring some computer whiz to do it pretty soon
Jack, non chexsystems banks
Same problem using WebSphere 5.1
Hi nas7,
I have the exact the same problem, only using the WebSphere 5.1.
Did you find a solution? If so could you reply. I will try the same than.
Any help is welcome from other users.
Kind Regards,
Tuno
Jsp problem
I followed the instructions in this, and I get:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: File "/axis2-web/listSingleService.jsp" not found org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:111) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: File "/axis2-web/listSingleService.jsp" not found org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.axis2.transport.http.AbstractAgent.renderView(AbstractAgent.java:116) org.apache.axis2.transport.http.ListingAgent.processListService(ListingAgent.java:197) org.apache.axis2.transport.http.ListingAgent.handle(ListingAgent.java:89) org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:109) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I also get this when trying with a maven-less build. I understand that the jsps are missing, but why, shouldn't maven have magically included them?
Also, I tried adding them manually to my alternative, non-maven try and that did not seem to help. I saw a reference saying I should simply add the axis2-web folder under my WEB-INF.
Did you ever solved this problem?
Hello!
I just wonder if you ever solved this problem?
If you solved it how did you do it?
Best regards
Fredrik
Rename axis2.war ?
Hi! Great tutorial!
I managed to create the "axis2.war" and it runs perfectly.
But now I want to rename it - say into "book.war". When I do so I can address the wsdl at "http://yourhost:port/book/services/BookService?wsdl".
So far so good- but how can I make Axis to generate in the wsdl the endpoints correctly? These unfortunately stay at:
soap:address location="http://yourhost:port/axis2/services/BookService" .
Many thanks in advance!
Best,
George
Undeploying, hot deploying embedded Axis2 service
What's up with Axis2 classloader? When i undeploy my webapp, the jars stick around, and hence a full undeployment doesn't occur. A redeployment can't occur after that either. I end up recycling the server. Any possible programmatic work around? Am i supposed to do some classloading trick...something was mentioned on Axis2's website about that when running "inside the aar".
Deployment Problem
Hi guys,
when I feed my tomcat (5.5.20) with the successfully build war from the book.zip I get following error:
Jul 27, 2007 1:30:29 PM org.apache.axis2.deployment.ServiceBuilder populateService
SEVERE: Error in schema generating samples.demo.BookService
java.lang.ClassNotFoundException: samples.demo.BookService
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.apache.ws.java2wsdl.SchemaGenerator.(SchemaGenerator.java:70)
at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:209)
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:149)
at org.apache.axis2.deployment.ServiceGroupBuilder.populateServiceGroup(ServiceGroupBuilder.java:91)
at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:84)
at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:145)
at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:620)
at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:195)
at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:207)
at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:155)
at org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:91)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:142)
...
Any ideas?
Cheers,
Dirk
class not found error
the problem is axis can't found the service class BookService, check the ubication of the file
Sotes
This worked for me too.
This worked for me too (Axis2 1.3, Tomcat 5.5.23). 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. The sad part is that there isn't as much following to that project as there is after Axis2. It makes it hard locating other working examples of the basic setup.
How to Embed an Axis2 based
I found the next problem when I access to
http://localhost:5800/axis2/services/BookService
problem: Please enable REST support in WEB-INF/conf/axis2.xml and WEB-INF/web.xml
I don't know what it means, somebody can help me please
Sotes
How to Embed an Axis2 based
Oops!
Still no book.zip
Hi,
I still can't get the example.
I can download the book.zip file from the article but it only contains META-INF/Manifest file.
I tried to download the zip from that other link, but I get a 404 Not Found page. :(
Embedding multiple WS?
I did actually see something
I did actually see something about this somewhere. It made a lot of sense to me then, especiall in relation to a gotomypc promo code limit.
Very helpful, thanks
This is one of the most useful articles I've seen here, not least because of the provision of a Maven2 POM which helps get all the dependencies in place. Also, it's very concise, heavy on example code, and above all it works!
Does not work
I spend the whole day getting this to work, But it did not. Any ideas? DS Downloads
Weblogic 8.1SP4
Your RSS feed doesn't work in
Your RSS feed doesn't work in my browser (google chrome) how can I fix it?
cruise deals
web design company
Dynamic pages adapt their content and/or appearance depending on end-user’s input/interaction or changes in the computing environment user, time, database modifications,web design company
This post actually save me
This post actually save me $50. I was supposed to hire a programmer to do this on my website until I found this tutorial on Google. Thank you sir.