SlideShare uma empresa Scribd logo
1 de 6
Web Services tutorial


Web services in Java
A piece of business logic, located somewhere on the Internet, that is accessible through standard-
based Internet protocols such as HTTP or SMTP.

Characteristics

XML based

Loosely Coupled

Coarse grained

Ability to be Synchronous or Asynchronous

Supports Remote Procedure Calls (RPCs)

Supports document exchange


Major Web Services Technologies


Simple Object Access Protocol (SOAP)

Web Service Description Language (WSDL)

Universal Description, Discovery, and Integration (UDDI)

Simple web service interaction


Why Java Web Services

Ability of enterprises using different computing platforms to communicate with each other

Java ensures code portability

J2EE ensures scalability

APIs hide all the implementation details

Components are reusable

Development time is substantially reduced



                   Ganapathi
Web Services tutorial


Java Web Service Developer Pack

Free integrated toolkit that allows Java developers to build, test and deploy Web services

Web services standards WSDL, SOAP, UDDI

APIs provided

Java API for XML Messaging (JAXM)

Java API for XML Registries (JAXR)

Java API for XML-based RPC (JAX-RPC)

Sample Scenario-Online Book store




JAX-RPC API for XML based RPC

RPC-based Web service is a collection of procedures that can be called by a remote client

Ties, the low-level classes that the server needs to communicate with a remote client

WSDL document used for creating stubs, the low-level classes that are needed by a client to
communicate with a remote service.

Stubs can be static or dynamic.

Tools wscompile and wsdeploy

simplify our job




                   Ganapathi
Web Services tutorial




Service consists of

Interface:

Declares the service's remote procedures

Implementation class:

Implements the remote procedures.

Configuration files jaxrpc-ri.xml and web.xml contain all the parameters needed to deploy the
service.

Client is a Java program which uses the stubs created from the WSDL document of the service

Configuration file config.xml contains the location of the WSDL document.

Service Interface


public interface BookIF {

public Book getPriceList();

public String orderBook(String BookName, int quantity);

}
Implementation class

public class BookImpl implements BookIF {

public Book getPriceList() { . . . }

public String orderBook(String BookName, int quantity) { . . . }

}


                    Ganapathi
Web Services tutorial


Client code

