Loading

How to set basic authentication for an exposed SOAP web service using spring module in Studio app

게시 일자: Aug 5, 2025
과업

GOAL

To setup basic authentication in HTTP listener via spring module for an exposed soap web service which was created using APIKit for SOAP in Studio app and then test the endpoint via Soap UI

PREREQUISITES

Create soap web service using APIKit for SOAP - Refer https://docs.mulesoft.com/apikit/4.x/apikit-4-soap-project-task
단계
1. Refer "Tutorial - how to create a simple Mule 4 http basic authentication application" https://help.mulesoft.com/s/article/Tutorial-how-to-create-a-simple-Mule-4-http-basic-authentication-application
Note: Few things are changed from the steps mentioned in this article.
1a. Updated spring security to http://www.springframework.org/schema/security/spring-security-5.4.xsd" from beans.xml as it was required.
1b. 
For Spring framework 5.x, default password encoder changes from NoOpPasswordEncoder to BCryptPasswordEncoder, it is necessary to add prefix {noop} before password. Further documents are available at Spring Security Reference and Spring module - Mule 4

2. Include the HTTP basic authentication code before the SOAP Router

User-added image

3. Test soap endpoint from soap UI.

Note: Before testing the endpoints in soap UI, Enable preemptive authentication.
preemptive authentication means that the server expects that the authorization credentials will be sent without providing the Unauthorized response. This reduces the load on network and the server itself.

Soap UI > Preferences > HTTP Settings > To enable preemptive authentication, select the Authenticate preemptively check box.

soapUI request without basic auth credentials:

User-added image

Log without basic auth credentials:

********************************************************************************

WARN 2022-08-18 15:28:34,604 [[MuleRuntime].uber.14: [expose-soapapi_poc].uber@org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource.lambda$null$16:412 @5d1ae385] [processor: ; event: ] org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'api-main' successfully reconnected

ERROR 2022-08-18 15:28:44,259 [[MuleRuntime].uber.14: [expose-soapapi_poc].api-main.CPU_LITE @2e360464] [processor: api-main/processors/0; event: ae870e50-1ef9-11ed-b4b0-88665a282a6f] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:

********************

Message : Registered authentication is set to HTTP basic authentication but there was no security context on the session. Authentication denied on connector HTTP listener

Element : api-main/processors/0 @ expose-soapapi_poc:expose-soapapi_poc.xml:24

Element DSL : <http:basic-security-filter realm="mule"></http:basic-security-filter>

Error type : HTTP:BASIC_AUTHENTICATION

FlowStack : at api-main(api-main/processors/0 @ expose-soapapi_poc:expose-soapapi_poc.xml:24)

(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

********************

********************************************************************************

soapUI request with basic auth credentials:

User-added image

 

Log with basic auth credentials:

********************************************************************************

INFO 2022-08-18 15:28:54,317 [[MuleRuntime].uber.13: [expose-soapapi_poc].api-main.BLOCKING @aaf909d] [processor: api-main/processors/3; event: b4634cd0-1ef9-11ed-b4b0-88665a282a6f] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Basic Authentication Implemented Successfully.

********************************************************************************

ADDITIONAL INFORMATION:

Attached a sample application for reference.

Disclaimer 1: This solution provides a suggestion that should be considered in conjunction with your specific use case and requirements and does not represent a complete solution for all circumstances.
Disclaimer 2: This example is provided as a reference for your own usage and it's not part of the official MuleSoft product so its use will be considered as a custom implementation made by MuleSoft customers.


 
Knowledge 기사 번호

001116432

 
로드 중
Salesforce Help | Article