1

Basically it is an extension of my previous question: How to read REST service that returns JSON object and store the same into PostgreSQL using Mule ESB, Mule Studio

I have some REST services being running at "http://localhost:35798/RestServiceImpl.svc/json/567"

Now in order to access those services, I need to authenticate as admin. The credentials are

User Name: admin

Password: pwd

The flow (existing) should be able to handle authentication & establish session via REST.

How to do authentication using Mule? The flow will stop if authentication fails. Else after successful authentication, it will read the REST service and will insert the data into PostgreSQL.

halfer
  • 19,824
  • 17
  • 99
  • 186
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173

1 Answers1

2

Put the credentials in the outbound endpoint URI:

http://admin:pwd@localhost:35798/RestServiceImpl.svc/json/567

You can of course use properties to avoid hard-coding them in the Mule config:

http://${rest.admin.username}:${rest.admin.password}@localhost:35798/RestServiceImpl.svc/json/567
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Did you mean to say in "http:rest-service-component" I should put?(http://stackoverflow.com/questions/14003046/how-to-read-rest-service-that-returns-json-object-and-store-the-same-into-postgr/14024632#comment19412046_14024632) – priyanka.sarkar Jan 03 '13 at 17:35
  • Yes use that in the service URL. – David Dossot Jan 03 '13 at 17:36