apache axis: a set of java tools for soap web services

8
Apache Axis: Apache Axis: A Set of Java Tools for A Set of Java Tools for SOAP Web Services SOAP Web Services

Post on 21-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Apache Axis: A Set of Java Tools for SOAP Web Services

Apache Axis:Apache Axis:

A Set of Java Tools for SOAP A Set of Java Tools for SOAP Web ServicesWeb Services

Page 2: Apache Axis: A Set of Java Tools for SOAP Web Services

What’s a SOAP web What’s a SOAP web service ?service ?• A remote resource that accepts and returns SOAP messages.A remote resource that accepts and returns SOAP messages.• SOAP messages are XML.SOAP messages are XML.• The XML sent to the resource describes an invocation of a method call : parameters The XML sent to the resource describes an invocation of a method call : parameters

and (optionally) their types and method name, and some metadata about the and (optionally) their types and method name, and some metadata about the message itself.message itself.

• The XML received from the resource describes the return value and the type, or The XML received from the resource describes the return value and the type, or exceptions, and some metadata about the message itself.exceptions, and some metadata about the message itself.

• A programming languages do the same thing with their syntax, but XML is weaker in A programming languages do the same thing with their syntax, but XML is weaker in readability and economy of expression.readability and economy of expression.

• XML can be described in a schema. Web service schemas are called WSDL and also XML can be described in a schema. Web service schemas are called WSDL and also define protocols ( e.g. http ) and a usually a URI. Schemas must define the types but define protocols ( e.g. http ) and a usually a URI. Schemas must define the types but the SOAP XML instance does not have too. the SOAP XML instance does not have too.

• Anything that is optional is implementation dependent and varies among resource Anything that is optional is implementation dependent and varies among resource providers.providers.

• Web services do not have to use SOAP, they do not have to use HTTP even. A SOAP Web services do not have to use SOAP, they do not have to use HTTP even. A SOAP web service does not require the HTTP protocol, but in practice it’s almost always web service does not require the HTTP protocol, but in practice it’s almost always used. used.

• SOAP is the standard that major vendors have agreed to, and can be expected to be SOAP is the standard that major vendors have agreed to, and can be expected to be supported by external systems.supported by external systems.

Page 3: Apache Axis: A Set of Java Tools for SOAP Web Services

Apache AxisApache Axis

• Hide implementation details of web services that talk SOAP :Hide implementation details of web services that talk SOAP :– Wrap Java methods and deploy them as web services. Wrap Java methods and deploy them as web services. – Create web service clients that accept and return Java objects.Create web service clients that accept and return Java objects.

• In the simplest case, the developer need never know that In the simplest case, the developer need never know that SOAP/XML/HTTP is being used. Axis does all the serialization SOAP/XML/HTTP is being used. Axis does all the serialization and protocol handling.and protocol handling.

• It is possible to customize for more complex cases with It is possible to customize for more complex cases with hooks provided by Axis. hooks provided by Axis.

• SOAP and WSDL are complicated, because they use XML SOAP and WSDL are complicated, because they use XML schemas with namespaces, and do serialization of java schemas with namespaces, and do serialization of java objects and primitives to and from mapped XML objects and primitives to and from mapped XML representations. Best let the tools do it.representations. Best let the tools do it.

• This is on purpose : SOAP was developed by MS to sell their This is on purpose : SOAP was developed by MS to sell their tools.tools.

• Fortunately a free set of tools was developed : Axis.Fortunately a free set of tools was developed : Axis.

Page 4: Apache Axis: A Set of Java Tools for SOAP Web Services

Create a Web Service in Create a Web Service in JavaJava• Set up server : add Axis servlet mapping Set up server : add Axis servlet mapping

to web.xml; make sure Axis in classpath.to web.xml; make sure Axis in classpath.• Write your classes and methods in POJ.Write your classes and methods in POJ.

– Use types that have built-in type mappings. Use types that have built-in type mappings.

• Can also generate a skeleton from a Java Can also generate a skeleton from a Java interface.interface.

• Write a deployment descriptor (*.wsdd).Write a deployment descriptor (*.wsdd).• Use the Axis admin client to deploy.Use the Axis admin client to deploy.• C’est tout !C’est tout !

Page 5: Apache Axis: A Set of Java Tools for SOAP Web Services