public class BookClient {

public static void main(String[] args) {

BookIF BookOrder = new BookServiceImpl().getBookIF();

Book priceList = BookOrder.getPriceList():

for (int i = 0; i <>JAXM API for XML Messaging

Provides a standard way to send XML documents over the Internet

Based on SOAP and SOAP with Attachments specifications

Messaging provider service, which does the behind-the-scenes work required to transport and
route messages

Standalone client also possible for request-response type of messaging

Very useful when Enterprise work on shared schemas.(e.g.. Schema for order form in Online
Book Store)


Advantages over JAX-RPC

One-way (asynchronous) messaging

Routing of a message to more than one party

Reliable messaging with guaranteed delivery


Steps

1.Setting up Connection with the end-point.

2. Creating the SOAP message and populate it.

3. Sending the message.




                   Ganapathi
Web Services tutorial


JAXR API for XML Registries


Provides a convenient way to

access standard business registries

Supports two standards ebXML and UDDI

Standards groups have developed

schemas for particular kinds of XML documents, and two businesses might for example, agree to
use the schema which is stored in the registry.

Querying registry-Useful methods

1.findOrganizations

which returns a list of organizations that meet the specified criteria

2.findServices

which returns a set of services offered by a specified organization

3. FindServiceBindings

which returns the service bindings (information about how to access the service) that are
supported by a specified service


Similar methods exist for Managing Registry Data.


JAX-WS Dynamic Dispatch with CXF

Calling a web service is most often done by using some ws implementation stack like Axis2 or
CXF/XFire to generate stubs for your language. The stub code is then linked against, to do the
actual calls to the web service, marshall and unmarshall data etc.

This posts shows you how to do this completely at runtime, by using the CXF API directly.

If you are willing to bind yourself directly to the CXF API (as opposed to using the standard
JAX-WS apis), you can do some nice things. It can do the steps of generating stubs, but
completely at runtime. Look at this code:
 DynamicClientFactory dcf = DynamicClientFactory.newInstance();
 Client client = dcf.createClient("http://host/invoicing.wsdl",



                   Ganapathi
Web Services tutorial


DynamicClient.class.getClassLoader());

 Object customerParam =
Thread.currentThread().getContextClassLoader().loadClass("com.acme.invoicing.
Customer").newInstance();

 Method setCustIdMethod = customerParam.getClass().getMethod("setCustomerId",
String.class);
 setCustIdMethod.invoke(customerParam, "CUST-42");

 Object[] result = client.invoke("doInvoicingOnCustomer", customerParam);

Here is a bit of explanation of what happens here:

       Calling createClient on a DynamicClientFactory instance makes CXF load
       the WSDL, generate stubs and compile them to class files. They are now available on the
       current threads context classloader.
       In this example, the invoicing.wsdl service is supposed to have a method
       doInvoicingOnCustomer(Customer). The wsdl will have Customer defined,
       which will make CXF generate a Customer class.
       You can then call loadClass method to load the Customer class and do a
       newInstance
       To call customer.setCustomerId(String), we reflect the method out and
       invoke the setter with the value "CUST-42".
       And lastly, we call the doInvoicingOnCustomer remote webservice method,
       giving the Customer instance as parameter

And of course. The Object[] output is typed in generated classes too. Ready to be reflected
upon.

The above code binds directly to the CXF API. There is also the possibility of using the standard
JAX-WS API for this. There are good examples on using the standard JAX-WS API to do
dynamic calls:

       Using Dispatch and Service.Mode.MESSAGE to construct a JAX-WS dynamic call,
       where you have to provide the complete soap:Envelope part, of the message
       Using Dispatch and Service.Mode.PAYLOAD to construct a JAX-WS dynamic call,
       where you "only" have to provide the soap:Body part, of the message

But I do not like it. The code in the above two links use the rather low-level API of
javax.xml.soap package to construct the call to the server. It seems like you have to know a lot
about the needed SOAP message format, QNames to use, etc.




                   Ganapathi

Mais conteúdo relacionado

Mais procurados

Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WSKatrien Verbert
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITCarol McDonald
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & RESTSanthu Rao
 
introduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationintroduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationredaxe12
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIIMC Institute
 
Java Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesJava Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesIMC Institute
 
Web services
Web servicesWeb services
Web servicesaspnet123
 
Wcf architecture overview
Wcf architecture overviewWcf architecture overview
Wcf architecture overviewArbind Tiwari
 
WebService-Java
WebService-JavaWebService-Java
WebService-Javahalwal
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIRajkattamuri
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web servicesNeil Ghosh
 

Mais procurados (20)

Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
introduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationintroduction to Windows Comunication Foundation
introduction to Windows Comunication Foundation
 
Webservice Testing
Webservice TestingWebservice Testing
Webservice Testing
 
Java Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDIJava Web Services [3/5]: WSDL, WADL and UDDI
Java Web Services [3/5]: WSDL, WADL and UDDI
 
Web Services - WSDL
Web Services - WSDLWeb Services - WSDL
Web Services - WSDL
 
Java Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web ServicesJava Web Services [4/5]: Java API for XML Web Services
Java Web Services [4/5]: Java API for XML Web Services
 
Web services
Web servicesWeb services
Web services
 
WSDL
WSDLWSDL
WSDL
 
Wcf faq
Wcf faqWcf faq
Wcf faq
 
WCF for begineers
WCF  for begineersWCF  for begineers
WCF for begineers
 
11-DWR-and-JQuery
11-DWR-and-JQuery11-DWR-and-JQuery
11-DWR-and-JQuery
 
Wcf architecture overview
Wcf architecture overviewWcf architecture overview
Wcf architecture overview
 
WebService-Java
WebService-JavaWebService-Java
WebService-Java
 
WCF And ASMX Web Services
WCF And ASMX Web ServicesWCF And ASMX Web Services
WCF And ASMX Web Services
 
WebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDIWebServices SOAP WSDL and UDDI
WebServices SOAP WSDL and UDDI
 
Java web services
Java web servicesJava web services
Java web services
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 

Semelhante a Web services in java

Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Mindfire Solutions
 
Web service through cxf
Web service through cxfWeb service through cxf
Web service through cxfRoger Xia
 
Application integration framework & Adaptor ppt
Application integration framework & Adaptor pptApplication integration framework & Adaptor ppt
Application integration framework & Adaptor pptAditya Negi
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
Xml web services
Xml web servicesXml web services
Xml web servicesRaghu nath
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Charlin Agramonte
 
Jax ws
Jax wsJax ws
Jax wsF K
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorialAbhi Arya
 
Web service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National WokshopWeb service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National WokshopNishikant Taksande
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casellentuck
 
Web services Concepts
Web services ConceptsWeb services Concepts
Web services Conceptspasam suresh
 
Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Deepak Gupta
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaJignesh Aakoliya
 
58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-serviceshomeworkping3
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocationashishspace
 

Semelhante a Web services in java (20)

Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)Webservices in SalesForce (part 1)
Webservices in SalesForce (part 1)
 
Web service through cxf
Web service through cxfWeb service through cxf
Web service through cxf
 
Application integration framework & Adaptor ppt
Application integration framework & Adaptor pptApplication integration framework & Adaptor ppt
Application integration framework & Adaptor ppt
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Xml web services
Xml web servicesXml web services
Xml web services
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5
 
Mule soft ppt 2
Mule soft ppt  2Mule soft ppt  2
Mule soft ppt 2
 
Jax ws
Jax wsJax ws
Jax ws
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
Web service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National WokshopWeb service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National Wokshop
 
Jasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-casJasigsakai12 columbia-customizes-cas
Jasigsakai12 columbia-customizes-cas
 
Web services Concepts
Web services ConceptsWeb services Concepts
Web services Concepts
 
Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)
 
WCF Fundamentals
WCF Fundamentals WCF Fundamentals
WCF Fundamentals
 
Web Service Basics and NWS Setup
Web Service  Basics and NWS SetupWeb Service  Basics and NWS Setup
Web Service Basics and NWS Setup
 
Servlets
ServletsServlets
Servlets
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services58615764 net-and-j2 ee-web-services
58615764 net-and-j2 ee-web-services
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Web services in java

  • 1. Web Services tutorial Web services in Java A piece of business logic, located somewhere on the Internet, that is accessible through standard- based Internet protocols such as HTTP or SMTP. Characteristics XML based Loosely Coupled Coarse grained Ability to be Synchronous or Asynchronous Supports Remote Procedure Calls (RPCs) Supports document exchange Major Web Services Technologies Simple Object Access Protocol (SOAP) Web Service Description Language (WSDL) Universal Description, Discovery, and Integration (UDDI) Simple web service interaction Why Java Web Services Ability of enterprises using different computing platforms to communicate with each other Java ensures code portability J2EE ensures scalability APIs hide all the implementation details Components are reusable Development time is substantially reduced Ganapathi
  • 2. Web Services tutorial Java Web Service Developer Pack Free integrated toolkit that allows Java developers to build, test and deploy Web services Web services standards WSDL, SOAP, UDDI APIs provided Java API for XML Messaging (JAXM) Java API for XML Registries (JAXR) Java API for XML-based RPC (JAX-RPC) Sample Scenario-Online Book store JAX-RPC API for XML based RPC RPC-based Web service is a collection of procedures that can be called by a remote client Ties, the low-level classes that the server needs to communicate with a remote client WSDL document used for creating stubs, the low-level classes that are needed by a client to communicate with a remote service. Stubs can be static or dynamic. Tools wscompile and wsdeploy simplify our job Ganapathi
  • 3. Web Services tutorial Service consists of Interface: Declares the service's remote procedures Implementation class: Implements the remote procedures. Configuration files jaxrpc-ri.xml and web.xml contain all the parameters needed to deploy the service. Client is a Java program which uses the stubs created from the WSDL document of the service Configuration file config.xml contains the location of the WSDL document. Service Interface public interface BookIF { public Book getPriceList(); public String orderBook(String BookName, int quantity); } Implementation class public class BookImpl implements BookIF { public Book getPriceList() { . . . } public String orderBook(String BookName, int quantity) { . . . } } Ganapathi
  • 4. Web Services tutorial Client code public class BookClient { public static void main(String[] args) { BookIF BookOrder = new BookServiceImpl().getBookIF(); Book priceList = BookOrder.getPriceList(): for (int i = 0; i <>JAXM API for XML Messaging Provides a standard way to send XML documents over the Internet Based on SOAP and SOAP with Attachments specifications Messaging provider service, which does the behind-the-scenes work required to transport and route messages Standalone client also possible for request-response type of messaging Very useful when Enterprise work on shared schemas.(e.g.. Schema for order form in Online Book Store) Advantages over JAX-RPC One-way (asynchronous) messaging Routing of a message to more than one party Reliable messaging with guaranteed delivery Steps 1.Setting up Connection with the end-point. 2. Creating the SOAP message and populate it. 3. Sending the message. Ganapathi
  • 5. Web Services tutorial JAXR API for XML Registries Provides a convenient way to access standard business registries Supports two standards ebXML and UDDI Standards groups have developed schemas for particular kinds of XML documents, and two businesses might for example, agree to use the schema which is stored in the registry. Querying registry-Useful methods 1.findOrganizations which returns a list of organizations that meet the specified criteria 2.findServices which returns a set of services offered by a specified organization 3. FindServiceBindings which returns the service bindings (information about how to access the service) that are supported by a specified service Similar methods exist for Managing Registry Data. JAX-WS Dynamic Dispatch with CXF Calling a web service is most often done by using some ws implementation stack like Axis2 or CXF/XFire to generate stubs for your language. The stub code is then linked against, to do the actual calls to the web service, marshall and unmarshall data etc. This posts shows you how to do this completely at runtime, by using the CXF API directly. If you are willing to bind yourself directly to the CXF API (as opposed to using the standard JAX-WS apis), you can do some nice things. It can do the steps of generating stubs, but completely at runtime. Look at this code: DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("http://host/invoicing.wsdl", Ganapathi
  • 6. Web Services tutorial DynamicClient.class.getClassLoader()); Object customerParam = Thread.currentThread().getContextClassLoader().loadClass("com.acme.invoicing. Customer").newInstance(); Method setCustIdMethod = customerParam.getClass().getMethod("setCustomerId", String.class); setCustIdMethod.invoke(customerParam, "CUST-42"); Object[] result = client.invoke("doInvoicingOnCustomer", customerParam); Here is a bit of explanation of what happens here: Calling createClient on a DynamicClientFactory instance makes CXF load the WSDL, generate stubs and compile them to class files. They are now available on the current threads context classloader. In this example, the invoicing.wsdl service is supposed to have a method doInvoicingOnCustomer(Customer). The wsdl will have Customer defined, which will make CXF generate a Customer class. You can then call loadClass method to load the Customer class and do a newInstance To call customer.setCustomerId(String), we reflect the method out and invoke the setter with the value "CUST-42". And lastly, we call the doInvoicingOnCustomer remote webservice method, giving the Customer instance as parameter And of course. The Object[] output is typed in generated classes too. Ready to be reflected upon. The above code binds directly to the CXF API. There is also the possibility of using the standard JAX-WS API for this. There are good examples on using the standard JAX-WS API to do dynamic calls: Using Dispatch and Service.Mode.MESSAGE to construct a JAX-WS dynamic call, where you have to provide the complete soap:Envelope part, of the message Using Dispatch and Service.Mode.PAYLOAD to construct a JAX-WS dynamic call, where you "only" have to provide the soap:Body part, of the message But I do not like it. The code in the above two links use the rather low-level API of javax.xml.soap package to construct the call to the server. It seems like you have to know a lot about the needed SOAP message format, QNames to use, etc. Ganapathi