Create a simple Web Service

This code example shows how to create a simple web service. We use the annotation @WebService to declare the class as a such. The annotation @WebMethod is provided at method level to declare it as an operation for the web service. The operation getTime of the JavadbWebService simply returns the current time.

package com.javadb.ws.example;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.jws.WebMethod;
import javax.jws.WebService;

/**
 *
 * @author www.javadb.com 
 */

@WebService()
public class JavadbWebService {
    
    @WebMethod
    public String getTime() {
        
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        return (sdf.format(calendar.getTime()));
        
    }

}
The result of a call to the operation getTime produces something like this: 14:15 This is the SOAP request and response to the web service:

    
    
        
    






    
        
            14:15
        
    



Article from www.javadb.com/create-a-simple-web-service

3 comentários:

Anónimo disse...

Hello,

My name is Isaura , and I work at the iconography department of Yan Imagens, in Sao Paulo, Brazil.

We're now producing for Moderna Publisher a didactic book/material called ''Textual Genres: Animated Videos'', in which the editors would like to use the print-screen of your blog, contained the link bellow:

http://informatictips.blogspot.com.br/

Could you please authorize this use? In case you agree, to whom we should attribute it?

We await to hear from you soon. Please contact us at isaura@yancom.com.br

Best wishes,
Isaura Oliveira

Anónimo disse...

Hello,

My name is Larissa , and I work at the iconography department of Yan Imagens, in Sao Paulo, Brazil.

We're now producing for Moderna Publisher a didactic book/material called ''Textual Genres: Animated Videos'', in which the editors would like to use the print-screen of your blog, contained the link bellow:

http://informatictips.blogspot.com.br/

Could you please authorize this use? In case you agree, to whom we should attribute it?

We await to hear from you soon. Please contact us at larissa@yancom.com.br

Best wishes,
Larissa

Anónimo disse...

Hello,

I would like to know if you received my two last requests regarding to the use of the image available on your website:

http://informatictips.blogspot.com.br/

As informed earlier, I work at the iconography department of Yan Imagens, in Sao Paulo, Brazil, and we're producing for Moderna Publisher a didactic material/book called "Textual genres: animated videos" in which the editors would like to use the image above.

Unfortunatelly, our deadline to insert this image is near the end.

Please let us know in case you cannot help us.

Thanks in advance.

Larissa
http://yancom.com.br

Enviar um comentário