how to change Geoserver 2.8.2 WMS exception format - exception

I want to change the exception format of Geoserver 2.8.2 WMS from default XML to inimage or blank. The docu states that this is possible (https://docs.geoserver.org/latest/en/user/services/wms/reference.html#exceptions), but does not tell how or where. Could anybody please tell me?
Thanks in advance!

The format can be changed only while performing a GetMap request (it cannot be configured, I believe the standard mandates the usage of XML exceptions by default).
When issuing a GetMap request, add the key value pair &EXCEPTIONS=application/vnd.ogc.se_inimage or &EXCEPTIONS=application/vnd.ogc.se_blank in the URL.
E.g.:
https://gs-main.geosolutionsgroup.com/geoserver/tiger/wms?service=WMS&version=1.1.0&request=GetMap&layers=tiger%3Agiant_polygon&bbox=-180.0%2C-90.0%2C180.0%2C90.0&width=768&height=384&srs=EPSG%3A4326&styles=foobar&format=image/png&EXCEPTIONS=application/vnd.ogc.se_inimage
(should return an image saying that the foobar style does not exist)

Related

Nifi RestLookupService in LookupRecord gives JsonParseException

I have a basic NIFI flow with one GenerateFlowFile processor and one LookupRecord processor with RestLookupService.
I need to do a rest lookup and enrich the incoming flow file with rest response.
I am getting errors that the lookup service is unable to lookup coordinates with the value I am extracting from the incoming flow file.
GenerateFlowFile is configured with simple JSON
LookupRecord is configured to extract the key from the JSON and populate it to the RestLookupService. Also, JsonReader and JsonSetWriter is configured to read the incoming flow file and to write the response back to the flow file
The RestLookupService itself exits with JsonParseException about unexpected character '<'
RestLookupService is configured with my API running in the cloud in which I am trying to use the extracted KEY from the incoming flow file.
The most interesting bug is that when I configure the URL to point for example to mocky.io everything works correctly so it means that the issue itself is tight with the API URL I am using (http://iotosk.ddns.net:3006/devices/${key}/getParsingData). I have tried also removing the $key, using the exact URL, using different URLs..
Of course the API is working OK over postman/curl anything else. I have checked the logs on the container that the API is running on and there is no requests in the logs what means that nifi is failing even before reaching the API. At least on application level...
I am absolutely out of options without any clue how to solve this. And with nifi also google is not helpful.
Does anybody see any issue in the configuration or can point me in some direction what can cause this issue?
After some additional digging. The issue was connected with authentication logic even
before the API receives it and that criples the request and and returned XML as Bryan Bende suggested in the comment.
But definitely better logging in nifi will help to solve this way faster...

How can I store the SOAP xml request in Clob field Oracle in ESQL IBM Integration BUS

I'm trying to store the Soap Input Request (Soap UI Request) in the database for log in ESQL Langage. I'm noob in ESQL .
My flow is Soap Input ==> Compute Node ==> Soap Reply .
I have no idea to do this. Please Help.
Not sure if you still require this or have already found a solution, but thought i'd post anyway.
This is something that has been quite common in several places I have worked. The way we tended to achieve this was by casting the incoming message as a bitstream and then casting it as a character -
DECLARE blobInputMsg BLOB ASBITSTREAM(InputBody CCSID 1208 ENCODING 546);
DECLARE charInputMsg CHAR CAST(blobInputMsg AS CHARACTER CCSID 1208 ENCODING 546);
The CCSID and ENCODING should be taken from the incoming message e.g. InputProperties.CodedCharSetId and InputProperties.Encoding, or defaulted to values suitable for your interfaces.
Have a go at Monitoring. Do the step by step stuff outlined here.
https://www.ibm.com/developerworks/community/blogs/546b8634-f33d-4ed5-834e-e7411faffc7a/entry/auditing_and_logging_messages_using_events_in_ibm_integration_bus_message_broker?lang=en
Be careful with the subscription in MQ as things get concatenated. Use MQExplorer to check your subscription including topic after you've defined it.
Also make sure you run the IIB queue definition scripts as per the install instructions for your version as one of the MQSC commands defines the topic.
Use a separate flow to write the events to your DB. Note in this day and age on Unix systems I'd probably write them to syslog and use ELK or Splunk

Parse Json in Logic App from Stream Analytics -> Service Hub -> Logic Apps

I'm trying to build a logic app that inserts data into a Sql database. The data is coming from s Stream Analytics job, outputting it on a Service Bus topic, consumed in Logic Apps in Service Bus trigger.
To populate the properties of the row inserted (lets say it only has one column 'Name'), I've found that this should work using following syntax:
"body": {
"Name": "#{json(decodeBase64(triggerBody()['ContentData'])).Name}"
},
Provided the message body contains a 'Name' property.
However I get following error message when running this:
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'Insert_row' inputs at line '1' and column '2017': 'The template language function 'json' parameter is not valid. The provided value '#\u0006string\b3http://schemas.microsoft.com/2003/10/Serialization/��{\"time\":\"2016-05-25T10:29:17.4953250Z\",\"Name\":\"Y-Axis\",\"Value\":81.0,\"Date\":\"2016-05-25T10:29:17.4953250\",\"EventProcessedUtcTime\":\"2016-05-25T10:29:17.5525449Z\",\"PartitionId\":2,\"EventEnqueuedUtcTime\":\"2016-05-25T10:29:17.2220000Z\"}\u0001' cannot be parsed: 'Unexpected character encountered while parsing value: #. Path '', line 0, position 0.'. Please see https://aka.ms/logicexpressions#json for usage details.'."}
So it seems like that the content is enclosed in another envelope that is preventing json parsing to work.
1) Any simple way how to get around this?
2) Isn't such an integration all within Microsoft Stack just supposed to work without this mocking around?
Thanks,
Stefan
with the limited string functions available in he workflow definition language I had to use a long winded way for removing the additional strings
#{json(substring(replace(decodeBase64(triggerBody()['ContentData']),'#string3http://schemas.microsoft.com/2003/10/Serialization/��', ''),0,sub(length(replace(decodeBase64(triggerBody()['ContentData']),'#string3http://schemas.microsoft.com/2003/10/Serialization/��', '')),1))).fieldname}
is there a better way to do this
Thanks for reporting this, you're right it should simply work. There is a known issue where ASA ServiceBus output JSON is being wrapped in a XML header. It will be addressed in a near future but can't specify a particular date. Could you please workaround it (maybe using substring/replace) until then ?
cheers,
Chetan
Sorry for the delay in getting back, this issue is now fixed. Its exposed under a new compatibility level (1.1) to avoid breaking existing solutions. Please use this URL to configure your job with compat level 1.1 and give it a try.
cheers!