Create a Web Service ClientCreate a Web Service Client

• Two simplest options:Two simplest options:– Use the Service and Call classes.Use the Service and Call classes.– Generate code for proxies and stubs from a WSDL.Generate code for proxies and stubs from a WSDL.

• If its not a web service you have the source If its not a web service you have the source code for, you have to use the WSDL. Therefore code for, you have to use the WSDL. Therefore always generate and make available a WSDL always generate and make available a WSDL for your own web services. It defines the for your own web services. It defines the contract with your clients, and they can use contract with your clients, and they can use their tools to create the client code.their tools to create the client code.

Page 6: Apache Axis: A Set of Java Tools for SOAP Web Services

Code GenerationCode Generation

• Conveniently generate WSDL, client and Conveniently generate WSDL, client and server code from one Java interface. server code from one Java interface.

• Generated code is a skeleton for an Generated code is a skeleton for an implementation. You can focus on your implementation. You can focus on your business logic in your implementation business logic in your implementation without worrying about protocol details. without worrying about protocol details.

• All the usual pluses and minuses of All the usual pluses and minuses of code generation.code generation.

Page 7: Apache Axis: A Set of Java Tools for SOAP Web Services

Why Web Services ?Why Web Services ?

• Easier distributed computing.Easier distributed computing.• Move toward systems of software components with well defined Move toward systems of software components with well defined

interfaces that are able to easily plug-in ( and out ); modular, not interfaces that are able to easily plug-in ( and out ); modular, not monolithic, software systems without unnecessary coupling (= monolithic, software systems without unnecessary coupling (= “SOA”). Tight / inappropriate coupling makes brittle systems that “SOA”). Tight / inappropriate coupling makes brittle systems that cannot be evolved with changing conditions.cannot be evolved with changing conditions.

• Disparate systems need access to a particular piece of functionality. Disparate systems need access to a particular piece of functionality. Creating it as a service means it can be coded and maintained in one Creating it as a service means it can be coded and maintained in one place but still be available everywhere its needed. place but still be available everywhere its needed.

• The SOAP and Web Service specifications represent a consensus for The SOAP and Web Service specifications represent a consensus for allowing software components to be included in a computing allowing software components to be included in a computing environment and to be used, irrespective of physical location, environment and to be used, irrespective of physical location, operating system, programming language, etc. HTTP + XML removes operating system, programming language, etc. HTTP + XML removes barriers.barriers.

• May seem to introduce complexity but the tools can hide that. May seem to introduce complexity but the tools can hide that. Performance may be an issue ( due to serialization / de-serialization Performance may be an issue ( due to serialization / de-serialization to XML, network latency ) depending on how its used. to XML, network latency ) depending on how its used.

Page 8: Apache Axis: A Set of Java Tools for SOAP Web Services

Why Web Services ? cont. Why Web Services ? cont.

• Identify candidate services.Identify candidate services.– Discrete unit of work.Discrete unit of work.– More than one client.More than one client.– Clients can’t be constrained to one implementation language, platform, or server.Clients can’t be constrained to one implementation language, platform, or server.– Does something tricky that we only want to maintain in one place.Does something tricky that we only want to maintain in one place.– Does something that many clients need to do.Does something that many clients need to do.– Need flexibility to change other system components, uncouple them from Need flexibility to change other system components, uncouple them from

implementations and use generic interface instead.implementations and use generic interface instead.• Develop a service catalog.Develop a service catalog.• Get buy in by development teams – overcome “I can just hack it myself Get buy in by development teams – overcome “I can just hack it myself

much easier than dealing with all this stuff”. much easier than dealing with all this stuff”. • Good communication required. Silos won’t use services from other silos.Good communication required. Silos won’t use services from other silos.• ProblemsProblems

– Co-variant development and dependency loops.Co-variant development and dependency loops.– Additional testing, development environments. Integration environment needed.Additional testing, development environments. Integration environment needed.– Deployment issues between environments – must configure to use the right Deployment issues between environments – must configure to use the right

service for the given environment. Use a good configuration + deployment service for the given environment. Use a good configuration + deployment process.process.

– Monitoring and troubleshooting – may have to debug a process across different Monitoring and troubleshooting – may have to debug a process across different servers.servers.