Sunday 25 December 2011

Baby steps. Adding Weblogic App Server in Eclipse

We are going to explore how we can add Weblogic Application Server in Eclispe IDE. We are using:



Ok. Let's Start. 
  • Start up your Eclipse IDE and switch to J2EE Perspective:


  • By the bottom of the screen you will find the "Servers" tab. Click it.


  • Right click in the blank space within the tab and choose new->server.


  • In the dialog that pops up, expand the Oracle server type and choose Oracle Weblogic Server 11gR1 PatchSet 4. Hit Next. 
    (Note:- We choose 11gR1 PatchSet 4 as the server adapter because we have this particular server installed. If your server is different, you need to choose the different version of the adapter here.)

  • Chances are that when you hit next, the wizard looks for and finds the actual server in your system and populates it it the appropriate boxes. However if it does not, choose the browse button next the the field "Weblogic home" and choose your server.
  • For java home, choose either jrockit, which comes with Weblogic and is tuned for production environments or you may choose any other JVM.




  • Click next and finish in the subsequent screens and you are done with the configuration. To test it, you can right click on the newly added server and hit Start







  • Done. Thank you.

Saturday 24 December 2011

Baby steps. Creating a simple web service in Eclipse/Weblogic/Java

We will be using Weblogic Application Server and Eclipse to develop a very simple Web Service. 
This tutorial serves two purposes:
  1. Clarifies some basic ideas about creating a web service.
  2. You can use it to create provider services for our OSB, ESB, BPEL examples.
So, lets get started. (Download source code here: Source Code (Eclipse Project)

This tutorial assumes that you already have Weblogic 11g installed in your system. You should also be having Eclipse installed in your system.

  • Start your Weblogic server. You need to click this:



  • Now start your Eclipse IDE. In my system, I have one shortcut in desktop.
  • Select File -> New -> Other


  • Select Web -> Dynamic Web Project


  • Give a suitable Project name and Choose to put it into an EAR project(optional).


  • Keep clicking next and finish. If all goes well, you will end up having a Web Project and an Enterprise Application in your workspace:


  • Right click on your dummy web project and click New-> Folder. Name it, say, resources. We will use it to keep our web service artifacts like xsd and wsdl.
  • Right click on your "resources" folder and select New->Other. Then in the dialog, select XML -> XML Schema. Click Next, give a suitable file name and hit Finish. You will have your XSD file opened in the default editor. Use this step twice to create two files, say, provider_req.xsd and provider_resp.xsd.
  • Here is how your request xsd will look like:




  • And here is how our response xsd will look like:



  • Again right click on your resources folder and do a New -> Other to open the dialog. Here choose Web Services -> WSDL and click Next. Give it a name, say, shipmentOrderSrvc.wsdl and click next. In the following screen, choose as shown in the following img. Remember to change the namespace.



  • You will have the wsdl file opened in your workspace. The file is big so the following screenshots split the whole wsdl in several parts:
  • Namespace declarations:



  • The types section of the wsdl:






  • The abstract part of the wsdl:





  • The concrete part of the wsdl:







  • The whole wsdl(sections shrinked):





  • To learn more about xsd and wsdl, please visit w3schools.com .
  • At this point you need to start your server, either from within Eclipse or separately from outside. If you wish to start your server from eclipse, you need to configure it first. These steps can help  http://simplifiedsoa.blogspot.com/2011/12/baby-steps-adding-weblogic-app-server.html :
  • Once you have started the server, you need to create the Java stubs and other classes for your service. No worries, you can do this with right and left clicks only. 
  • Right click on the wsdl you just created. Then select New -> Other and from the dialog, choose Web services -> Web service. Clicking next will start the wizard.






  • In the New Web Serivce wizard, everything is straight forward:


(Note:- For both of the app server and web service runtime, you can choose different values, here we choose Weblogic + Axis as we are using Weblogic Server and Apache Axis comes a web service runtime with it.


  • Now hit finish. It will take some time before you have a big number of packages and classes created in your workspace, something like this:




  • Its a good idea to browse through the set of classes and observe how they are formed. Notice the package names; they are almost opposite to what your namespace was, right?
  • In your workspace, you will also find other new artifacts like these:



  • Before your start coding for your web service, and there is not much left for that :), you should have a look at each of these artifacts. They are pretty much self explanatory and will help you better understand the working of the system.
  • Ok. Straight to coding. Open up the file named ShipmentOrderSrvcSOAPImpl




  • So now that we have our code ready, lets not wait anymore. Startup your server and run your application.
  • Remember, you need to be in the J2EE perspective to find the "Servers" tab the bottom of the page. You will find the configured Weblogic server here. Right click and click start.




  • After the server starts, deploy your application. Right click on your application -> Run as -> Run on server:





  • You will see the dialog that will let you choose the app server. Choose it and hit finish.
  • It will take some time before your application gets deployed.
  • After deployment, open the generated wsdl file, i.e., this one:




  • After you open this file, scroll down to the bottom of it and you will find the endpoint, i.e., where your service can be found on the network. Copy it:




  • Open SoapUI. (This is a software you need to use to test your services. Its free and you can get it at soapui.com.)
  • Right click on projects and click new Project.





  • In the dialog that pops up, Enter the endpoint followed by ?wsdl in the Initial WSDL field. Hit Ok.



  • In the left panel, you will find something like this:



  • Double click Request1. It will bring up the SOAP request:



  • You need to put some dummy values in the above step.
  • Now hit the green arrow on the top left. Soon after that you will see the response in the adjoining right window:



  • Ok. We are done here. If you find some problem, just put a comment here and I will be back with some solution, if I can. :)


Thursday 22 December 2011

Creating a Weblogic Domain and starting OSB server. 11g

After successfully installing Weblogic server and OSB on it follow these steps to create the domain and start both the servers:

  • Click "Configuration Wizard" located in your start->programs menu.


  • You will get the following screen, where you have to choose "Create a new...":


  • On clicking next, you have to choose the deployable components of your domain. Use the following as a guideline:

(Note:- We are not choosing OWSM as that needs an RDBMS to be installed for the schemas. If you are having one RDBMS and want to use policy management, you can choose this)

  • Keep clicking next and give username, password etc. Until you face this error:


  •  Click "OK" and continue. On the next screen, choose all of the available items to configure:



  • Although we are interested in only the 3rd one, but choosing all will allow you to see what all things you can configure.
  • You can accept all the default settings except for this screen where you need to create a new Machine. Just click "Add" and accept the default values:


  • In the following screen, select the items in left pane and click the "-->" arrow to push them to the right pane.



  • Keep clicking "Next" and click "Create" on the last screen.
  • Once you are done with creating the domain, we need to start the server by clicking this:



  • Once you find the server running(by observing the console and finding out if the last printed line has "<RUNNING STATE>" in it), you need to start your OSB server.
  • Locate the following path in your system(where you have installed WLS and OSB, so it might be different in your system):

  • Spawn a command prompt and navigate to the path specified in the previous step.
  •   Now give the following command to start your osb server:
    startManagedWebLogic osb_server1 http://Ankur-PC:7001
    (Note:- The command is pretty helpful in nature, if you just type the command without the parameters, it hints you to what you should actually give as the other two parameters, and in fact the "http://ankur-pc:7001/" part will change in your system, which will be suggested by the command)

  • Done, thank you.