Default settings on config read fail

I have a method for parsing a config file into a dictionary. I'm unsure how it should behave if a config parameter is missing. Should it use a default value and log an error or raise an exception?
I suggest that you separate: (1) the parsing of the configuration file and storing the parsed details into a dictionary, from (2) retrieving name=value pairs from the dictionary. This separation of concerns will then enable you to provide an overloaded API for (2) that specifies if a missing name=value pair should result in a default value being returned or an exception being raised. For example (pseudo code):
cfg = parseConfigurationFile("example.cfg")
x = cfg.lookupString("x"); // throws an exception if the name=value is missing
y = cfg.lookupString("y", "hello, World!"); // returns default value if name=value is missing
I also suggest that the API should provide type-safe lookup methods such as lookupInt(), lookupBoolean(), lookupDouble() and so on. Those methods should throw an exception if a looked-up value cannot be parsed into the specified type.
Edit to respond to a comment
"Thanks for the example. I was more wondering if it was a good idea to even
provide default settings and start the application if the config was wrong."
I like the Fail Fast Principle, so I recommend that if any configuration data is invalid, your application should report an error and stop, rather than try to silently repair the error (perhaps by using a default value instead of a bad configuration value) and continue on.
However, I don't think you should necessarily view missing name=value pairs as being an error. Instead, it is valid to use a default value for a missing value. If you take this to an extreme by allowing all the configuration name=value pairs to be optional, then your application will be able to work "out of the box" without any configuration file at all, which arguably improves the application's ease of use for new users.
A few years ago, I wrote Config4* (C++ and Java libraries for parsing a particular configuration-file syntax). Config4* provides an elegant way to enable any/all name=value pairs to be optional: it's what the Config4* manual calls fallback configuration. If you want to learn about that, then I suggest you skim-read Chapter 2 of the Config4* Getting Started Guide to get an understanding of the configuration syntax, and then read Chapter 3 of the same manual to understand the API. Pay particular attention to Sections 3.6.2 (Parsing Embedded Configuration) and 3.6.3 (Using Fallback Configuration).

What should be the standard success, failure and error JSON response formats for REST APIs?

What should be the standard format for returning success JSON, failure JSON and error JSON? I visited many so called RESTful APIs but almost all have their own way to return success, failure and error JSON? Is there any recommended JSON format that should be followed/referenced?
Thanks
Good question. REST does set some conventions, but unlike for GET or PUT HTML where there is at least a convention for the tag names to be sent, there is little about the vocabulary to be used for JSON... I believe any truly useful long-term usage will need to develop formal vocabularies beyond basic transaction behaviors, whether HTML, XMPP, or a dialect of JSON (e.g., in XMPP, unlike say WebSockets alone, you can develop clients which know how to handle subscription and publishing for any Pubsub server).
To signal Success, errors or any other status you should use standard http status codes.
You can also in case of an error return a json containing something like code, severity and message.
You should follow the HTTP Status Codes as per its description. It will be good to have all your REST failure/error responses to have some common fields like errorCode and errorMessage that describes the status you are sending back.
{
"apiStatus":{
"errorCode":"validation.error.invalidId",
"errorMessage":"The Id entered is not valid"
}
"yourContentIfany": ....
}