Sitemap
Fernando Harris

Fernando Harris

Just sharing what I learn! :)

Java Webservice with Basic Authentication

3 min readJul 5, 2020

In a RestFul microservice World, moved by JSON, gRFC and other fancy, light protocols, SOAP became the ugly duck.

But that doesn’t mean that many of its positive traits are no longer valid.

For those, still running new and legacy systems in Weblogic or other Java Application Servers, the exercise below is very simple and can be very useful.

First step, open your Eclipse JEE and create a new Project:

Press enter or click to view image in full size

In the wizard choose the Oracle folder. Make sure you have installed it beforehand in your Eclipse.

Press enter or click to view image in full size

Define your project like this

Press enter or click to view image in full size

Click Next. Leave it like this…

Press enter or click to view image in full size

Don’t forget to generate the web.xml descriptor file:

Press enter or click to view image in full size

Click Finish and Wait:

Press enter or click to view image in full size

When generated, you should have something like this:

Press enter or click to view image in full size

From the Java Resources src folder, generate a new Weblogic Web Service:

Press enter or click to view image in full size

Create your new webservice:

Press enter or click to view image in full size

With No policies and Finish:

Press enter or click to view image in full size

You should get something like this:

Press enter or click to view image in full size

Make this changes in your class:

Press enter or click to view image in full size

Click the method name and the parameter if you want to generate annotations automatically:

Press enter or click to view image in full size

Now, lets add the Basic Authentication part.

Get Fernando Harris’s stories in your inbox

Join Medium for free to get updates from this writer.

Edit your web.xml

Press enter or click to view image in full size

And weblogic.xml

Press enter or click to view image in full size

The principal-name in the weblogic.xml should represent a User or Group that you already have created in Weblogic:

Press enter or click to view image in full size
Press enter or click to view image in full size

Now , you can export your webservice as an EAR and deploy it in Weblogic.

When finished, in Weblogic you can obtain the WSDL from the Testing folder:

Press enter or click to view image in full size

After that you just need to test it with SOAP UI.

First test without Authentication is unsuccessful :

Press enter or click to view image in full size

Second try, this time with Basic Authentication in place is successful :

Press enter or click to view image in full size

That’s it.

--

--