Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Monday, May 12, 2014

Creating a SOAP Web Service


1. Create the Java class with methods you want to be converted as web service
2. Add a WebService annotation to the class
3. Add WebMethod annotation to the web service method. This is optional. All public methods of the web service class are automatically considered a web service method.

Example:
@WebService
public class BookStore{
@WebMethod
 public List<String> getBookNames() {
 }
}
This will create a web service class called BookStoreService.

Wednesday, May 7, 2014

Consuming a Web Service

What you need:
- wsdl source

1. Use wsimport tool from java se. In command line enter:
wsimport -keep -s , e.g. wsimport -keep -s src
-keep - keep generated files (.java files)

2. Import the the java files in your project and use them as stubs to call the webservice method(s). The name of the stub you can use can be found in the wsdl:service tag of the wsdl.
Ex.
 name="CurrencyConvertor">

CurrencyConvertor cc = new CurrencyConvertor();
CurrencyConvertorSoap ccs = cc.getCurrencyConvertorSoap();




Monday, January 5, 2009

Understanding Web Service

Web Service

- a software system designed to support interoperable machine-to-machine interaction over a network.
- makes software functionality available over the Internet so that programs like PHP, ASP, JSP, JavaBeans, the COM object, and all our other favorite widgets can make a request to a program running on another server (a web service) and use that program’s response in a website, WAP service, or other application.
- describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone.

2 Types of Web Service

  1. SOAP (Simple Object Access Protocol)
    - a lightweight XML-based messaging protocol used to encode the information in Web service request and response messages before sending them over a network.
    - SOAP messages are formatted in XML and are typically sent using HTTP but can be also transported using a variety of Internet protocols, including SMTP and MIME.
    - older type, successor of XML-RPC
    - uses JAX-WS specification
  2. REST
    - is simpler and more light weighted than SOAP
    - can send and receive data as JSON, XML or even plain text
    - uses JAX-RS specification

Related Terms


XML (Extensible Markup Language)
- a general-purpose specification for creating custom markup languages developed by the W3C.
- is a markup language much like HTML. A markup language is a mechanism to identify structures in a document.
- allows designers to create their own customized tags, enabling the definition, transmission, validation, and interpretation of data between applications and between organizations.

WSDL (Web Services Description Language)
- an XML-formatted language used to describe a Web service's capabilities as collections of communication endpoints capable of exchanging messages. WSDL is the language that UDDI uses, developed jointly by Microsoft and IBM.
- describes the interface of Web services

UDDI (Universal Description, Discovery and Integration)
- it is a Web-based distributed directory that enables businesses to list themselves on the Internet and discover each other, similar to a traditional phone book's yellow and white pages.

SEI (Service Endpoint Interface)
- is a Java interface class that defines the methods to be exposed as a Web service
- coverts the web service call including the (Java, C++, etc.) objects to a SOAP message

Protocol
- is a convention or standard that controls or enables the connection, communication, and data transfer between two computing endpoints. In its simplest form, a protocol can be defined as the rules governing the syntax, semantics, and synchronization of communication. Protocols may be implemented by hardware, software, or a combination of the two.

References:
http://www.alistapart.com/articles/webservices
http://en.wikipedia.org
http://www.webopedia.com/TERM/W/Web_services.html
http://www.webopedia.com/DidYouKnow/Computer_Science/2005/web_services.asp
http://www.ibm.com/developerworks/library/ws-intwsdl
http://www.ibm.com/developerworks/library/ws-intwsdl2