Hi, the REST Adapter allows to map the "Complete URL" to an input parameter of an ABL method.
However, the QueryString portion of the URL is not part of this. According to http://en.wikipedia.org/wiki/Uniform_resource_locator I was under the impression that the Query String is part of the URL.
I was trying to be able to parse the Query String in the ABL and not have to map every possible query string parameter to a disctinct input parameter of the ABL method.
Is my understanding of the term "Complete URL" wrong? Is this a bug? Or is there another was to send the complete Query String (including all the name/value pairs) to the ABL method.
Still on OpenEdge 11.4 for this customer.
Hi Mike,
you could use "servlet request" from the "servlet contexts" in the mapping dialog.
hth
Hi Mike, also see knowledgebase.progress.com/.../000054636
Btw, if you don't want to program parsing the servlet request, take a look at:
to more precise, the ServletRequestParser class:
bitbucket.org/.../ServletRequestParser.cls
and the ServletRequestInfo class:
Btw, if you don't want to program parsing the servlet request, take a look at:
to more precise, the ServletRequestParser class:
bitbucket.org/.../ServletRequestParser.cls
and the ServletRequestInfo class:
Flag this post as spam/abuse.
Bronco, is there a particular reason why you map the rest request info property "method" to "HttpMethod" in your parser? I just tried and 11.5 at least does allow a property called "Method".
I'm not saying it's wise to do in general ... but in this case where you just transform data from REST into an ABL class, I'm tempted to leave the property name in the ABL as it was in the Json string.
Well, I was pretty sure it gave a compile error. I just checked however and there's no error in 11.3/11.4 either so I guess the mapping from Method to HttpMethod is superfluous...
... on the other hand, "Method" is a bit ambiguous.
Sorry to bring back an old thread, but I am trying to achieve same idea to parse whole URL to a single parameter to process the query string, these two classes are very useful but they still leave the query string unparsed.
Do you know if there are a library or class in Openedge.Net package maybe to parse the query string to get the list of key/values?
Cheers,
Don't know, but it's not rocket science. The query string is just a '&' delimited string. You can add somthing like the to the requestinfo class:
define private variable queryStringProcessed as logical no-undo.
method public character GetQueryParameter(parameterName as character):
/* lazy parsing: don't parse until needed */
if (not queryStringProcessed) then do:
processQueryString().
queryStringProcessed = true.
end.
return KeyValueStore:Get("RequestQueryString", parameterName).
end method.
method private void processQueryString():
define variable i as integer no-undo.
define variable numEntries as integer no-undo.
define variable currentEntry as character no-undo.
if (QueryString = "" or QueryString = ?) then
return.
numEntries = num-entries(QueryString, "&").
do i = 1 to numEntries:
currentEntry = entry(i, QueryString, "&").
/* key = entry(1, currentEntry, "="). */
/* value = entry(2, currentEntry, "=")). */
end.
end method.
Now you have to make something yourself for the KeyValueStore class, but you get the drift.
Thanks bronco, yes I understand is not rocket science, but just wondered if there was an already working version of it in some of the new Openedge.net classes.
Your code would work for the most basic cases, but there will be, at least URI encode values that would need processing, and not sure if some other edge case that needs to be considered.
Appreciate your code, if there is nothing already available it will be a good head start.
An alternative if you have the URI - Method with INPUT poURI AS URI:
DEFINE VARIABLE cNamesArray AS CHARACTER EXTENT NO-UNDO.
DEFINE VARIABLE iNamesArray AS INTEGER NO-UNDO.
DEFINE VARIABLE iIdx AS INTEGER NO-UNDO.
ASSIGN iNamesArray = poURI:GetQueryNames(OUTPUT cNamesArray).
DO iIdx = 1 TO iNamesArray:
MESSAGE cNamesArray[iIdx].
MESSAGE poUri:GetQueryValue(cNamesArray[iIdx]).
END.
Thanks, that's exactly what I was looking for.
I thought we were in 11.6 but still in 11.5.1, I assume that there are not Openedge.net classes available for 11.5.1, right?