Axis2 distributes WebService (server and client) I

Posted by mkoga on Mon, 25 Nov 2019 17:52:58 +0100

Although POJO and aar can publish WebService, they are not the most commonly used methods.

The common methods are as follows

Server side

1. Create a web Project (New - > other - > Web - > dynamic web Project)

2. Copy the jar package in axis2-1.7.9\lib to WebContent/WEB-INF/lib /

3. Create services folder under WebContent/WEB-INF / and another folder under services folder. The name of the folder is recommended to be the name of the service (such as city). Create "META-INF" folder under City folder and create services.xml file under META-INF folder.

4. Write services.xml.

5. Modify web.xml under WebContent/WEB-INF / and add axis servlet.

That's about it.

web.xml content

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	version="3.1">
	
	<display-name>myAxis2Pro</display-name>
	

	<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>

</web-app>

services.xml content

<?xml version="1.0" encoding="UTF-8"?>

<service name="city">

	<description>jwt's first axis2 webservice</description>

	<parameter name="ServiceClass">
		com.jwt.svc.city
	</parameter>


	<operation name="desc">
		<messageReceiver
			class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
	</operation>

	<operation name="mark">
		<messageReceiver
			class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
	</operation>

</service>

Architecture of the whole project

Then pass http://localhost:8080/myAxis2Pro/services/city?wsdl Check whether the publication is successful.

Topics: xml JavaEE Apache encoding