Axis entry (4)

Source: Internet
Author: User

Publish your own Web Services

1) Create your own Java file as follows:
Public class helloservice
? Public String echostring (string name)
? {
?? Return name;
2) Rename the file helloservice. JWS and copy it to the D:/tomcat 5.0/webapps/axis directory.
3) start Tomcat
4) write the client code as follows:
Package com. hongsoft. test;
Import org. Apache. axis. Client. call;
Import org. Apache. axis. Client. Service;

Import javax. xml. namespace. QNAME;

Public class testclient
?? Public static void main (string [] ARGs ){
?????? Try {
?????????? String endpoint = "http: // localhost: 8080/axis/helloservice. JWS ";
?????????? Service? Service = new service ();
?????????? Call ???? Call ??? = (CALL) service. createcall ();

?????????? Call. settargetendpointaddress (New URL (endpoint ));??????????
?????????? Call. setoperationname (New QNAME ("echostring "));
?????????? String ret = (string) Call. Invoke (new object [] {"Hello! "});

?????????? System. Out. println ("sent 'Hello! ', Got' "+ RET + "'");
?????? } Catch (exception e ){
?????????? System. Err. println (E. tostring ());
?????? }
?? }
5) run the client program. The effect is as follows:
? Sent 'Hello! ', Got' hello! '
Axis can automatically locate files, compile, and convert soap calls into Java calls to your services.
6) Isn't it easy? Yes, but don't be too happy. We should pay attention to the following questions:
? JWS Web services are only used for simple web services. We cannot use a package in the service code, and the code is at runtime.

You cannot find any error message during compilation or release. We will discuss other methods for releasing your web services later.

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.