Worklight 5.0.6 Documentation - Open Questions: "WL.FailResponse", "standard response object", "heartbeat in designated cases" - ibm-mobilefirst

We are using WL 5.0.6.1 and we did not find all the information in the docs.
At
http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/topic/com.ibm.worklight.help.doc/apiref/r_wl_client_connect.html
does the onSuccess(??) receive any parameter/object as input? If so what type/JSON structure?
the onFailure receives a WL.FailResponse input object - is there any type/JSON-Structure definition available?
At:
http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/topic/com.ibm.worklight.help.doc/apiref/r_wl_client_invokeprocedure.html
it says: "the failure handler receives a standard response object." ... is there a type definition for a "standard response object"?
At:
http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/topic/com.ibm.worklight.help.doc/apiref/r_wl_client_setheartbeatinterval.html
in the WorkingOffline PDF: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v600/05_04_Working_offline.pdf it says: " Both WL.Events.WORKLIGHT_IS_CONNECTED and
WL.Events.WORKLIGHT_IS_DISCONNECTED events can be fired
by heartbeat in designated cases"
What are these "designated cases"?
when the heartbeat fails to connect to the server for the first time (or every time) will the event WL.Events.WORKLIGHT_IS_DISCONNECTED be fired?
will the heartbeat continue to run/try once the WL.Events.WORKLIGHT_IS_DISCONNECTED was fired, or does it need to be reset/restarted manually?
if it does continue to run, will the event WL.Events.WORKLIGHT_IS_CONNECTED be fired once the heartbeat has it's first successful connection to the server again?

The object that comes in on the onSuccess can be any (JSON) object you return from the back-end wrapped in an invocationResult together with an isSuccessful and errors attributes:
An object that contains the data that is returned by the invoked procedure, and the invocation status. Its format is as follows:
**invocationResult = {
isSuccessful: Boolean,
errors : "Error Message"
// Procedure results go here
}**
Where:
isSuccessful – Contains true if the procedure invocation succeeded, false otherwise. If the invocation failed, the failure handler for the request is called.
errors – An optional array of strings containing error messages.
And for the failure:
The procedure was called but failed. In this case, the invocationResult property is added to the response received by the failure handler. This property has the same structure as the invocationResult property returned to the success handler, but the value of the isSuccessful attribute is false. For the structure of the invocationResult property, see invocationResult.

Related

UI5 Odata batch update - Connect return messages to single operation

I perform a batch update on an OData v2 model, that contains several operations.
The update is performed in a single changeset, so that a single failed operation fails the whole update.
If one operation fails (due to business logic) and a message returns. Is there a way to know which operation triggered the message? The response I get contains the message text and nothing else that seems useful.
The error function is triggered for every failed operation, and contains the same message every time.
Maybe there is a specific way the message should be issued on the SAP backend?
The ABAP method /iwbep/if_message_container->ADD_MESSAGE has a parameter IV_KEY_TAB, but it does not seem to affect anything.
Edit:
Clarification following conversation.
My service does not return a list of messages, it performs updates. If one of the update operations fails with a message, I want to connect the message to the specific update that failed, preferably without modifying the message text.
An example of the error response I'm getting:
{
"error":{
"code":"SY/530",
"message":{
"lang":"en",
"value":"<My message text>"
},
"innererror":{
"application":{
"component_id":"",
"service_namespace":"/SAP/",
"service_id":"<My service>",
"service_version":"0001"
},
"transactionid":"",
"timestamp":"20181231084555.1576790",
"Error_Resolution":{
// Sap standard message here
},
"errordetails":[
{
"code":"<My message class>",
"message":"<My message text>",
"propertyref":"",
"severity":"error",
"target":""
},
{
"code":"/IWBEP/CX_MGW_BUSI_EXCEPTION",
"message":"An exception was raised.",
"propertyref":"",
"severity":"error",
"target":""
}
]
}
}
}
If you want to keep the same exact message for all operations the simplest way to be able to determine the message origin would be to add a specific 'tag' to it in the backend.
For example, you can fill the PARAMETER field of the message structure with a specific value for each operation. This way you can easily determine the origin in gateway or frontend.
If I understand your question correctly, you could try the following.
override the following DPC methods:
changeset_begin: set cv_defer_mode to abap_true
changeset_end: just redefine it, with nothing inside
changeset_process:
here you get a list of your requests in a table, which has the operation number (thats what you seek), and the key value structure (iwbep.blablabla) for the call.
loop over the table, and call the method for each of the entries.
put the result of each of the operations in the CT_CHANGESET_RESPONSE.
in case of one operation failing, you can raise the busi_exception in there and there you can access the actual operation number.
for further information about batch processing you can check out this link:
https://blogs.sap.com/2018/05/06/batch-request-in-sap-gateway/
is that what you meant?

