Orbeon Form HTTP Service - orbeon

Does anyone know how to pass parameters to a RESTFUL webservice using the Orbeon HTTP Service?
I have a RESTFUL API at http://localhost/RESTFUL/GETADDRESS/$parameter$.
Sample of the URL is http://localhost/RESTFUL/GETADDRESS/1234
Orbeon HTTP service is unable to pass the parameter to the web service.
The Request Body is configured as <parameter/> and serialization is set to XML.
Could not use HTML Form as it adds a ? to the URL which is not correct.
Anyone has any ideas to get this working?

There is no perfect solution. But try writing the service URL as:
http://localhost/RESTFUL/GETADDRESS/{...expression here...}
where "...expression here..." should be replaced by an XPath expression pointing to the value you would like to pass. For example, if pointing to a control called foo in a section called bar, try:
http://localhost/RESTFUL/GETADDRESS/{/*/bar/foo}
I also added this RFE.

Related

Adding dynamic path parameters into Orbeon Form HTTP Service

I'm trying to add a dynamic path parameter into an HTTP service in Orbeon forms, ie call a specific URL based on the content of a form field. I know we can change the query string parameters but I need to change the URL itself - the one in this field:
I've read that this is possible in newer version of Orbeon forms by using
{fr:control-string-value('testField')}
but we are stuck on an older version.
I saw another question on Stack Overflow from a few years ago: Orbeon Form HTTP Service where #ebruchez explained xpath is executed in the Resource URL field and gave the example:
http://localhost/RESTFUL/GETADDRESS/{/*/bar/foo}
However, I can't get this to work.
I have been able to successfully execute XPath, eg:
{string-join("test", "value")}
But I don't seem to be able to work out the correct Xpath syntax to dynamically select the value of a sample field and insert it into this box. I think I'm missing something in how I construct the XPath to retrieve the value.
This is what I've tried so far:
{xxf:value('testField')}
{xxf:value($testField)}
{fr:control-value($testField)}
{fr:control-value('testField')}
{xxf:property('testField')}
{xxf:property($testField)}
{$testField}
{'testField'}
{xxf:get-request-parameter('testField')}
{xxf:bind('testField')}
{/*/testField/}
{/*/content/testField/}
{//testField/}
{//*:testField/}
{//:testField/}
{(//testField)[1].text()}
{//form/content/testField/text()}
{(//testField)[1]/text()}
If anyone has any hints of advice on what I'm doing wrong or could give me an example of the syntax I put in here to retrieve a value, I'd be eternally grateful.
You can use AVT (Attribute Value Templates) https://doc.orbeon.com/xforms/core/attribute-value-templates?q=avt. In resource in <xf:submission> or HTTP service wizard use e.g. {instance('fr-form-instance')//url} or if you want edit only some part of URL you can use http://httpbin.org/{instance('fr-form-instance')//url}. I make simple form for you https://demo.orbeon.com/demo/fr/orbeon/builder/edit/18c4bee259fd9f398238b3c72041ee43ea691aa7 witch save respose to dataset and have second example in resource.
Hope this help you

Send POST request in ATG with checkFormRedirect method

I have requirement of changing GET to POST redirection to external URL.
Currently, we are using checkFormRedirect(url,req,res) to redirect to external URL which by default uses GET as per my understanding. I want to change this request to POST.
One way is we can use HTTPClient API for re-direction.
Is there any way ATG out of box provide some thing to POST redirection. Please help.
If you submitted a form in JSP as you are using checkFormRedirect(). It is already a POST request and you can get data in your handlerXXX method.
You can use this method to control redirects. The API call of this method looks somewhat like:-
public boolean checkFormRedirect(pSuccessURL, pFailureURL, pRequest, pResponse);
Now, this method redirects to pSuccessURL if no form errors are found in the form. Otherwise, it redirects to pFailureURL.

With the Orbeon Proxy Portlet is there a way to enable form selection via Inter Portlet Communication?

The Orbeon Proxy Portlet allows form selection via URL parameters. It would be preferable if the parameters were not included in the URL. I thought I might be able to use a public render parameter as described in the Liferay documentation but it looks like the proxy portlet isn't configured that way.
Looking at OrbeonProxyPortlet.scala I see this method is used to retrieve the URL parameters:
private def portalQuery(request: PortletRequest) =
collectByErasedType[String](request.getAttribute("javax.servlet.forward.query_string")) map decodeSimpleQuery getOrElse Nil
Could this method be modified to combine that map with the map returned by PorletRenderRequest.getParameterMap() or PorletRenderRequest.getPublicParameterMap()?
Or perhaps there could be another init-param like enable-url-parameters, for example, enable-inter-portlet-parameters?
This would also require the following configuration in the portlet.xml:
<supported-public-render-parameter>orbeon-app</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-form</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-document</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-page</supported-public-render-parameter>
As you noticed, currently this is not implemented, and I don't think there is a way without modifying the code of OrbeonProxyPortlet.scala. But yes, it would make sense to make this work, and in fact the option was considered in issue #1850.

get GET request in Golang on fcgi

I run my scripts under Apache. I understand how I can create request, for example:
http.Get(url)
How I can get GET request? I really dont see this information in docs. Thanks in advance!
UPD
For example, i do GET or POST-request to my go script from another script. In PHP I'd just write $a=$_GET["param"]. How i can do that in Go? Sorry for bad english, by the way
Your handler is passed a Request. In that Request you find for example the parameters in the Form field as soon as you parsed it using ParseForm :
// Form contains the parsed form data, including both the URL
// field's query parameters and the POST or PUT form data.
// This field is only available after ParseForm is called.
// The HTTP client ignores Form and uses Body instead.
Form url.Values

ASP.NET WEB API 406 error:for POST request using Media format

I am very new to web api stuff:
I am getting an error
406: Not Acceptable
error message in asp.net web api rest service.
In my rest service I’m using media format for my customized XML output, to get customized output.
I’m registering my formatted media in Global.asax page.
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new mynewformat());
all my methods are post methods with typed object as parameter and parameters are accepts from body.
Whenever I try to test the service… Getting 406: Not acceptable error message.
can anyone please help me ... what could be the reason for this....???
I did notice couple of interesting points here...
If I’m commenting below line then I’m getting 200 (OK) status code (which is fine.)... but format is not applying to output.
GlobalConfiguration.Configuration.Formatters.Clear();
If i'm removing parameters in my service method.. Then its working
fine..
I request everyone.. Please guide me what could be the reason/work around/solution/fix..for this issue.
Note:I don't want accept parameters from URI so i made it to accept from frombody only.
Thanks.
There is a lot more to implementing a custom format than just adding it to the configuration formatters. It starts with having to change the media-type header to a new custom type of your choosing (like "application/myNewFormat") for all requests, for the client. On the back end, you have to implement a new MediaTypeFormatter that can handle the serialization. This involves a bit more of code.
A good example of this resides here, it can easily be stripped to boiler-plate code:
http://www.codeproject.com/Articles/559378/Implementing-Custom-Media-Formatters-in-ASP-NET-We

Resources