- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
How to consume YAML Web Service using RESTFul Connector
Below is the information of our service available on Open Ldap.
role.php | Assign/remove role to/from ID | https://it.intra.sears.com/it/ds/api/role.php | YAML or JSON |
| YAML or JSON |
| ||||||||||||||||||||||||||||||||||
Sample invocation:--- %YAML:1.0 {"svc_uid": "rmroczk", "svc_pw": "xxx", | Sample result:--- %YAML:1.0 {"status": 0, "message": "OK"}or --- %YAML:1.0 {"status": 1, "message": "already a member"} |
So based on this information, I am configuring RESFul Web Service connector.
Content- Type & Accept both are set to - application/jason; charset-UTF-8, while running Test I am getting time out on UI & in logs I am getting below error.
2016-06-27 08:56:49.208 [WARN] org.mule.transport.jms.JmsMessageUtils:269 - Header: Content-Type is not compliant with JMS specification (sec. 3.5.1, 3.8.1.1). It will cause problems in your and other applications. Please update your application code to correct this. Mule renamed it to Content_Type
2016-06-27 08:56:49.211 [ERROR] org.mule.exception.DefaultMessagingExceptionStrategy:341 -
********************************************************************************
Message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jms://AFX.JMS.OUT, connector=ActiveMQJmsConnector
{
name=jmsConnector
lifecycle=start
this=6a08143f
numberOfConcurrentTransactedReceivers=1
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
, name='endpoint.jms.AFX.JMS.OUT', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ActiveMQTextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jms://AFX.JMS.OUT, connector=ActiveMQJmsConnector
{
name=jmsConnector
lifecycle=start
this=6a08143f
numberOfConcurrentTransactedReceivers=1
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
, name='endpoint.jms.AFX.JMS.OUT', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ActiveMQTextMessage (org.mule.api.transport.DispatchException)
org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
+ 0 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
2016-06-27 08:56:49.213 [ERROR] org.mule.exception.DefaultMessagingExceptionStrategy:341 -
********************************************************************************
Message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jms://AFX.JMS.OUT, connector=ActiveMQJmsConnector
{
name=jmsConnector
lifecycle=start
this=6a08143f
numberOfConcurrentTransactedReceivers=1
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
, name='endpoint.jms.AFX.JMS.OUT', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ActiveMQTextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jms://AFX.JMS.OUT, connector=ActiveMQJmsConnector
{
name=jmsConnector
lifecycle=start
this=6a08143f
numberOfConcurrentTransactedReceivers=1
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
, name='endpoint.jms.AFX.JMS.OUT', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ActiveMQTextMessage (org.mule.api.transport.DispatchException)
org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
+ 0 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
2016-06-27 08:56:49.214 [INFO] org.mule.api.processor.LoggerMessageProcessor:197 - EXCEPTION redirect flow invoked...
2016-06-27 08:56:49.223 [INFO] org.mule.api.processor.LoggerMessageProcessor:197 - AFX_OUT redirect flow invoked...
2016-06-27 08:56:49.227 [WARN] org.mule.transport.jms.JmsMessageUtils:269 - Header: Content-Type is not compliant with JMS specification (sec. 3.5.1, 3.8.1.1). It will cause problems in your and other applications. Please update your application code to correct this. Mule renamed it to Content_Type
2016-06-27 08:56:49.228 [WARN] org.mule.transport.jms.JmsMessageUtils:269 - Header: Content-Type is not compliant with JMS specification (sec. 3.5.1, 3.8.1.1). It will cause problems in your and other applications. Please update your application code to correct this. Mule renamed it to Content_Type
2016-06-27 08:56:49.231 [ERROR] org.mule.exception.DefaultMessagingExceptionStrategy:341 -
- Tags:
- Access Fulfillment Express
- AFX
- Automated Fulfillment Express
- Community Thread
- Discussion
- Forum Thread
- Identity G&L
- Identity Governance & Lifecycle
- IG&L
- IGL
- json
- RSA Identity
- RSA Identity G&L
- RSA Identity Governance & Lifecycle
- RSA Identity Governance and Lifecycle
- RSA IGL
- webservice
- yaml
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thank you.
I think I see the issue. Can you please edit the connector and uncheck "Asynchronous callback?" on the Settings tab, save the connector, and try again?
The asynchronous callback is used in cases where the RESTful web service can't issue an immediate response indicating the result of the operation and instead needs to do further, perhaps long-running, processing and issue a callback later on containing the end result of the operation. This is commonly used when interacting with an enterprise service bus, for example.
In your case the web service response contains the result, so you don't need the asynchronous callback. Because it's currently enabled, the test never completes because it's waiting for a results callback that it never receives.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
We do not support content type YAML. We support JSON/XML content.
The log message "Content-Type is not compliant with JMS specification" correctly specifies the problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Debashish,
Thank you for replying, I do understand the error, that's why I raised this to community.
Is there any workaround available to consume a YAML response?
Or what alternative is there to ovecome this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Are you able to provide some more details:
- What is the application/directory that you're trying to connect with?
- What commands are you wanting to run?
- Can you show some screenshots with your configuration?
Thanks
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Paul,
1. The directory is OpenLdap.
2. I want to run commands Add Application role to Account & Remove Application role from Account.(OpenLdap connector don't have commands to add account to Role or remove from Role.)
3. Our OpenLdap guys have an API wherein they allow to add accounts to Ldap Roles & Remove accounts from Ldap roles.
As Ldap connector don't have feature to work with roles, I thought of using Rest Connector as the Ldap service does work with YAML / JASON.
The service details are there in above post.
The configuration is as below,
I am really not sure about below 2 parts, what configuration is needed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Your JSON is formatted correctly, so if nothing else, the command should still be sent to the endpoint server.
Are you seeing any errors on the target system? Is it completing correctly?
I'm assuming that the command is sent in JSON, but the return is defaulting to YAML.
If we are unable to consume the YAML format status code, can you try as Regex and see what happens?
Also, can you try removing the Content-Type request header and see what errors occur?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Paul,
1. Yes, you are right it is delivering the request successfully but not able to parse the response.
I am seeing account getting added to the role but I get error after each test suite run.
I am getting below error due to parse failure.
Error code = 2
Failure - Error processing RESTful web service response Cause: Error processing RESTful web service response: java.lang.StringIndexOutOfBoundsException: String index out of range: 2
And I am not at all sure where to put reg ex ?
There are 3 locations given in connector setting Status Code, Brief Header, Detailed Header I have put my regular expression in all of them but still no correct response. I know status code it is not needed.
I am not even sure my regular expression is correct or not but I did check it on
Free Online Regular Expression Tester - FreeFormatter.com
2. If I remove 'Accept' - type then I am getting same error String Index out of range : 2
But if I play bit with Accept Type then error changes,
Error code = 2
Failure - Error processing RESTful web service response Cause: Error processing RESTful web service response: java.lang.IllegalStateException: Expected application/jason; UTF-8 but received application/json
So I am keeping Accpet - application/json
This hints that we are getting application/json but something wrong with parsing which is causing String index out Of range :2.
If it is really jason we are receiving then JSONPath also can be used but don't know how to.
Please advise what top do.
Thanks,
Tushar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
The important part to keep in mind is that we have 3 fields that we can use to store the representation of the overall success or failure of the request based on the response from the endpoint.
- Status Code: This field is the most important. The captured value that we put into this field must be an integer, positive or negative. The value is important too: 0 means that the request/command succeeded, and any other value means that it failed (much like unix/linux exit codes).
- Brief Response: This should just be a short message indicating the result of the command. The exact value doesn't matter, but it should conceptually convey what happened.
- Detailed Response: This is meant for a more detailed explanation of what happened, and it's mostly important when the request failed. Here you can put information like larger error messages or stack traces - anything that would help in troubleshooting the failure later.
One other thing to keep in mind is that there are 2 sections that are used to generate the value that's ultimately stored in the fields. The first section, "Expression," is used to extract a specific value from somewhere in the response, and the next section, which is optional, contains patterns that are used to transform that extracted value. So as an example, if your service will return {"status": "OK"} for success and {"status": "ERROR", "message": "Something bad happened - here are the details"} for failure, you might set the Status Code Expression Type to JsonPath and its expression to status. The extracted value would then be OK for success and ERROR for failure. Since Status Code must be an integer, you would need to add 2 patterns and corresponding replacements in order to convert these to valid values. You would add one pattern of OK with a replacement 0 and another pattern of ERROR with a replacement of something other than 0, like 1. To continue with this example, you could set Brief Response Expression Type to JsonPath and its expression to status as well, but you could remove all patterns and replacements from it so that Brief Response would end up being just either OK or ERROR. Lastly, for Detailed Response you could use Expression Type JsonPath and message for the expression and remove all patterns; for success Detailed Response would be empty and for failure it would be Something bad happened - here are the details.
Based on the documentation for your service that you provided, I think you'll just want the following:
Status Code
Expression Type: JsonPath
Expression: status
No patterns/replacements
Notes: This field is already 0 for success and other integers for failures, so we don't need to transform it.
Brief Response
Expression Type: JsonPath
Expression: message
No patterns/replacements
Detailed Response
Expression Type: JsonPath
Expression: message
No patterns/replacements
If this doesn't work, then we can turn on debug logging in order to see the actual response from the service and go from there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks for the explanation. It cleared lots of doubts.
After changing settings as above, test does add the account to role but no status.
It is getting timed out.
How can I enable deug logs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