Full example of Message Broker in Lagom

I'm trying to implement a Message Broker set up with Lagom 1.2.2 and have run into a wall. The documentation has the following example for the service descriptor:
default Descriptor descriptor() {
return named("helloservice").withCalls(...)
// here we declare the topic(s) this service will publish to
.publishing(
topic("greetings", this::greetingsTopic)
)
....;
}
And this example for the implementation:
public Topic<GreetingMessage> greetingsTopic() {
return TopicProducer.singleStreamWithOffset(offset -> {
return persistentEntityRegistry
.eventStream(HelloEventTag.INSTANCE, offset)
.map(this::convertEvent);
});
}
However, there's no example of what the argument type or return type of the convertEvent() function are, and this is where I'm drawing a blank. On the other end, the subscriber to the MessageBroker, it seems that it's consuming GreetingMessage objects, but when I create a function convertEvent to return GreetingMessage objects, I get a compilation error:
Error:(61, 21) java: method map in class akka.stream.javadsl.Source<Out,Mat> cannot be applied to given types;
required: akka.japi.function.Function<akka.japi.Pair<com.example.GreetingEvent,com.lightbend.lagom.javadsl.persistence.Offset>,T>
found: this::convertEvent
reason: cannot infer type-variable(s) T
(argument mismatch; invalid method reference
incompatible types: akka.japi.Pair<com.example.GreetingEvent,com.lightbend.lagom.javadsl.persistence.Offset> cannot be converted to com.example.GreetingMessage)
Are there any more more thorough examples of how to use this? I've already checked in the Chirper sample app and it doesn't seem to have an example of this.
Thanks!
The error message you pasted tells you exactly what map expects:
required: akka.japi.function.Function<akka.japi.Pair<com.example.GreetingEvent,com.lightbend.lagom.javadsl.persistence.Offset>,T>
So, you need to pass a function that takes Pair<GreetingEvent, Offset>. What should the function return? Well, update it to take that, and then you'll get the next error, which once again will tell you what it was expecting you to return, and in this instance you'll find it's Pair<GreetingMessage, Offset>.
To explain what these types are - Lagom needs to track which events have been published to Kafka, so that when you restart a service, it doesn't start from the beginning of your event log and republish all the events from the beginning of time again. It does this by using offsets. So the event log produces pairs of events and offsets, and then you need to transform these events to the messages that will be published to Kafka, and when you returned the transformed message to Lagom, it needs to be a in a pair with the offset that you got from the event log, so that after publishing to Kafka, Lagom can persist the offset, and use that as the starting point next time the service is restarted.
A full example can be seen here: https://github.com/lagom/online-auction-java/blob/a32e696/bidding-impl/src/main/java/com/example/auction/bidding/impl/BiddingServiceImpl.java#L91

SQS Extended - The input receipt handle is invalid

We wrappered an existing queue with the extended functionality. Messages are able to be put on the queue, and we see the message body being stored on S3.
However, when the message is consumed we get the following stack trace:
com.amazonaws.services.sqs.model.ReceiptHandleIsInvalidException: The input receipt handle is invalid. (Service: AmazonSQS; Status Code: 404; Error Code: ReceiptHandleIsInvalid; Request ID: ba9421e9-a9d2-56ba-8e17-70ff7190f05a)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2419)
at com.amazonaws.services.sqs.AmazonSQSClient.changeMessageVisibility(AmazonSQSClient.java:485)
at com.amazonaws.services.sqs.AmazonSQSClient.changeMessageVisibility(AmazonSQSClient.java:1692)
at com.amazon.sqs.javamessaging.AmazonSQSExtendedClientBase.changeMessageVisibility(AmazonSQSExtendedClientBase.java:1376)
Which happens when we attempt to change the visibility. Is that not supported?
sqsExtended.changeMessageVisibility(queueUrl, message.getReceiptHandle(), visibilityTimeout);
The answer is that this hasn't been implemented, nor does it try to warn you by throwing an exception when calling the method. There doesn't seem to be a reason to not be implemented, looking at the source code, it would be straightforward.
For our case, we are okay with relaying on the queue default value for this parameter and not setting each individually.

