WebServices in WebLogic

Web services are de facto standards in today’s internet world. They use XML-based standards and transport protocols to exchange data with clients.

The below post gives a brief understanding of the webservices in WebLogic Service.

Before moving on with a sample WebServer demonstration, lets understand the structure of the WebLogic WebService Container.

WebLogic WebService container implements the JAX-WS 2.1 specification and provides built in WS-1 Basic Profile inter-operablity support. Facilitates the processing of the SOAP requests and response. It is integrated with WebLogic Server Security to provide WS security standards like WS-Security and SAML tokens.

WebLogic Web Service container looks like below.

The web services container provides two transport mechanisms for invoking web services:

  1. SOAP over HTTP and
  2. SOAP over JMS.

 

Follow the below steps to create a sample Web Service using IDE:

1. Create a WebService project in IDE:

Open your IDE (Eclipse), then create a WebService project

2: Create JWS (Java Web Service) file:

Create the JWS file that implements the Web Service using the @webservice annotation.


import javax.jws.*;

@WebService(serviceName="HelloWorldService" , name="HelloWorldPortType")


public class HelloWorldImpl {

@WebMethod public void hello()
{
System.out.println("*** Sample Test WebService Application ***");
}

public String sayHelloWorld(String message)
{
try
{
System.out.println("sayHelloWorld:" + message);
}

catch (Exception ex)
{
ex.printStackTrace();
}

return "Here is the message: '" + message + "'"; } }

 

 

Note:  @WebService annotation at the beginning that tells the Java interpreter that you intend to publish the methods of this class as a web service.

The @WebMethod annotation customizes a method that is exposed as a web service operation. The associated method must be public.

3: Deploy the WebService:

Clean and build the project, then run the Web Service on the server.

4: Test the WebService:

Test that the Web Service is deployed correctly by invoking its WSDL in your browser:

http://host:port/HelloWorldImpl/HelloWorldService?WSDL

You construct the URL using the default values for the contextPath and serviceUri attributes. The default value for the contextPath is the name of the Java class in the JWS file.

A typical WSDL file would look like below.

You can also create a WebService using ant task jwsc,

Refer the below example for the same using ant  script.

http://download.oracle.com/docs/cd/E13222_01/wls/docs103/webserv/use_cases.html#wp241983

Note: You can invoke the WebService using a standalone client or a Web Application.

Refer the below link for the same.

http://download.oracle.com/docs/cd/E13222_01/wls/docs103/webserv/use_cases.html#wp244847

Regards,

Wonders Team 🙂

 

3 comments

  1. Good post, though it only appears to deal with a contract last (code first) approach. I would be interested to see a post related to contract first web services where the xsd/wsdl is fixed.

  2. Hi sir,

    i want to set any alert as mail to my mail id when the servers are overloaded state and shutdown state. can you help me on this please.

    Regards,
    Siddartha

Comments are closed.