Relative URL when sending data

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Relative URL when sending data

ctbogdan
Hello,

I noticed this question has been posted multiple times before, but since
it's been some years I want to check if there are at least workarounds now.

I'm using the latest version of Orbeon (2017.2) and it's deployed in it's
own http server (tomcat), and the application that embeds the forms is at a
different url/port.

I want the embedding application to deal with data storage and processing
and so I defined this in properties-local-prod.xml

<property as="xs:string" name="oxf.fr.detail.process.send.orbeon.test-form">
        send(uri = "http://localhost/localPoint", method="POST",
data-format-version="xml", prune="false")
        then navigate("/success")
        recover navigate("/failure")
</property>

And this works - my application receives the xml data and is free to process
it.

The problem is that there could be multiple applications that use the same
form deployed at different urls.


Is there any way to make Orbeon send the data to a relative URL (like
"/localPoint"), the same way it's done with navigate ?


--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

Alessandro  Vernet
Administrator
Hi Catalin,

I am not sure to follow: you're saying that you'd like `send(uri =
"/localPoint")` to make a query to `http://localhost/localPoint`, but then
what would the downside of using `http://localhost/localPoint` instead of
`/localPoint` in the `send()`?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
Hi Alessandro,

I am running everything locally just as a proof of concept.

Let's assume there are two instances of the same web server, each with their
own domain - http://foo-dev.com and http://foo-qa.com and the Orbeon
instance is deployed at http://bar.com

Both my applications will embed the same form but the send action can be
configured to send the data to only one server.
`send()` with a relative URL would send the data to the embedding
application, rather than a hardcoded URL.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
In reply to this post by Alessandro Vernet
Alessandro,

As per this ticket -
http://discuss.orbeon.com/relative-URL-with-POST-td45314.html I tried
defining a new `xf:submission` node in my form with
 <xf:submission id="submit-relative-url" method="post" validate="false"
nonrelevant="keep"
                           resource="/localPoint" replace="none"/>
under <xf:model> tag and under <fr:body> I added this
<xf:submit submission="submit-relative-url">
   <xf:label>Submit to relative URL</xf:label>
</xf:submit>

When I press the submit button nothing happens and this line is logged in
orbeon.log
ERROR XFormsServer  - xforms-submit-error - xf:submission for submission id:
submit-relative-url, error code received when submitting instance: 404

If I put in the entire URL it works.

I should mention the web server that processes form data is running at port
80 and the Orbeon server is running at port 8081.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

Alessandro  Vernet
Administrator
Hi Catalin,

Got it, and thank you for the additional information. If you're using an
`<xf:submission>`, you can use `f:url-norewrite="true"`. You can find more
about this on:

https://doc.orbeon.com/xforms/submission-extensions.html#context-resolution

You'll let me know if this works for you.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
Hi Alex,

I tried your solution by adding
xmlns:f="http://orbeon.org/oxf/xml/formatting" schema and modifying
submission as such

<xf:submission id="submit-relative-url" method="post" validate="false"
nonrelevant="keep"
    resource="/localPoint"
    replace="none"
    f:url-norewrite="true"/>

and I get the same issue as without the attribute with the same log error.

The documentation says the attribute allows resolving resources from other
web applications in the same servlet container, but I'm using 2 different
servlet containers for my setup.

Is there anything else I can try ?


Thank you,
Catalin

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

Alessandro  Vernet
Administrator
Hi Catalin,

Got it, and I am not surprised that this is the way it is working. Keep in
mind that your submission is made by Orbeon Forms, not the browser. If you
have a single instance of Orbeon Forms and you need it to make queries to
different servers depending on the situation, you could make this more
explicit by having your reserve proxy (either the dev proxy or qa proxy) set
a header containing the host name to use, and in your  `xf:submission` use
`resource="http://{xxf:get-request-header('service-host')}/localPoint"`.
Would something along those lines work for you?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
Hi Alex,

That sounds like a great idea.
I've been having trouble using it locally though. No matter what header key
I put in it results in an empty string.

I tried using this function in 2 different places:

1. In properties-local-prod.xml I added
xmlns:xxf="http://orbeon.org/oxf/xml/xforms" namespace and
        <property as="xs:string"
name="oxf.fr.detail.process.send.orbeon.test-form">
                send(uri = "http://{xxf:get-request-header('origin')}/localPoint",
method="POST", data-format-version="xml", prune="false")
                then navigate("/success")
                recover navigate("/failure")
        </property>
And I get this line in logs

ERROR XFormsServer  - xforms-submit-error - URI does not specify a valid
host name:
http:///localPoint?document=6be3f149f1878053609301c4eef4f9b64e2d9512&process=5f3a0cb9ed4c6c8449cf05f622ac9672c49a466d&data-format-version=xml&language=en&valid=true&app=orbeon&form-version=1&form=test-form


2. xf:submission in form source
<xf:submission id="submit-relative-url" method="post" validate="false"
nonrelevant="keep"
  resource="http://{xxf:get-request-header('Origin')}/localPoint"
  replace="none"
  f:url-norewrite="true"/>
And I get this in the logs
ERROR XFormsServer  - xforms-submit-error - URI does not specify a valid
host name: http:///localPoint


I should mention I tried to get multiple common header values, including
content-length, user-agent - both uppercase and lower case and the error
messages are always the same.
I also tried with a custom header value (added by filter on every request),
same results.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

Alessandro  Vernet
Administrator
Hi Catalin,

Indeed, it sounds like `xxf:get-request-header('origin')` doesn't return
anything, in your case. Are you indeed setting that header? How are you
setting it?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
Hi Alex,

I defined a new custom filter in the application that sets the custom header
to response and then chains filters. It is mapped to all URLs ("/*").

To validate it I used browser's Network tab (Chrome) to capture requests and
surely there's always a single POST request to
http://localhost/orbeon/o0/xforms-server and the custom header is set
whenever I click on the custom submit.

What concerns me is that `xxf:get-request-header()` doesn't retrieve header
values that are always set by Java or the browser (eg. Content-Length or
Origin). If it would, the error message in the log should be different. Does
it not allow getting the value for certain headers ?

Catalin

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

Alessandro  Vernet
Administrator
Hi Catalin,

So I understand you're using a servlet filter to set the header. Are you
also setting the headers when the page with the form is loaded (not just for
the Ajax request)? I am asking because those will be the headers that will
be forwarded, not the headers Orbeon Forms received with the Ajax request.

If you're setting the headers when the form is loaded and it still isn't
working, could you instead try setting them in Chrome with the ModHeader
extension? The idea of this test would be exclude a problem with your
filter.

https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Relative URL when sending data

ctbogdan
Hi Alex,

I set the headers with ModHeader extension and still get the same issue.

Is there anything else I could try ?


Catalin

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].