1 / 48

Web Services in WebLogic Server

Web Services in WebLogic Server. Tom Purcell Chariot Solutions LLC. Agenda. In this presentation, we'll discuss Distinguishing features of WebLogic 7.0 Exposing EJBs as web services in WebLogic 7.0 Invoking web services from applications running in WebLogic 7.0. About Tom Purcell.

levi
Download Presentation

Web Services in WebLogic Server

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Services in WebLogic Server Tom PurcellChariot Solutions LLC

  2. Agenda • In this presentation, we'll discuss • Distinguishing features of WebLogic 7.0 • Exposing EJBs as web services in WebLogic 7.0 • Invoking web services from applications running in WebLogic 7.0

  3. About Tom Purcell • Enterprise Architect with Chariot Solutions • Published articles… • Presented at JavaOne 2003… • Runs the DVBUG… • In IT since 1985… • tpurcell@chariotsolutions.com

  4. About Chariot Solutions • Information Technology provider focused on automating business processes • Team of leading Java architects on staff • Technical expertise in software architecture and development, and systems integration • Proven track record with companies such as ExxonMobil, Midas, Rosenbluth International, UGI Utilities, and the State of New Jersey

  5. Introduction to WebLogic 7

  6. Distinguishing Features • Installation (easy via a wizard) • Domains (configuration groups) • Startup (easy via provided script) • Deployment (copy EAR into deploy dir) • Management (nice web interface) • Extensions to J2EE (clustering, web services, etc.)

  7. Installation • BEA offers both a “network install” which downloads features on demand, and a regular full installer package (200MB) • You can download the “platform” (includes Portal, Integration, Workshop products) or just the Server • Downloads come with 1-year, 5-client-IP, 15-DB-connection development license • Can get the JRockit JVM with it

  8. Installation, cont. • Installer includes a JVM • You will be prompted for a “BEA Home Directory” where it stores the license, etc. • The products are installed to a separate dir, though default is under BEA Home • After the product install, you can run the “configuration wizard” to set up domains (without a domain, you can only run the demos – more on this later)

  9. Installation Screen Shots

  10. Installation Screen Shots

  11. Domains • WebLogic groups configuration settings into “domains” • Each domain has its own set of server configuration info, its own deployed applications, etc. • Each domain runs in a different JVM • Several server instances can be grouped into a single domain to share applications, resources, etc.

  12. A Development Domain • Contains a single server instance (the “admin server” • Is your typical standalone development or QA server

  13. A Clustered Domain • Contains a single “admin server” instance to manage all the other instances • Contains one or more “managed servers”, which are dumb and just obey the admin server • All administration and deployment is initiated through the admin server • Typically the application runs only on the managed servers (the admin server is dedicated to administration) • Admin server often doesn’t need a license

  14. Creating a Domain • Done through the “configuration wizard” • This wizard can be run at the end of the installation routine • Can also be run from the Start menu, or the weblogic7/common/bin directory • Wizard prompts for things like, should it be a standalone server or an admin server with managed servers

  15. Configuration Wizard Screen Shots

  16. Configuration Wizard Screen Shots • Each domain that will be run simultaneously should have different listen ports (most traffic goes over these ports)

  17. Configuration Wizard Screen Shots • An administrative account must be created; this username and password must be provided to start the server

  18. Configuration Wizard Screen Shots

  19. Domain Directory • Domain directory contains: • Startup scripts (startWebLogic.cmd / .sh) • Configuration file (config.xml) • Subdirectory for deployments (applications/) • Subdirectory for logs (logs/) • Environment configuration scripts (to add WebLogic tools to PATH/CLASSPATH, etc. named setEnv.cmd / .sh) • Various other config files

  20. Customizing the Startup Script • Environment variables to set in the script: • Set the admin user/password so no login is required to start the server set WLS_USER=… set WLS_PW=… • Set “development mode” so any applications in the application/ directory are auto-deployed set STARTMODE=false • Add things (JDBC drivers) to the CLASSPATH set POST_CLASSPATH=foo.jar;…

  21. Starting the Server • Run the startWebLogic script to start the server, or use the Start menu entry

  22. Deploying Applications • If the server is set for development mode, copy the application to applications/ dir • Otherwise, use the deployment function in the management console • You can deploy an EJB JAR, WAR, RAR, EAR, or an expanded directory structure laid out like any of those • In development mode, updating the files under applications/ will redeploy

  23. Management • All management is done through the “console” web application • It has a tree view on the left with available resources, application modules, etc. • Click something on the left, and you get detailed information and options in the area to the right • http://localhost:7001/console/

  24. Console Screen Shots

  25. WebLogic’s Extensions to J2EE • Clustering • Web Services • JMS Bridge (lets 2 JMS implementations pass messages back and forth) • Guesses about CMP’s future

  26. Web Services

  27. Why Web Services? • Interoperability • hardware platforms • programming languages • applications • business partners • Alternatives • CORBA • RMI • Proprietary protocols (XML, binary, etc.)

  28. What Are Web Services? • Generic protocol, transport • For today's discussion • SOAP 1.1 (1.2 in not out) • WSDL 1.1 • HTTP or HTTPS • JAX-RPC • Registry services • UDDI 2.0

  29. What Does WebLogic Support? • WebLogic 6.1 • First release with web services support • Tools to generate web services servlet/JSP code for stateless session EJBs and JMS destinations • Crippled tool to generate client code to invoke web services • No standards-based support

  30. What Does WebLogic Support? • WebLogic 7.0 • Improved web services support • Deployment Descriptor-based web services support • Tool to generate client code to invoke any web service (based on WSDL) • JAX-RPC support • WebLogic 8.0 ? • J2EE 1.4/EJB 2.1 web services support

  31. Overview of Examples • For the rest of the presentation, we'll dig into the code and procedures • There are no particular WebLogic Console configuration requirements • Expose existing EJB 2.0 CMP application • Important: WebLogic client libraries can be freely redistributed

  32. WebLogic 7.0 Web Services • More options for what backs the web services (individual EJB methods, etc.) • Supports additional data types • Can interact with SOAP messages • Client need not receive a response • Generates JAX-RPC clients from WSDL • Quick-start tool from WSDL • Uses web services DD • Examples use WebLogic 7.0 SP4

  33. WL7.0: Architecture WAR SOAP Handler Chain EJB JAR Client web-services.xml Session Beans ? SOAP Handler Chain

  34. WL7.0: Developing the EJB • Still can't expose overloaded methods • You can generate or code custom XML serializers for unknown data types (such as Java Beans) • Additional built-in types include: byte/Byte, char/Character, BigInteger, Calendar

  35. WL7.0: Easy Packaging Tool • Create an EJB JAR like normal • Run the setEnv script to set environment, add webserviceclient.jar to CLASSPATH • Run an Ant script with servicegen to create an EAR from an EJB JAR • Deploy the EAR • servicegen has loads of options, but still doesn't integrate well into an existing application

  36. WL7.0: servicegen Ant Script <servicegen destEar="example-servicegen.ear" contextURI="examples" > <service ejbJar="example-ejbs.jar" targetNamespace="java:mypackage.name" serviceName="Bean1" includeEJBs="Bean1" serviceURI="/web-services/bean1" generateTypes="True" expandMethods="True" style="rpc" > <client packageName="com.chariotsolutions.example"/> </service> </servicegen>

  37. WL7.0: Advanced Packaging • Procedure • Develop and package the EJBs • Create the web-services.xml deployment descriptor • Package the WAR, including web.xml for security, and classes for SOAP handlers • Package the EAR, including EJB JARs and WAR • Build the client code

  38. WL7.0: web-services.xml <web-services> <web-service name="Bean1" targetNamespace="java:mypackage.name" uri="/web-services/bean1"> <components> <stateless-ejb name="Bean1"> <ejb-link path="example-ejbs.jar#Bean1" /> </stateless-ejb> </components> <operations> <operation method="saySomething" component="Bean1" /> </operations> </web-service> </web-services> (See sample)

  39. WL7.0: More web-services.xml • Use embedded XML schemas with namespaces to identify custom data types (see also the autotype Ant task) • Use method parameters to support in/out parameters • Use method of “ * ” to support all methods on an EJB • Specify one-way operations • Specify SOAP handlers

  40. WL7.0: Package WAR & EAR • web-services.xml goes in WEB-INF/ in the WAR • SOAP handler classes go in WEB-INF/lib or WEB-INF/classes • Security, WSDL URL aliasing goes in web.xml • No need for EJB refs in web.xml • EAR needs references to WAR and EJB JARs like before (application.xml)

  41. WL7.0: Deploy EAR • Deploy the EAR like normal • Web services appear in the Console under Deployments/Web Services Components • Use these URLs to access the web services and WSDL: http://localhost:7001/examples/web-services/bean1 http://localhost:7001/examples/web-services/bean1?WSDL

  42. WL7.0: Client Code • Run setEnv script, add webserviceclient.jar • Generate client code from the WSDL using the clientgen Ant task <clientgen wsdl="c:/examples/src/web/bean1.wsdl" serviceName="Bean1" packageName="com.chariotsolutions.example.client" clientJar="c:/examples/dist/bean1-client.jar" /> • Can also specify a normal URL for the WSDL

  43. WL7.0: Coding a Client • Add webserviceclient.jar and client JAR to CLASSPATH • Configure JAXM/JAX-RPC system properties • Use the generated classes to invoke the Web Service • Or, use a much more complicated process to dynamically interact with arbitrary web services based on WSDL

  44. WL7.0: Client Code System.setProperty("javax.xml.soap.MessageFactory", "weblogic.webservice.core.soap.MessageFactoryImpl"); System.setProperty("javax.xml.rpc.ServiceFactory", "weblogic.webservice.core.rpc.ServiceFactoryImpl"); ... Bean1_Impl stub = new Bean1_Impl(); Bean1Port bean = stub.getBean1Port(username, password); String response = bean.saySomething(); System.out.println("Bean1 said: "+response); • This client will work against the service deployed in WebLogic 6.1 or 7.0!

  45. Conclusions • WebLogic 6.1 provides basic web services, but limited client generation • WebLogic 7.0 provides lots of options, but taking full advantage makes it extremely difficult to configure • WebLogic 7.0 is nearly fully Ant-script-able from client to server (WSDL?) • EJB 2.1 will be greatly appreciated when it arrives

  46. A Final Thought How can web services ease integration challenges today?

  47. Questions?

  48. http://www.chariotsolutions.com/ tpurcell@chariotsolutions.com

More Related