03 – HelloWorld WebService

In this tutorial I’ll show you, how to implement your first webservice in Oracle SOA Suite using Mediator component. Additionaly you will learn how to create XSD files, deploy SOA Composite Application to SOA Server and test it.

Create SCA (SOA Composite Application)

To create new SOA Application project go to Menu->File->New From Gallery->SOA Application.

Menu_004

Zaznaczenie_003

Choose the application name and package prefix and click next.

Zaznaczenie_005

Enter project name and go next.

Zaznaczenie_007

On the last step choose Empty Composite and click Finish.

Zaznaczenie_008

After the completion of processing you see SOA Project(if not, double click ST03HelloWorldProject from project tree).

The left side “Exposed Services” is what our service expose. It might be WebService, JMS or Database QA Adapter, listening on directory, Event and much more. In other words it’s entry point/trigger/external interface of composit.

The right site “External References” is what external resources our composit may use ie. other service, database adapter, directory.

In the middle is a place for internal logic Components.

Zaznaczenie_009

Create contract

There is unwritten principle in SOA – “contract first”. It means first define the contract of your service then implement it.

The first step is to create XML Schema (XSD) describes input and output of the service. Create XML Schema file HelloWorld.xml in Schemas directory.

Menu_010

Zaznaczenie_011

Enter the file name “HelloWorld.xsd” , namespace “http://better-coding.com/soa/tutorial03” and prefix “bcst3”.

Zaznaczenie_013

Click OK.

Zaznaczenie_012

Now using “complexType”, “sequence” and “element” try to design request and response structure as below.

Zaznaczenie_014

In case of trouble just past inside source tab.

Create Mediator component

Mediator is a compotent that allows routing and transforming messages. We use it to implement HelloWorld service.

Go to project diagram. Drag Mediator component and drop into Components diagram.

Enter “HelloWorldMediator” as name  and select “Interface Definition from WSDL” then click “Generate…” icon.

Zaznaczenie_016

Enter “helloworld_ptt” (1) as Port Type and “hello” as operation name(2). Then add input message(3). Enter “request” as part name (4) and choose helloWorldRequest Type from schema (5,6,7).

Zaznaczenie_018

Do the same for response and click ok.

Zaznaczenie_020

Zaznaczenie_021

Zaznaczenie_022

As you can see our composite exposes HelloWorldMediator web service with hello operation.

Service implementation using mediator

Edit mediator component. Double click on it, choose from project structure od right click and edit.

s03

Click Add and the “Echo Reply”. Click OK.

Zaznaczenie_025

Click “Assign icon”, then “Assign Source Expression…” and enter the expression:

Zaznaczenie_027

Click OK, and connect expression value to output message:

Menu_029

Zaznaczenie_045

Click ok and save All. Out service is ready for deploy and test.

Deploy SCA to SOA Server

Ensure your SOA Server is running.

Right click on project -> Deploy -> ST03HelloWorldProject. Deploy to Application Server. Next.

Menu_033

Zaznaczenie_034

Mark “Overwrite any existing composites…” and click next.

Obszar 1_035

Choose CompactDomain and click Next. Then select AdminServer and click Next and Finish.

Zaznaczenie_036

Zaznaczenie_038

Zaznaczenie_039

If everything was ok, you will see “Deployment Finished” message.

Zaznaczenie_040

Testing

In this part I’ll show you how to test deployed Web Service from Oracle Enterprise Manager. If you want you can do this using ie SoapUI.

LogIn into Oracle EM: http://localhost:7001/em using weblogic/welcome1 as user and password.

Zaznaczenie_041

Go to ST03HelloWorldProject SCA(1,2,3) and click Test(4).

Zaznaczenie_043

As you can see the WSDL is:

Fill the request message and click “Test Web Service”.

Zaznaczenie_044

Check the response.

Zaznaczenie_046

Our first service works fine. In the next parts of this tutorial I’ll show you how to create complex services, BPEL processes and debugging.

Facebooktwittergoogle_plusredditlinkedinmail

Leave a Reply

Feel free to ask me about anything!

Notify of
avatar
wpDiscuz