Professional Documents
Culture Documents
Overview:
UDDI's standard Web services are divided into two WSDL/SOAP-based APIs:
1) Inquiry API: The Inquiry API is used to search and read data in a UDDI registry,
2) Publishing API: The Publishing API is used to add, modify, and delete data in a
UDDI registry.
WebService:
Advantages of Webservices:
The idea of a Web service developed from the evolution of the Internet.
The Main purpose of Web service technologies is to allow applications on different
platforms to exchange business data.
With JAX-WS, clients and web services have a big advantage: the Platform
independence of the Java programming language. A JAX-WS client can access a web
service that is not running on the Java platform, and vice versa. This flexibility is
possible because JAX-WS uses technologies defined by the Worldwide Web
Consortium (W3C): HTTP, SOAP, and the Web Service Description Language
(WSDL).
The starting point for developing a JAX-WS web service is a Java class
annotated with the javax.jws.WebService annotation. The WebService annotation
defines the class as a web service endpoint. A service endpoint interface (SEI) is a
Java interface that declares the methods that a client can invoke on the service. An
SEI is not required when building a JAX-WS endpoint. The web service
implementation class implicitly defines a SEI.
You use the endpoint implementation class and the wsgen tool to generate the web
service artifacts and the stubs that connect a web service client to the JAX-WS
runtime.
3) The business methods of the implementing class must be public, and must not
be declared static or final.
5) The implementing class must not be declared final and must not be
abstract.
6) The implementing class must have a default public constructor.
8) The implementing class must not be declared final and must not be
abstract.
10) The implementing class must not define the finalize method.
Step1:
Choose File Tab Choose Web Choose WebApplications Click on
Next.
Step 2:
Choose Project Name and Choose Server Name (Sun Java System Application
Server) Choose J2EE Version (Java EE5) and Click on Next and Click on Finish.
Step 3:
package com.iton;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@Entity
@Table(name = "customer")
@Column(name = "firstName")
private String firstName;
@Column(name = "lastName")
private String lastName;
@Id
@Column(name = "ADDRESS_ID")
private Integer addressId;
/** Creates a new instance of Customer */
public Customer() {
}
Creating WebService:
Step 4:
@WebMethod annotation.
table and getCustomer method returns the details of the particular record of
the client.
package com.iton;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.UserTransaction;
@WebService()
EntityManager em;
public DataWS(){
try {
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
em = (EntityManager) ctx.lookup("persistence/LogicalName");
}
catch (NamingException ex) {
ex.printStackTrace();
}
@WebMethod
//Business Methods that are exposed to web service clients must be annotated
with @javax.jws.WebMethod.
@WebMethod
Customer customer=(Customer)em.createNamedQuery("Customer.findById").
setParameter("id",id).getSingleResult();
al.add(customer.getId());
al.add(customer.getFirstName());
al.add(customer.getLastName());
return al;
}
To display the result Choose the DataWS File under the WebServices Folder .
and Click on getCustomer Then the result will be look like this
A Simple JAX-WS Client :
DataWSService. It makes this call through a stub, a local object that acts as a
Proxy for the remote service. The stub is created at development time by the
file.
When invoking the remote methods on the stub, the client performs these steps:
package com.iton;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.ws.WebServiceRef;
@WebServiceRef(wsdlLocation =
"http://192.168.0.30:8080/DataViaWS/DataWSService?wsdl")
response.setContentType("text/html;charset=UTF-8");
try {
// Call Web Service Operation
com.iton.DataWS port = service.getDataWSPort();
int arg1 = 2;
int arg2 = 3;
out.println("Result1 = "+result1);
out.println("<br>");
out.println("Result2 = "+result2);
out.println("<br>");
out.println("Result3 = "+result3);
out.close();
}
processRequest(request, response);
Advantages of JAXR:
UDDI browsing tool, JAXR is a great choice for supporting the actual SOAP
The JAXR API can be used to look up the Web service in UDDI and
Registry:
Standards (OASIS) and the United Nations Centre for the Facilitation of
(U.N./CEFACT)
JAXR Provider:
JAXR Architecture :
1) A JAXR client: This is a client program that uses the JAXR API to access a
information model for JAXR. These interfaces define the types of objects
that reside in a registry and how they relate to each other. The basic inte
Registry provider. The client must create a connection with the JAXR
connection. The RegistryService object in turn enables the client to obtain the