Your SlideShare is downloading. ×
0
Web Services Harish Alwala
Agenda   Overview Architecture WSDL SOAP UDDI An Example >> >> >> >> >> >>
Overview <ul><li>General Definition </li></ul><ul><ul><li>A Web Service is a software component that is described via WSDL...
Overview <ul><li>Key Features </li></ul><ul><li>Web services are self-contained .  </li></ul><ul><li>On the client side, n...
Overview <ul><li>Key Features </li></ul><ul><li>Web services are inherently open and standard-based.   </li></ul><ul><li>X...
Architecture <ul><li>Characteristics of the Web service  architecture </li></ul><ul><li>Webservice that follows the servic...
Architecture <ul><li>Concept of a service-oriented </li></ul><ul><li>The  service provider  creates a Web service and poss...
Architecture <ul><li>The following are the core technologies used for Web services. </li></ul><ul><ul><li>XML  (eXtensible...
WSDL <ul><li>WSDL architecture </li></ul><ul><li>Web Services Description Language (WSDL) files are written in Extensible ...
WSDL <ul><li>A WSDL file describes a Web service with the following elements: </li></ul><ul><ul><li>portType </li></ul></u...
WSDL <ul><ul><li>types </li></ul></ul><ul><ul><ul><li>The   schema for describing XML types used in the messages. </li></u...
WSDL <ul><ul><li>The services and ports define the location of the Web service </li></ul></ul><ul><ul><li>Service </li></u...
SOAP <ul><li>SOAP </li></ul><ul><li>SOAP is a lightweight protocol intended for exchanging structured information in a dec...
SOAP <ul><li>SOAP can be used over any transport protocol such as TCP, HTTP, SMTP </li></ul><ul><li>This protocol consists...
SOAP <ul><li>SOAP Schema: </li></ul><ul><li>The  Envelope  element is always the root element of a SOAP message. The Envel...
SOAP <ul><li>SOAP Request </li></ul><ul><ul><li><soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&...
SOAP <ul><li>Fault Code </li></ul><ul><li><soap:Envelope  xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;...
UDDI <ul><li>The Universal Description, Discovery and Integration (UDDI) define a way to publish and discover information ...
Service Styles <ul><li>Service Styles - RPC, Document, Wrapped, and Message  </li></ul><ul><li>RPC: </li></ul><ul><ul><li>...
Service Styles <ul><li><schema targetNamespace=&quot;http://commerce.com/PO&quot;> </li></ul><ul><ul><li><complexType name...
Service Styles <ul><li>Standard mappings from WSDL to Java </li></ul>
An Example <ul><li>Axis Setup </li></ul><ul><li>Axis software in the form of xml-axis-beta3-bin.zip can be downloaded from...
An Example <ul><li>A sample java Class </li></ul><ul><li>public class HelloWorld{ </li></ul><ul><li>public String sayHello...
An Example <ul><li>Use the above wsdd file to expose as web service with the following command. </li></ul><ul><ul><li>java...
An Example <ul><li>Java code to access the web service via stubs </li></ul><ul><li>import java.rmi.RemoteException; </li><...
An Example <ul><li>java org.apache.axis.utils.tcpmon </li></ul>
Documentation <ul><li>The JAX-WS 2.0 specification demands that the exception annotated with @WebFault must have two const...
Documentation <ul><li>HandlerChain </li></ul><ul><li>Example: </li></ul><ul><li><?xml version= &quot;1.0&quot; encoding=&q...
Documentation <ul><li>HandlerChain </li></ul><ul><li>Example: </li></ul><ul><li>Handler Interface </li></ul><ul><li>public...
Documentation <ul><li>Annotations: </li></ul><ul><li>JSR 181 (Web Services Metadata) Annotations </li></ul><ul><li>2.1 jav...
Documentation <ul><li>URLs </li></ul><ul><li>http://today.java.net/pub/a/today/2006/09/19/asynchronous-jax-ws-web-services...
Thank You!
Upcoming SlideShare
Loading in...5
×

WebService-Java

7,044

Published on

Detail Description of WebServices

Published in: Technology, News & Politics

Transcript of "WebService-Java"

  1. 1. Web Services Harish Alwala
  2. 2. Agenda Overview Architecture WSDL SOAP UDDI An Example >> >> >> >> >> >>
  3. 3. Overview <ul><li>General Definition </li></ul><ul><ul><li>A Web Service is a software component that is described via WSDL and is capable of being accessed via standard network protocols such as but not limited to SOAP over HTTP. </li></ul></ul><ul><ul><li>Web service is a software component that provides a consistent, transparent API for invocation of services by using message-oriented transport mechanisms, which can be dynamically located and bound, and by utilizing XML for data representation and transformation </li></ul></ul><ul><li>According to Gartner Group: </li></ul><ul><li>“ Web services are software components that interact with one another dynamically via standard Internet Technologies, making it possible to build bridges between IT systems that otherwise would require extensive development efforts” </li></ul><ul><li>Web services are </li></ul><ul><ul><li>Complementary to existing technology </li></ul></ul><ul><ul><li>Building blocks (components) used to construct larger applications </li></ul></ul><ul><ul><li>Evolutionary technology: The latest in a long line of approaches for distributed applications communication </li></ul></ul><ul><li>Web services are NOT </li></ul><ul><ul><li>A rip and replace technology </li></ul></ul><ul><ul><li>A solution to all the integration woes </li></ul></ul>
  4. 4. Overview <ul><li>Key Features </li></ul><ul><li>Web services are self-contained . </li></ul><ul><li>On the client side, no additional software is required. A programming language with XML and HTTP client support is enough to get you started. On the server side, merely a Web server and a SOAP server are required. </li></ul><ul><li>Web services are self-describing . </li></ul><ul><li>Neither the client nor the server knows or cares about anything besides the format and content of request and response messages (loosely coupled application integration). </li></ul><ul><li>Web services can be published, located, and invoked across the Web . </li></ul><ul><li>This technology uses established lightweight Internet standards such as HTTP. It leverages the existing infrastructure. Some additional standards that are required to do so include SOAP, WSDL, and UDDI. </li></ul><ul><li>Web services are language-independent and interoperable . </li></ul><ul><li>Client and server can be implemented in different environments. Existing code does not have to be changed in order to be Web service enabled. </li></ul><ul><li>Cntd… </li></ul>
  5. 5. Overview <ul><li>Key Features </li></ul><ul><li>Web services are inherently open and standard-based. </li></ul><ul><li>XML and HTTP are the major technical foundation for Web services. A large part of the Web service technology has been built using open-source projects. Therefore, vendor independence and interoperability are realistic goals this time. </li></ul><ul><li>Web services build on proven mature technology </li></ul><ul><li>There are a lot of commonalities, as well as a few fundamental differences to other distributed computing frameworks. For example, Web services are build with SOA Architecture. </li></ul><ul><li>Web services are loosely coupled </li></ul><ul><li>Traditionally, application design has depended on tight interconnections at both ends. Web services require a simpler level of coordination that allows a more flexible re-configuration for an integration of the services in question. </li></ul><ul><li>Web services provide the ability to wrap existing applications </li></ul><ul><li>Already existing stand-alone applications can easily be integrated into the service-oriented architecture by implementing a Web service as an interface. </li></ul>
  6. 6. Architecture <ul><li>Characteristics of the Web service architecture </li></ul><ul><li>Webservice that follows the service-oriented architecture employs a loose coupling betweenthe participants. Such a loose coupling provides greater flexibility: </li></ul><ul><li>In this architecture, a client is not coupled to a server, but to a service. Thus, the integration of the server to use takes place outside of the scope of the client application programs. </li></ul><ul><li>Functional components and their interfaces are separated. Therefore, new interfaces can be plugged in more easily. </li></ul><ul><li>Within complex applications, the control of business processes can be isolated. A business rule engine can be incorporated to control the workflow of a defined business process. Depending on the state of the workflow, the engine calls the respective services. </li></ul><ul><li>Bindings are specified using configuration files and can thus easily be adapted to new needs. </li></ul>
  7. 7. Architecture <ul><li>Concept of a service-oriented </li></ul><ul><li>The service provider creates a Web service and possibly publishes its interface and access information to the service registry. </li></ul><ul><li>The service broker (also known as service registry) is responsible for making the Web service interface and implementation access information available to any potential service requestor. </li></ul><ul><li>The service requestor locates entries in the broker registry using various find operations and then binds to the service provider in order to invoke one of its Web services. </li></ul>
  8. 8. Architecture <ul><li>The following are the core technologies used for Web services. </li></ul><ul><ul><li>XML (eXtensible Markup Language) </li></ul></ul><ul><ul><li>The markup language that underlies most of the specifications used for Web services. XML is a generic language that can be used to describe any kind of content in a structured way, separated from its presentation to a specific device. </li></ul></ul><ul><ul><li>SOAP (Simple Object Access Protocol) </li></ul></ul><ul><ul><li>SOAP similar to JDBC, is a network, transport, and programming language and platform neutral protocol that allows a client to call a remote service. The message format is XML. </li></ul></ul><ul><ul><li>WSDL (Web services description language) </li></ul></ul><ul><ul><li>WSDL is an XML-based interface and implementation description language. The service provider uses a WSDL document in order to specify the operations a Web service provides, as well as the parameters and data types of these operations. A WSDL document also contains the service access information. </li></ul></ul><ul><ul><li>UDDI (universal description, discovery, and integration) </li></ul></ul><ul><ul><li>UDDI is both a client-side API and a SOAP-based server implementation that can be used to store and retrieve information on service providers and Web services. </li></ul></ul>
  9. 9. WSDL <ul><li>WSDL architecture </li></ul><ul><li>Web Services Description Language (WSDL) files are written in Extensible Markup Language (XML). </li></ul><ul><li>WSDL is one alternative to make service interfaces and implementations available in the UDDI registry. </li></ul><ul><li>WSDL includes the workflow description (business process execution language for Web services, BPEL4WS) </li></ul><ul><li>WSDL is the base for SOAP server deployment and SOAP client generation. </li></ul><ul><li>A WSDL file contains the following parts: </li></ul><ul><li>Web service interface definition </li></ul><ul><ul><li>This is part contains the elements, as well as the namespaces. </li></ul></ul><ul><li>Web service implementation </li></ul><ul><ul><li>This part contains the definition of the service and ports. </li></ul></ul><ul><li>The following is the structure of the information in a WSDL file : A WSDL file contains the following parts: </li></ul>
  10. 10. WSDL <ul><li>A WSDL file describes a Web service with the following elements: </li></ul><ul><ul><li>portType </li></ul></ul><ul><ul><ul><li>The description of the operations and associated messages. The portType element defines abstract operations. </li></ul></ul></ul><ul><ul><ul><ul><li><portType name=&quot;EightBall&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><operation name=&quot;getAnswer&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li><input message=&quot;ebs:IngetAnswerRequest&quot;/> </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li><output message=&quot;ebs:OutgetAnswerResponse&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><ul><li></operation> </li></ul></ul></ul></ul><ul><ul><ul><ul><li></portType > </li></ul></ul></ul></ul><ul><ul><li>message </li></ul></ul><ul><ul><ul><li>The description of input and output parameters and return values. </li></ul></ul></ul><ul><ul><ul><ul><li><message name=&quot;IngetAnswerRequest&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><part name=&quot;meth1_inType&quot; type=&quot;ebs:questionType&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><ul><li></message> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><message name=&quot;OutgetAnswerResponse&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><part name=&quot;meth1_outType&quot; type=&quot;ebs:answerType&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><ul><li></message> </li></ul></ul></ul></ul>
  11. 11. WSDL <ul><ul><li>types </li></ul></ul><ul><ul><ul><li>The schema for describing XML types used in the messages. </li></ul></ul></ul><ul><ul><ul><li><types> </li></ul></ul></ul><ul><ul><ul><ul><li><xsd:schema targetNamespace=&quot;...&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><xsd:complexType name=&quot;questionType&quot;> <xsd:element name=&quot;question&quot; type=&quot;string&quot;/> </xsd:complexType> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><xsd:complexType name=&quot;answerType&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li>... </li></ul></ul></ul></ul><ul><ul><ul><ul><li></types> </li></ul></ul></ul></ul><ul><ul><li>binding </li></ul></ul><ul><ul><ul><li>The bindings describe the protocol that is used to access a portType, as well as the data formats for the messages that are defined by a particular portType element. </li></ul></ul></ul><ul><ul><ul><li><binding name=&quot;EightBallBinding&quot; type=&quot;ebs:EightBall&quot;> <soap:binding style=&quot;rpc” transport=&quot;schemas.xmlsoap.org/soap/http&quot;> </li></ul></ul></ul><ul><ul><ul><li><operation name=&quot;ebs:getAnswer&quot;> </li></ul></ul></ul><ul><ul><ul><li><soap:operation soapAction=&quot;urn:EightBall&quot;/> </li></ul></ul></ul><ul><ul><ul><li><input> </li></ul></ul></ul><ul><ul><ul><li><soap:body namespace=&quot;urn:EightBall&quot; ... /> </li></ul></ul></ul><ul><ul><ul><li>… </li></ul></ul></ul>
  12. 12. WSDL <ul><ul><li>The services and ports define the location of the Web service </li></ul></ul><ul><ul><li>Service </li></ul></ul><ul><ul><ul><li>The service contains the Web service name and a list of ports. </li></ul></ul></ul><ul><ul><li>Ports </li></ul></ul><ul><ul><ul><li>The ports contain the location of the Web service and the binding used for service access. </li></ul></ul></ul><ul><ul><ul><ul><li><service name=&quot;EightBall&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li><port binding=&quot;ebs:EightBallBinding&quot; name=&quot;EightBallPort&quot;> </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li><soap:address location=&quot;localhost:8080/axis/EightBall&quot;/> </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li></port> </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li></ service > </li></ul></ul></ul></ul>
  13. 13. SOAP <ul><li>SOAP </li></ul><ul><li>SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. SOAP uses XML technologies to define an extensible messaging framework, which provides a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics. </li></ul><ul><li>It represents the main way of communication between the three key actors in a service oriented architecture (SOA): service provider, service requestor and service broker. The main goal of its design is to be simple and extensible. A SOAP message is used to request a Web service. </li></ul>
  14. 14. SOAP <ul><li>SOAP can be used over any transport protocol such as TCP, HTTP, SMTP </li></ul><ul><li>This protocol consists of three parts: </li></ul><ul><ul><li>An envelope that defines a framework for describing message content and processing instructions. </li></ul></ul><ul><ul><li>A set of encoding rules for expressing instances of application-defined data types. </li></ul></ul><ul><ul><li>A convention for representing remote procedure calls and responses. </li></ul></ul><ul><li>SOAP is a protocol-independent transport and can be used in combination with a variety of protocols. In Web services SOAP is used in combination with HTTP, HTTP extension framework and Java Message Service (JMS). </li></ul><ul><li>SOAP is also operating-system independent and not tied to any programming language or component technology. </li></ul><ul><li>As long as the client can issue XML messages, it does not matter what technology is used to implement the client. Also, both server and client sides can reside on any suitable platform. </li></ul>
  15. 15. SOAP <ul><li>SOAP Schema: </li></ul><ul><li>The Envelope element is always the root element of a SOAP message. The Envelope element contains an optional Header element, followed by a mandatory Body element. </li></ul><ul><li>The Body element represents the message payload. The Body element is a generic container in that it can contain any number of elements from any namespace. This is ultimately where the data goes that you're trying to send. </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;> </li></ul><ul><ul><li><soap:Header> </li></ul></ul><ul><ul><li><!-- optional --> </li></ul></ul><ul><ul><li><!-- header blocks go here... --> </li></ul></ul><ul><ul><li> </soap:Header> </li></ul></ul><ul><ul><li><soap:Body> </li></ul></ul><ul><ul><li><!-- payload or Fault element goes here... --> </li></ul></ul><ul><ul><li></soap:Body> </li></ul></ul><ul><ul><li></soap:Envelope> </li></ul></ul>
  16. 16. SOAP <ul><li>SOAP Request </li></ul><ul><ul><li><soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;> </li></ul></ul><ul><ul><li><soap:Body> </li></ul></ul><ul><ul><li><x:TransferFunds xmlns:x=&quot;urn:examples-org:banking&quot;> </li></ul></ul><ul><ul><li><from>01-4-2006</from> </li></ul></ul><ul><ul><li><to>31-04-2006</to> </li></ul></ul><ul><ul><li><amount>100.00</amount> </li></ul></ul><ul><ul><li></x:TransferFunds> </li></ul></ul><ul><ul><li></soap:Body> </li></ul></ul><ul><ul><li></soap:Envelope> </li></ul></ul><ul><li>SOAP Response </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;> </li></ul><ul><li><soap:Body> </li></ul><ul><li><x:TransferFundsResponse xmlns:x=&quot;urn:examples-org:banking&quot;> </li></ul><ul><li><balances> </li></ul><ul><li><account> </li></ul><ul><li><id>22-342439</id> <balance>33.45</balance> </li></ul><ul><li></account> </li></ul><ul><li></balances> </li></ul><ul><li></x:TransferFundsResponse> </li></ul><ul><li></soap:Body> </li></ul><ul><li> </soap:Envelope> </li></ul>
  17. 17. SOAP <ul><li>Fault Code </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;> </li></ul><ul><li><soap:Body> </li></ul><ul><li><soap:Fault> </li></ul><ul><li><faultcode>soap:Server</faultcode> <faultstring>Insufficient funds</faultstring> <detail> </li></ul><ul><li><x:TransferError xmlns:x=&quot;urn:examples-org:banking&quot;> <sourceAccount>22- 342439</sourceAccount> <transferAmount> </li></ul><ul><li>100.00</transferAmount> <currentBalance> </li></ul><ul><li>89.23</currentBalance> </x:TransferError> </li></ul><ul><li></detail> </li></ul><ul><li> </soap:Fault> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul>
  18. 18. UDDI <ul><li>The Universal Description, Discovery and Integration (UDDI) define a way to publish and discover information about Web services. The term “Web service” describes specific business functionality exposed by a company, usually through an Internet connection, for the purpose of providing a way for another company or software program to use the service. </li></ul><ul><li>Conceptually, the information provided in a UDDI business registration consists of three components: </li></ul><ul><li>white pages </li></ul><ul><ul><li>address, contact, and known identifiers; </li></ul></ul><ul><li>yellow pages </li></ul><ul><ul><li>industrial categorizations based on standard taxonomies; </li></ul></ul><ul><li>green pages </li></ul><ul><ul><li>the technical information about services that are exposed by the business. Green pages include references to specifications for Web services, as well as support for pointers to various file and URL based discovery mechanisms if required. </li></ul></ul>
  19. 19. Service Styles <ul><li>Service Styles - RPC, Document, Wrapped, and Message </li></ul><ul><li>RPC: </li></ul><ul><ul><li>RPC services are the default in Axis </li></ul></ul><ul><ul><li>Axis will deserialize XML into Java objects which can be fed to your service, and will serialize the returned Java object(s) from your service back into XML. </li></ul></ul><ul><li>Document </li></ul><ul><ul><li>Document services do not use any encoding (so in particular, you won't see multiref object serialization or SOAP-style arrays on the wire) but DO still do XML<->Java databinding </li></ul></ul><ul><li>Wrapped </li></ul><ul><ul><li>Wrapped services are just like document services, except that rather than binding the entire SOAP body into one big structure, they &quot;unwrap&quot; it into individual parameters </li></ul></ul><ul><li>Message </li></ul><ul><ul><li>Message services receive and return arbitrary XML in the SOAP Envelope without any type mapping / data binding. If you want to work with the raw XML of the incoming and outgoing SOAP Envelopes, write a message service </li></ul></ul>
  20. 20. Service Styles <ul><li><schema targetNamespace=&quot;http://commerce.com/PO&quot;> </li></ul><ul><ul><li><complexType name=&quot;POType&quot;> </li></ul></ul><ul><ul><ul><li><sequence> </li></ul></ul></ul><ul><ul><ul><ul><li><element name=&quot;item&quot; type=&quot;xsd:string&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><element name=&quot;quantity&quot; type=&quot;xsd:int&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><element name=&quot;description&quot; type=&quot;xsd:string&quot;/> </li></ul></ul></ul></ul><ul><ul><ul><li></sequence> </li></ul></ul></ul><ul><ul><li></complexType> </li></ul></ul><ul><ul><li><element name=&quot;PurchaseOrder&quot; type=&quot;POType&quot;/> </li></ul></ul><ul><li>document style service, this would map to a method like this: </li></ul><ul><ul><li>public void method(PurchaseOrder po) </li></ul></ul><ul><li>In other words, the ENTIRE <PurchaseOrder> element would be handed to your method as a single bean with three fields inside it. On the other hand, </li></ul><ul><li>wrapped style service, it would map to a method like this: </li></ul><ul><ul><li>public void purchaseOrder(String item, int quantity, String description) </li></ul></ul><ul><li>Message Service </li></ul><ul><ul><li>public Element [] method(Element [] bodies); public SOAPBodyElement [] method (SOAPBodyElement [] bodies); public Document method(Document body); public void method(SOAPEnvelope req, SOAPEnvelope resp); </li></ul></ul>
  21. 21. Service Styles <ul><li>Standard mappings from WSDL to Java </li></ul>
  22. 22. An Example <ul><li>Axis Setup </li></ul><ul><li>Axis software in the form of xml-axis-beta3-bin.zip can be downloaded from http://archive.apache.org/dist/ws/axis/beta3 </li></ul><ul><li>Extract the folder from zip file to c:/xml-axis folder </li></ul><ul><li>Set “%XML_AXIS% = c:/xml-axis” as environment variable </li></ul><ul><li>Set classpath = %XML_AXIS%libaxis.jar; %XML_AXIS% libcommons-logging.jar; %XML_AXIS%libjaxrpc.jar;c:xml-axisliblog4j-1.2.4.jar; %XML_AXIS%lib t-bytecode.jar; %XML_AXIS%libwsdl4j.jar;%XML_AXIS%libxmlParserAPIs.jar; %XML_AXIS%libsaaj.jar %JAVA_HOME%lib ools.jar; </li></ul><ul><li>Apache Tomcat Setup </li></ul><ul><li>Download Apache tomcat (jakarta-tomcat-4.1.31.exe) from http://mirror.tomato.it/apache/jakarta/tomcat-4/v4.1.31/bin </li></ul><ul><li>Set “CATALINA_HOME = C:Apache Tomcat 4.0” as environment variable </li></ul><ul><li>Also set “path=%path%;CATALINA_HOMEin” </li></ul><ul><li>Add the following in server.xml (C:Apache Tomcat 4.0conf). </li></ul><ul><ul><li><Context path=&quot;/axis&quot; docBase=&quot;C:xml-axiswebappsaxis&quot; debug=&quot;0&quot;/> </li></ul></ul><ul><li>Start tomacat web server </li></ul>
  23. 23. An Example <ul><li>A sample java Class </li></ul><ul><li>public class HelloWorld{ </li></ul><ul><li>public String sayHello(String reader){ </li></ul><ul><li>System.out.println(&quot;Service Called&quot;); </li></ul><ul><li>return &quot;Hi &quot; + reader + &quot; How are you&quot;; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>Steps to Expose as Web Service </li></ul><ul><li>Write the following to a text file and name it as HelloWorldService.wsdd. </li></ul><ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul></ul><ul><ul><li><deployment xmlns=“ http:// xml.apache.org/axis/wsdd / ” xmlns:java=&quot;http://xml.apache.org/axis/wsdd/providers/java&quot;> </li></ul></ul><ul><ul><li> <service name=&quot;HelloWorldService&quot; provider=&quot;java:RPC&quot;> </li></ul></ul><ul><ul><li><parameter name=&quot;allowedMethods&quot; value=“sayHello&quot;/> </li></ul></ul><ul><ul><li><parameter name=&quot;className&quot; value=&quot;HelloWorld&quot;/> </li></ul></ul><ul><ul><li> </service> </li></ul></ul><ul><ul><li></deployment> </li></ul></ul>
  24. 24. An Example <ul><li>Use the above wsdd file to expose as web service with the following command. </li></ul><ul><ul><li>java -classpath &quot;%classpath%;C:jarsaxis.jar;C:jarsjaxrpc.jar;C:jarscommons-logging-1.0.3.jar;C:jarscommons-discovery-0.2.jar;C:jarsjndi.jar;C:jarssaaj.jar;.&quot; org.apache.axis.client.AdminClient -h localhost -p 8080 -s WebservicesTest/servlet/AxisServlet &quot;C: HelloWorldService .wsdd“ </li></ul></ul><ul><ul><li>Test the exposed web service </li></ul></ul><ul><ul><ul><li>http://localhost:8080 /WebservicesTest /servlet/AxisServlet </li></ul></ul></ul><ul><ul><li>Click on “wsdl” to view wsdl file in browser. </li></ul></ul><ul><li>Use the following command to generate wsdl file for the exposed service </li></ul><ul><ul><li>Java org.apache.axis.wsdl.Java2WSDL HelloWorld -l http://localhost:8080/ WebservicesTest /services/HelloWorldService </li></ul></ul><ul><ul><li>Copy the wsdl file to %XML_AXIS% root </li></ul></ul><ul><li>Use the following command to generate the stubs for given wsdl file </li></ul><ul><ul><li>java org.apache.axis.wsdl.WSDL2Java C:xml-axisHelloWorldService.wsdl </li></ul></ul><ul><ul><li>For the generated stubs write a java class to access the web service. </li></ul></ul>
  25. 25. An Example <ul><li>Java code to access the web service via stubs </li></ul><ul><li>import java.rmi.RemoteException; </li></ul><ul><li>import javax.xml.rpc.ServiceException; </li></ul><ul><li>public class HelloWorldStubClient { </li></ul><ul><li>public static void main(String[] args) { </li></ul><ul><li> try{ </li></ul><ul><li> //Fetch HelloWorldService object from Service Locator generated </li></ul><ul><li> HelloWorldService hWorldService = new HelloWorldServiceLocator(); </li></ul><ul><li> //Fetch actual service hosted from the service. </li></ul><ul><li> HelloWorld hWorld = hWorldService.getHelloWorldService(); </li></ul><ul><li> //call the Service method </li></ul><ul><li> System.out.println(hWorld.sayHello(&quot;Harish&quot;)); </li></ul><ul><li> }catch(ServiceException sExc){ </li></ul><ul><li> sExc.printStackTrace(); </li></ul><ul><li> }catch(RemoteException rExc){ </li></ul><ul><li> rExc.printStackTrace(); </li></ul><ul><li> } </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  26. 26. An Example <ul><li>java org.apache.axis.utils.tcpmon </li></ul>
  27. 27. Documentation <ul><li>The JAX-WS 2.0 specification demands that the exception annotated with @WebFault must have two constructors and one method: </li></ul><ul><li>WrapperException(String message, FaultBean faultInfo) WrapperException(String message, FaultBean faultInfo, Throwable cause) FaultBean getFaultInfo() The WrapperException is replaced by the name of the exception, and FaultBean is replaced by the class name that implements the fault bean. The fault bean is a Java bean that contains the information of the fault and is used by the Web service client to know the cause for the fault. </li></ul><ul><li>Sample </li></ul><ul><li>@javax.xml.ws.WebFault(name=&quot;AddNumbersException&quot;,     targetNamespace=&quot; http:// server.fromjava/jaxws &quot;) public class AddNumbersException_Exception extends Exception {     private fromjava.client.AddNumbersException faultInfo;     public AddNumbersException_Exception(String message, AddNumbersException faultInfo) {         super(message);         this.faultInfo = faultInfo;     }     public AddNumbersException_Exception(String message, AddNumbersException faultInfo,                                          Throwable cause) {         super(message, cause);         this.faultInfo = faultInfo;     }     public AddNumbersException getFaultInfo() {         return faultInfo;     } } </li></ul>
  28. 28. Documentation <ul><li>HandlerChain </li></ul><ul><li>Example: </li></ul><ul><li><?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?> </li></ul><ul><li><javaee:handler-chains xmlns:javaee= http:// java.sun.com/xml/ns/javaee xmlns:xsd= &quot;http://www.w3.org/2001/XMLSchema&quot;> </li></ul><ul><li><javaee:handler-chain> </li></ul><ul><li><javaee:handler-chain-name>Service Framework Handlers</javaee:handler-chain-name> </li></ul><ul><li><javaee:handler> </li></ul><ul><li><javaee:handler-name>LoggingHandler</javaee:handler-name> </li></ul><ul><li><javaee:handler-class> com.test.handlers.LoggingHandler </li></ul><ul><li></javaee:handler-class> </li></ul><ul><li></javaee:handler> </li></ul><ul><li><javaee:handler> </li></ul><ul><li><javaee:handler-name>ThrottlingHandler</javaee:handler-name> </li></ul><ul><li><javaee:handler-class> com.test.handlers.ThrottlingHandler </li></ul><ul><li></javaee:handler-class> </li></ul><ul><li></javaee:handler> </li></ul><ul><li></javaee:handler-chain> </li></ul><ul><li></javaee:handler-chains> </li></ul>
  29. 29. Documentation <ul><li>HandlerChain </li></ul><ul><li>Example: </li></ul><ul><li>Handler Interface </li></ul><ul><li>public class LoggingHandler implements SOAPHandler<SOAPMessageContext> </li></ul><ul><li>public boolean handleFault(SOAPMessageContext context) </li></ul><ul><li> public boolean handleMessage(SOAPMessageContext context) </li></ul><ul><li> public Set<QName> getHeaders() </li></ul>
  30. 30. Documentation <ul><li>Annotations: </li></ul><ul><li>JSR 181 (Web Services Metadata) Annotations </li></ul><ul><li>2.1 javax.jws.WebService </li></ul><ul><li>2.2 javax.jws.WebMethod </li></ul><ul><li>2.3 javax.jws.OneWay </li></ul><ul><li>2.4 javax.jws.WebParam </li></ul><ul><li>2.5 javax.jws.WebResult </li></ul><ul><li>2.6 javax.jws.HandlerChain </li></ul><ul><li>2.7 javax.jws.soap.SOAPBinding </li></ul><ul><li>3. JSR 224 (JAX-WS) Annotations </li></ul><ul><li>3.1 javax.xml.ws.BindingType </li></ul><ul><li>3.2 javax.xml.ws.RequestWrapper </li></ul><ul><li>3.3 javax.xml.ws.ResponseWrapper </li></ul><ul><li>3.4 javax.xml.ws.ServiceMode </li></ul><ul><li>3.5 javax.xml.ws.WebEndpoint </li></ul><ul><li>3.6 javax.xml.ws.WebFault </li></ul><ul><li>3.7 javax.xml.ws.WebServiceClient </li></ul><ul><li>3.8 javax.xml.ws.WebServiceProvider </li></ul><ul><li>3.9 javax.xml.ws.WebServiceRef </li></ul><ul><li>4. JSR 222 (JAXB) Annotations </li></ul><ul><li>4.1 javax.xml.bind.annotation.XmlRootElement </li></ul><ul><li>4.2 javax.xml.bind.annotation.XmlAccessorType </li></ul><ul><li>4.3 javax.xml.bind.annotation.XmlType </li></ul><ul><li>4.4 javax.xml.bind.annotation.XmlElement </li></ul>
  31. 31. Documentation <ul><li>URLs </li></ul><ul><li>http://today.java.net/pub/a/today/2006/09/19/asynchronous-jax-ws-web-services.html </li></ul><ul><li>http://java.sun.com/webservices/docs/2.0/tutorial/doc/ </li></ul><ul><li>http://ws.apache.org/axis/java/user-guide.html#Introduction </li></ul>
  32. 32. Thank You!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×