Thursday, February 13, 2020

12c SOA - WS Security - expose service with header and WSSE user token authentication

  • WS-Security is a specification published by OASIS, it is mainly aimed for SOAP Web Services. It encompasses a number of mechanisms to strengthen the integrity and confidentiality of the messages exchanged between these type of services such as data encryption, security tokens, username and password validation, signed messages, etc.
  • On the other hand, Oracle Web Service Manager (OWSM) is a component of Oracle SOA Suite that provides a framework for centralizing policy management and security of Web Services. OWSM is based on the WS-Policy standard and can be used in development time, or from the management console.
  • For the SOAP Service the username and password will travel in the UsernameToken element embedded within the SOAP Envelope message Header, and for the REST service, it will travel in the HTTP transport Header.
Here you will find how to configure from a development perspective using JDeveloper, a policy-based user and password authentication for a SOAP.


Step1: Create a Schema:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="" xmlns="http://www.emp.test"
            targetNamespace="http://www.emp.test" elementFormDefault="qualified">
    <xsd:element name="EmployeeRequest">
                <xsd:element name="EmpId" type="xsd:string"/>
                <xsd:element name="EmpName" type="xsd:string"/>
                <xsd:element name="Address" type="xsd:string"/>
        <xsd:element name="EmployeeResponse">
                <xsd:element name="result" type="xsd:string"/>
    <xsd:element name="requestHeader">
            <xsd:element name="User" type="xsd:string" minOccurs="0"/>
            <xsd:element name="Id" type="xsd:string" minOccurs="0"/>

Step2: Create a WSDL:
Right click on project folder WSDLs⇾New⇾From Galary⇾All Items⇾WSDL(builder)(Interfaces)⇾OK⇾Provide Service Name,Port type, operation and choose Interface Type as Synchronous and Add the message part(Request and Header) in the Input and Response in the Output sections.

<?xml version= '1.0' encoding= 'UTF-8' ?>
<wsdl:definitions name="service1"
                  xmlns:inp1="http://www.emp.test" xmlns:wsdl=""
        <xsd:schema xmlns:xsd="">
            <xsd:import namespace="http://www.emp.test" schemaLocation="../Schemas/EMP.xsd"/>
    <wsdl:message name="requestMessage">
        <wsdl:part name="requestHeader" element="inp1:requestHeader"/>
        <wsdl:part name="paylod" element="inp1:EmployeeRequest"/>
    <wsdl:message name="replyMessage">
        <wsdl:part name="payload" element="inp1:EmployeeResponse"/>
    <wsdl:portType name="execute_ptt">
        <wsdl:operation name="execute">
            <wsdl:input message="tns:requestMessage"/>
            <wsdl:output message="tns:replyMessage"/>
    <wsdl:binding name="execute_pttSOAP11Binding" type="tns:execute_ptt">
        <soap:binding style="document" transport=""/>
        <wsdl:operation name="execute">
            <soap:operation style="document"
                <soap:body use="literal" parts="paylod"/>
                <soap:header message="tns:requestMessage" use="literal" part="requestHeader"/>
                <soap:body use="literal" parts="payload"/>

Step3: Create a BPEL service based on the above WSDL:

Step4: Configure SOA WS Policies...

Step5: Deploy and take the wsdl and test from SOAP UI:

Test1: Tested without WSSE Security user token authentication:
 Test2: Tested with WSSE Security user token authentication:
Payload with WSSE:
<soapenv:Envelope xmlns:emp="http://www.emp.test" xmlns:soapenv="">
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="" xmlns:wsu="">
         <wsse:UsernameToken wsu:Id="UsernameToken-81CB99D5C318DB117215815725859457">
            <wsse:Password Type="">wsstest1</wsse:Password>
            <wsse:Nonce EncodingType="">j05VdqxZ2sVIdPjZiGKi5Q==</wsse:Nonce>

No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...