Java Web Service deployment Method

Source: Internet
Author: User
    • You can deploy a Web Service in either of the following ways:

1. compile the Java source file, change the Java Suffix of the file to JWS, and deploy the file to the webapps/axis directory. The axia engine can directly execute the Java method defined in the source file as web service. In addition, to enable your Web application server to recognize JWS files, make sure that the files are already in the web. configure servlet in XML (if you follow the method described in this article to copy the axis directory as the starting point, skip this step ):

<Servlet>
<Servlet-Name> axisservlet </servlet-Name>
<Display-Name> APACHE-axis servlet </display-Name>
<Servlet-class>
Org. Apache. axis. Transport. http. axisservlet
</Servlet-class>
</Servlet>

<Servlet-mapping>
<Servlet-Name> axisservlet </servlet-Name>
<URL-pattern> *. JWS </url-pattern>
</Servlet-mapping>

<Servlet-mapping>
<Servlet-Name> axisservlet </servlet-Name>
<URL-pattern>/services/* </url-pattern>
</Servlet-mapping>
2. Compile the Web service deployment description file (WSDD ). This method is applicable when you do not have a Java source file or you only need to release some specific methods in the Java class as web service. You can also configure the serialization and deserialization devices in the WSDD file, extends the basic data types defined by soap to enable web services to support complex data types and solve web service interaction problems on heterogeneous platforms. It can be seen that this method is more powerful and controllable than the JWS method.

The specific process can be divided into the following two steps:
1) Deploy the classes and jar files
2) Notify axisengine to load the new service

Step 1:

Place the compiled Java class file under the WEB-INF/classes directory
If JavaCodeCompiled as a jar file, can be placed directly under the WEB-INF/lib
Step 2:

Compile the deploy. WSDD file. You can refer to the example in the samples \ stock directory of the Axis compressed package. The following is a simple example:

<Deployment name = "myservice1" xmlns = "http://xml.apache.org/axis/wsdd"
Xmlns: Java = "http://xml.apache.org/axis/wsdd/providers/java">
<Service name = "myservice1" provider = "Java: RPC">
<Parameter name = "classname" value = "myservice1"/>
<Parameter name = "allowedmethods" value = "*"/>
</Service>
</Deployment>

Deploy. WSDD is used to publish Web Services, and aixs typically saves published services (except those defined in the JWS file) to the global profile WEB-INF/server-config.wsdd

Run Java-CP % axisclasspath % org. Apache. axis. Client. adminclient-lhttp: // localhost: 8080/axis/services/adminservice deploy. WSDD

Define the axisclasspath environment variable, open a new command prompt window, and enter the following command (first define the environment variable before executing the above command ):

Set axis_home = c: \ axis
Set axis_lib = % axis_home % \ Lib
Set axisclasspath = % axis_lib % \ axis. jar; % axis_lib % \ commons-discovery.jar; % axis_lib % \ commons-logging.jar; % axis_lib % \ jaxrpc. jar; % axis_lib % \ SAAJ. jar; % axis_lib % \ log4j-1.2.8.jar; % axis_lib % \ xml-apis.jar; % axis_lib % \ xercesimpl. jar

Trouble Shooting:

1. The above set environment variable command if directly copy the given in this article to your local execution, pay attention to your local file commons-discovery.jar and commons-logging.jar whether there is a version number, if there is, the above command needs to be modified;

2. the XML Parser recommended by axis is xerces. This is also used for environment variables, rather than Java's default crimson parser.May needDownload this component from the xerces site and copy it to WEB-INF/LIB;

3. To run the preceding command, make sure that Tomcat is started. Otherwise, the connection refused error may occur.

4. some jar packages in the lib directory are activation. jar axis. jar commons-discovery.jar commons-logging.jar jaxrpc. jar log4j-1.2.9.jar mail. jar netcomponents. jar portal-client.jar SAAJ. jar wsdl4j. jar xercesimpl. jar xml-apis.jar, a total of 13, you can compare whether you lack, otherwise Java may appear. lang. noclassdeffounderror error.

By the way, you do not need to execute the adminclient tool to deploy the web service. Instead, edit the server-config.wsdd file directly and restart the web server.

    • Cancel a published Web Service:

Write the undeploy. WSDD file. The content is as follows:

<Undeployment Xmlns=Http://xml.apache.org/axis/wsdd">

<Service Name="Myservice1"/>

</Undeployment> 

Run the following command:

JAVA-djava. ext. dirs = lib Org. apache. axis. client. adminclient-lhttp: // localhost: 8080/axis/services/adminservice undeploy. WSDD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.