Use of WebService-axis1

Source: Internet
Author: User
Tags server memory

1. Setting up an axis server

1.1 Download the Axis-bin-1_4.zip file and unzip it

1.2 Copy the WebApps directory under axis to tomcat directory under the \axis-1_4\webapps directory and start

1.3 Enter http://localhost:8080/axis/in the browser if you can get to the Axis home page, it means a successful build.

    

2. Publish your own app to axis server (instant release and custom release)

2.1 Instant release (only available in a single Java file with no packages and jar packages and requires source code) (JWS)

Release steps:

1) Write a single Java file

public class Hellows {public    string Hello (string a,string b) {        return ' response by server ' +a + ', ' +b    }}

2) Copy the Hellows.java to the Webapps/axis directory under Tomcat and rename the Hellows.jws to restart Tomcat

        

3) Enter HTTP://LOCALHOST:8080/AXIS/HELLOWS.JWS in the browser to see the following interface indicates a successful release

        

4) Click to see the WSDL if the following error is reported, modify the JDK version to 1.6 (I test, does not support 1.8)

        

2.2 Custom Release (WSDD)

2.2.1 A class file with a package structure for publishing

1) write Java code and compile it as a class file

Package com.beifeng.hadoop.webservice.server;
public class HELLOWSDD { private int counter=0; public string Hello (string name) { counter++; System.out.println ("Number of Visits:" +counter); Return "Welcome to Axis server:" +name; } Public float Add (float a,float b) { counter++; System.out.println ("Number of Visits:" +counter); return a+b;} }

2) Copy the compiled class file and package structure to the Tomcat\webapps\axis\web-inf\classes directory

        

3) Add the service to be published in the AXIS\WEB-INF\SERVER-CONFIG.WSDD file, if there is no copy of the file elsewhere

<!--The name of the service to be published--
<Servicename= "HELLOWSDD"provider= "Java:rpc">
<!--class name <parametername= "ClassName"value= "Com.beifeng.hadoop.webservice.server.HelloWSDD" />
<! --the method to publish--<parametername= "Allowedmethods"value= "Hello,add" />
<parameter name= "Scope" value= "Application"/> </Service>

Value of parameter scope: Requet, session, or application

Request:axis generates a service object for each SOAP request (default) for the request

Session:axis generates an object for each client that calls webservice, for the session

Application: Creates an object directly in server memory and returns each request directly

4) Restart Tomcat, enter http://location:8080 in the browser, click List to see the following page

      

3. Client Calls

3.1 Calling JWs Hellows.jws's Hello method for immediate release

Service address string url= "Http://localhost:8080/axis/HelloWS.jws";        Build the Web Service Services Service service=new service ();        Create a call Service.createcall () calling call= ();         Sets the address of the call call.settargetendpointaddress (URL);        Set the method to invoke Call.setoperationname (new QName (URL, "Hello"));        Execute the call and pass the argument String result= (String) call.invoke (new object[]{"Teacher", "student"});        Results returned: Response by Server teacher,studentsystem.out.println (result);

  

Use of WebService-axis1

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.