OnTaskFailed event handler in SSIS

If I use OnError event handler in my SSIS package, there are variables System::ErrorCode and System::ErrorDescription from which I can get the error information if any things fails while execution.
But I cant the find the same for OnTaskFailed event handler, i.e. How to get the ErrorCode and ErrorDescription from the OnTaskFailed event handler when any things fails while execution in case we want to only implement OnTaskFailed event handler for our package?
This might be helpful, it's a list of all system variables and when they are available.
http://msdn.microsoft.com/en-us/library/ms141788.aspx
I've just run into the same issue, and I've worked around it by :
Creating a #[ErrorCache] variable
In my case the task was being retried multiple times, so I needed an Expression task to reset the #[ErrorCache] variable at the beginning of each retry
Create an OnError event handler, which contains an Expression task purely to append the #[ErrorMessage] to the #[ErrorCache]
Create an OnTaskFailed event handler which then utilises the #[ErrorCache]
Go to the event handler of the task you want to monitor for errors and click on the link to create a new handler.Then create a task like Send Mail and create 2 variables: mail_header and mail_body.
IMPORTANT: Move the variables from the current scope to the OnError scope otherwise the values won't be available when processing the package.
Define the mail_subject variable as string and set the expression as: "Error " + #[System::TaskName] + " when executing " + #[System::PackageName] + " package."
Define the mail_body variable as string and set the expression as: REPLACENULL( #[System::ErrorDescription],"" ) + "\nNotify your system administrator."
On the task editor, create an expression assigning Subject to the #mail_subject variable. Define the MessageSourceType as a variable and set MessageSource to the #mail_body.
In the task that you put on the error event handler you can select parameters that are only available in an error handler such as system:Errordescription or system:Sourcename (which provideds the task that it failed on). We use these as input variables to a stored proc which inserts into an error table (and to send an email for a failed process) that stores other information beyond just the logging table. We also use the logging table to log our steps and in clude on error in that so general error information goes there.

WCF: The server method 'MyMethod' failed

The WCF service is deployed on different machine.
Im able to get the http://MyServer/MYService.svc/jsdebug file by giving
<identity>
<dns value="ServerName and the portnumber"/>
And I'm able to invoke the service method using javascript.
After invoking the MyMethod.
I get this error in the javascript --> The server method 'MyMethod' failed, status 404 (in failedCallback)
MyMethod returns a Boolean value in svc.cs file after performing a datacheck.
These are the errors came up when I used Firefox Firebug:
When I call the same service using VS2008 in my development environment it works fine.
I found that following are the files which are not loading while using Ajax enabled VS2005
1) MicrosoftAjax.debug.js(3.5)
2) MicrosoftAjaxWebForms.debug.js(3.5) During runtime
Its obvious that 3.5 debug files doesn't load but, 1.0.6 debug files should load without the errors displayed below.
invokeCalledTwice":"Cannot call invoke more than once.",
11"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}",
12"argumentType":"Object cannot be converted to the required type.",
13"argumentNull":"Value cannot be null.",
14"controlCantSetId":"The id property can\u0027t be set on a control.",
15"formatBadFormatSpecifier":"Format specifier was invalid.",
16"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.",
17"argumentDomElement":"Value must be a DOM element.",
18"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.",
19"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.",
20"actualValue":"Actual value was {0}.",
21"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.",
22"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.",
23"parameterCount":"Parameter count mismatch.",
24"cannotDeserializeEmptyString":"Cannot deserialize empty string.",
25"formatInvalidString":"Input string was not in a correct format.",
26"invalidTimeout":"Value must be greater than or equal to zero.",
27"cannotAbortBeforeStart":"Cannot abort when executor has not started.",
28"argument":"Value does not fall within the expected range.",
29"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.",
30"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.",
31"nullWebRequest":"Cannot call executeRequest with a null webRequest.",
32"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
33"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.",
34"argumentUndefined":"Value cannot be undefined.",
35"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}",
36"servicePathNotSet":"The path to the web service has not been set.",
37"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.",
38"cannotCallOnceStarted":"Cannot call {0} once started.",
39"badBaseUrl1":"Base URL does not contain ://.",
40"badBaseUrl2":"Base URL does not contain another /.",
41"badBaseUrl3":"Cannot find last / in base URL.",
42"setExecutorAfterActive":"Cannot set executor after it has become active.",
43"paramName":"Parameter name: {0}",
44"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.",
45"format":"One of the identified items was in an invalid format.",
46"assertFailedCaller":"Assertion Failed: {0}\r\nat {1}",
47"argumentOutOfRange":"Specified argument was out of the range of valid values.",
48"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.",
49"notImplemented":"The method or operation is not implemented.",
50"assertFailed":"Assertion Failed: {0}",
51"invalidOperation":"Operation is not valid due to the current state of the object.",
52"breakIntoDebugger":"{0}\r\n\r\nBreak into debugger?"
Appreciate your inputs.
Seeing as you have Firebug installed, you can use it to check the HTTP request and response to see if they contain more information about what went wrong.
These are the errors came up when I used Firefox Firebug:
When I call the same service using VS2008 in my development environment it works fine.
I found that following are the files which are not loading while using Ajax enabled VS2005
1) MicrosoftAjax.debug.js(3.5)
2) MicrosoftAjaxWebForms.debug.js(3.5) During runtime
Its obvious that 3.5 debug files doesn't load but, 1.0.6 debug files should load without the errors displayed below.
invokeCalledTwice":"Cannot call invoke more than once.",
11"webServiceFailed":"The server method \u0027{0}\u0027 failed with the following error: {1}",
12"argumentType":"Object cannot be converted to the required type.",
13"argumentNull":"Value cannot be null.",
14"controlCantSetId":"The id property can\u0027t be set on a control.",
15"formatBadFormatSpecifier":"Format specifier was invalid.",
16"webServiceFailedNoMsg":"The server method \u0027{0}\u0027 failed.",
17"argumentDomElement":"Value must be a DOM element.",
18"invalidExecutorType":"Could not create a valid Sys.Net.WebRequestExecutor from: {0}.",
19"cannotCallBeforeResponse":"Cannot call {0} when responseAvailable is false.",
20"actualValue":"Actual value was {0}.",
21"enumInvalidValue":"\u0027{0}\u0027 is not a valid value for enum {1}.",
22"scriptLoadFailed":"The script \u0027{0}\u0027 could not be loaded.",
23"parameterCount":"Parameter count mismatch.",
24"cannotDeserializeEmptyString":"Cannot deserialize empty string.",
25"formatInvalidString":"Input string was not in a correct format.",
26"invalidTimeout":"Value must be greater than or equal to zero.",
27"cannotAbortBeforeStart":"Cannot abort when executor has not started.",
28"argument":"Value does not fall within the expected range.",
29"cannotDeserializeInvalidJson":"Cannot deserialize. The data does not correspond to valid JSON.",
30"invalidHttpVerb":"httpVerb cannot be set to an empty or null string.",
31"nullWebRequest":"Cannot call executeRequest with a null webRequest.",
32"eventHandlerInvalid":"Handler was not added through the Sys.UI.DomEvent.addHandler method.",
33"cannotSerializeNonFiniteNumbers":"Cannot serialize non finite numbers.",
34"argumentUndefined":"Value cannot be undefined.",
35"webServiceInvalidReturnType":"The server method \u0027{0}\u0027 returned an invalid type. Expected type: {1}",
36"servicePathNotSet":"The path to the web service has not been set.",
37"argumentTypeWithTypes":"Object of type \u0027{0}\u0027 cannot be converted to type \u0027{1}\u0027.",
38"cannotCallOnceStarted":"Cannot call {0} once started.",
39"badBaseUrl1":"Base URL does not contain ://.",
40"badBaseUrl2":"Base URL does not contain another /.",
41"badBaseUrl3":"Cannot find last / in base URL.",
42"setExecutorAfterActive":"Cannot set executor after it has become active.",
43"paramName":"Parameter name: {0}",
44"cannotCallOutsideHandler":"Cannot call {0} outside of a completed event handler.",
45"format":"One of the identified items was in an invalid format.",
46"assertFailedCaller":"Assertion Failed: {0}\r\nat {1}",
47"argumentOutOfRange":"Specified argument was out of the range of valid values.",
48"webServiceTimedOut":"The server method \u0027{0}\u0027 timed out.",
49"notImplemented":"The method or operation is not implemented.",
50"assertFailed":"Assertion Failed: {0}",
51"invalidOperation":"Operation is not valid due to the current state of the object.",
52"breakIntoDebugger":"{0}\r\n\r\nBreak into debugger?"