tomcat with AXIS2 publishing WebService site method


Axis2+tomcat7.0realizewebService Server-side publishing and client-side invocation。

There are many ways to develop a webService with Aixs2, so here is only a relatively simple implementation.

Step 1: First download the jar packages needed for development

Download.

axis2-1.6.2-war.zip http://www.apache.org/dist//axis/axis2/Java/core/1.6.2/

After downloading, you willaxis2.war placetomcat in the installation directory of thewebapps folder, Then starttomcat back, (located) atwebapps directory will generateaxis2 file (paper)。 interviewshttp://localhost:8080/axis2/ Can see the following page indicatingaxis2 Running successfully。

second step (located) atMyEclipse new construction underWeb Project, Project Name:elecProject。 new build packagecn.itcast.elec.service, (located) atcn.itcast.elec.service Next new categoryWebSystemDDLServiceImpl。

packagecn.itcast.elec.service.impl;
 
importjava.util.ArrayList;
importjava.util.LinkedHashMap;
importjava.util.List;
importjava.util.Map;
 
importorg.apache.commons.lang.StringUtils;
importorg.springframework.context.ApplicationContext;
importorg.springframework.context.support.ClassPathXmlApplicationContext;
 
importcn.itcast.elec.dao.IElecSystemDDLDao;
importcn.itcast.elec.domain.ElecSystemDDL;
 
publicclassWebSystemDDLServiceImpl{
 
 publicStringfindSystemByKeyword(Stringkeyword){
ApplicationContextac=newClassPathXmlApplicationContext("beans.xml");
IElecSystemDDLDaoelecSystemDDLDao=(IElecSystemDDLDao)ac.getBean(IElecSystemDDLDao.SERVICE_NAME);
 
 // Organizational search criteria
Stringcondition="";
List<Object>paramsList=newArrayList<Object>();
 if(StringUtils.isNotBlank(keyword)){
condition+="ando.keyword=?";
paramsList.add(keyword);
}
Object[]params=paramsList.toArray();
 // Sort statement
Map<String,String>orderby=newLinkedHashMap<String,String>();
orderby.put("o.ddlCode","asc");// Sort by data item number in ascending order
 // When the data dictionary is queried, Enhancing the efficiency of retrieval with second-level caching
List<ElecSystemDDL>list=elecSystemDDLDao.findColectionByConditionNoPageWithCache(condition,params,orderby);
//List<ElecSystemDDL>list=elecSystemDDLDao.findColectionByConditionNoPage(condition,params,orderby);
StringBufferwebObject=newStringBuffer("");//axis2 backingString Types andXML Types of
 if(list!=null&&list.size()>0){
 for(inti=0;i<list.size();i++){
webObject.append(list.get(i).getDdlName()+",");// Values are separated by commas
}
webObject.deleteCharAt(webObject.length()-1);
}
 returnwebObject.toString();
}
}

(located) atWEB-INF Directory Modificationweb.xml documents, It reads as follows.

<?xmlversion="1.0"encoding="UTF-8"?>
<web-appversion="2.5"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--Axis2configstart-->
<servlet>
<servlet-name>AxisServlet</servlet-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>
<!--Axis2end-->
</web-app>

Copy the modules, service and conf files under webapps/axis2/WEB-INF in the tomcat installation directory to the WEB-INF directory under itcastProject. Also copy the following jar package under lib to the project's lib package

The jar packages that are required in order not to conflict with other packages in the project are.

Then, under WEB-INF/services, create a new path systemDDLService/META-INF

A new services.xml is created under META-INF.

It reads as follows.

<?xmlversion="1.0"encoding="UTF-8"?>
<servicename="systemDDLService">
 <description>elecProjectServiceExample</description>
 <parametername="ServiceClass">cn.itcast.elec.service.impl.WebSystemDDLServiceImpl</parameter>
 <operationname="findSystemByKeyword">
 <messageReceiverclass="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
 </operation>
</service>

Visit after starting tomcat:

http://127.0.0.1:8080/elecProject/services/systemDDLService?wsdl I can see the service information now.。 heretoAxis2 ofWebService The service has been successfully released。

Look at the webservice manual and remember to look from the bottom up.

(1)

(2)

(3)

(4)

(5)

Axis2 client calls.

Here's a look at the use ofaxis2 Example of client-side call

The jar packages needed for the client application


Recommended>>
1、NVIDIA partners with GE Healthcare Nuance to inject artificial intelligence into medical imaging 500000 imaging devices to be upgraded
2、A car without a steering wheel GMs fourthgeneration driverless car is here production in 2019
3、The 27th Computer Performance Competition Shanghai Final is successfully completed
4、Solution for nesting two and more ListViews in a ScrollView
5、Charging like this is dangerous and can steal all the information from your phone in minutes

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号