Eclipse's Web Tools Platform supports Axis 2.x
1. Download the latest Axis2 runtime from here(http://ws.apache.org/axis2/download.cgi) and extract it.
2. Now we point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Preferences
Select the Axis2 Runtime tab and point to the correct Axis2 runtime location.
3. Creating webservice
a) Create a dynamic web project. (Axis2Server)
b) In project facets,
Set Dynamic Web Module facet to 2.2, 2.3, 2.4 or 2.5.
If unable to change it edit .settings/org.eclipse.wst.common.project.facet.core.xml file
(this file is displayed in Navigator view)
Set Axis2 Web Services facet.
c) Create service resource
d) Select HelloOperation.java, open File -> New -> Other... -> Web Services -> Web Service
Check server, webservice runtime and service project.
click next.
This page is the service.xml selection page. if you have a custom services.xml, you can include that by clicking the Browse button.
For the moment, just leave it at the default.
Test the deployed webservice endpoint.
4. Creating client
Create a dynamic web project and enable axis2 project facet.
Now we'll generate the client for the newly created service by referring the wsdl generated by the Axis2 Server.
Open File -> New -> Other... -> Web Services -> Web ServiceClient.
Check server/webservice runtime and project selected. All the rest i kept default.
Note that after successful client code generation. You will find a stub and callback handler class in client project.
Try the below code in a main function or servlet method.
1. Download the latest Axis2 runtime from here(http://ws.apache.org/axis2/download.cgi) and extract it.
2. Now we point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Preferences
Select the Axis2 Runtime tab and point to the correct Axis2 runtime location.
3. Creating webservice
a) Create a dynamic web project. (Axis2Server)
b) In project facets,
Set Dynamic Web Module facet to 2.2, 2.3, 2.4 or 2.5.
If unable to change it edit .settings/org.eclipse.wst.common.project.facet.core.xml file
Set Axis2 Web Services facet.
c) Create service resource
package com.ws.hello;
import com.ws.bean.InnerBean;
import com.ws.bean.MyBean;
public class HelloOperation {
public String sayHello(String name){
return "Hello "+name;
}
public MyBean sayBean(){
MyBean bean = new MyBean();
InnerBean ibean = new InnerBean();
ibean.setBeanVal("this is bean value");
bean.setIb(ibean);
return bean;
}
}
package com.ws.bean;
public class InnerBean {
private String beanVal;
public String getBeanVal() {
return beanVal;
}
public void setBeanVal(String beanVal) {
this.beanVal = beanVal;
}
}
package com.ws.bean;
public class MyBean {
private InnerBean ib;
public InnerBean getIb() {
return ib;
}
public void setIb(InnerBean ib) {
this.ib = ib;
}
}
d) Select HelloOperation.java, open File -> New -> Other... -> Web Services -> Web Service
Check server, webservice runtime and service project.
click next.
This page is the service.xml selection page. if you have a custom services.xml, you can include that by clicking the Browse button.
For the moment, just leave it at the default.
Test the deployed webservice endpoint.
http://localhost:8085/Axis2Server/axis2-web/index.jsp
http://localhost:8085/Axis2Server/services/HelloOperation?wsdl
4. Creating client
Create a dynamic web project and enable axis2 project facet.
Now we'll generate the client for the newly created service by referring the wsdl generated by the Axis2 Server.
Open File -> New -> Other... -> Web Services -> Web ServiceClient.
Check server/webservice runtime and project selected. All the rest i kept default.
Note that after successful client code generation. You will find a stub and callback handler class in client project.
Try the below code in a main function or servlet method.
HelloOperationStub stub = new HelloOperationStub();
SayHello sayHello = new SayHello();
sayHello.setName("john");
SayHelloResponse response = stub.sayHello(sayHello);
System.out.println(response.get_return());
SayBean temp = new SayBean();
SayBeanResponse response1 = stub.sayBean(temp);
System.out.println(response1.get_return().getIb().getBeanVal());
No comments:
Post a Comment