The installation and testing of Apache SOAP Web services in Tomcat4.0.4

Source: Internet
Author: User
Tags error handling soap sin web services tomcat apache tomcat

Related downloads:

Apache SOAP


1. Install Apache SOAP to C packing directory, namely C:\soap-2_3_1

2. Install Tomcat4.0.4 to C:\Program files\apache Tomcat 4.0

3. Copy C:\soap-2_3_1\webapps\soap.war files to C:\Program files\apache Tomcat 4.0\webapps Directory

4. Set up Test catalogue C:\soaptest and C:\soaptest\classes

5. Modify system environment variable classpath, join C:\soaptest\classes\test.jar

6. To start Tomca4.0.4, there are two methods: A. Perform C:\Program Files\apache Tomcat 4.0\bin\;b. Turn on Apache Tomcat4.0.4 through system Managed service management

7. Set up test Java source files, the source files should be placed under the directory C:\soaptest
Package test;
public class Simplemath
Public double Getsinvalue (double input)
DOUBLE ret = Math.sin (input);
return ret;
---The second java source file----------------
Package test;
Import java.util.*;
Import org.apache.soap.util.xml.*;
Import org.apache.soap.*;
Import org.apache.soap.rpc.*;
public class Simplemathclient
public static void Main (string[] args) throws Exception {
System.err.println ("SOAP call testing");
Double value = Math.random ();
Simplemathclient SMC = new Simplemathclient ();
Invoking a remote SOAP service
Double returnvalue = smc.dorequest (value);
System.err.println ("The Sin value of" +value + "is:" +returnvalue);
Public double dorequest (double value) throws Exception {
Build the call.
Call call = new Call ();
Set the URI of the remote object
Call.settargetobjecturi ("Urn:test.math.sin");
Sets the method name of the call
Call.setmethodname ("Getsinvalue");
Set the encoding style
Call.setencodingstyleuri (CONSTANTS.NS_URI_SOAP_ENC);
To set the parameters of a method call
Vector params = new vector ();
Params.addelement (New Parameter ("Input", Double.class, new double (value), null));
Call.setparams (params);
Send RPC Request
Response resp = call.invoke (New URL ("Http://"), "");
if (Resp.generatedfault ()) {//Remote call error handling
Fault Fault = Resp.getfault ();
SYSTEM.OUT.PRINTLN ("The call failed:");
System.out.println ("Fault Code =" + Fault.getfaultcode ());
System.out.println ("Fault String =" + fault.getfaultstring ());
return 0.0d;
else {//call succeeded, get return value
Parameter result = Resp.getreturnvalue ();
Return (Double) Result.getvalue ()). Doublevalue ();

8. Compile Java source files and package
A. CD c:\soaptest
B. javac-d Classes *.java
C. CD classes
D. JAR-CVF Test.jar test

Release of 9.SOAP Services
Use IE browser to browse http://localhost:8080/soap/admin/index.html, enter deploy, fill in the following information:
Methods Getsinvalue
Provider Type:java
Java Provider Provider class:test. Simplemath
Java Provider Static:no
Confirm the release, you can click the list to view the published service!

10. Run test program
A. CD c:\soaptest
B. Java test. Simplemathclien
You should be able to see the values returned, then prove that the configuration and test are successful and you can publish your own SOAP service later!

Reference books: Javaweb Service Application Development detailed

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