Using Xforms App as a service

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

Using Xforms App as a service

Harshal
Hello All,

I have xforms code which I want to call from two different xforms apps.

I have implemented this as follows:
- common xforms code (lets call it XC) is written as separate app
- other xforms apps (lets call them X1 and X2) are calling XC using post-submission with replace attribute set to none

Alternate way to achieve this would be either including XC in both X1 and X2 using xi:include or
by rewriting XC code in XPL.

I am wondering if there is any alternate and better way to do this .

Thanks,
Harshal

Reply | Threaded
Open this post in threaded view
|

Re: Using Xforms App as a service

Harshal
After playing a little with XML processors in epilogue.xpl, This is what I came up with:

1. Add entry in page-flow.xml
<config xmlns="http://www.orbeon.com/oxf/controller">
    <page path-info="/Services/XForms/test-service" view="/Services/XForms/test-service.xhtml"/>
    <epilogue url="oxf:/config/xforms-service-epilogue.xpl"/>
</config>

xforms-service-epilogue.xpl is attachedxforms-service-epilogue.xpl

2. Call test-service.xhtml with xforms:submission

3. In test-service.xhtml write a processing code inside xforms-model-construct-done event.
Inside xforms:body put only single xforms:output statement with id which outputs result of service.

sample test-service.xhtml reads as follows:
<xhtml:html
    xmlns:xforms="http://www.w3.org/2002/xforms" 
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:head>
   <xforms:model>
       <xforms:instace id="result"><result/><xforms:instance>
       <xforms:action ev:event="xforms-model-construct-done">
         
        </xforms:action>
   </xforms:model>
</xhtml:head>
<xhtml:body>
   <xforms:output id="response" ref="instance('result')"/>
</xhtml:body>
</xhtml:html>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Using Xforms App as a service

Erik Bruchez
Administrator
Thanks for sharing this.

Your approach is ok.

For a long time now we have been wanting to add the ability to create
services returning XML fully in XForms. I.e. you could write:

<result>
  <xf:model>…</xf:model>
  <foo><xf:output value="…"/>
</result>

There is already some code going in that direction, but it's not fully
baked yet.

Another option which works now is to use a submission with
replace="all" and the "echo:" protocol:

<xf:submission id="fr-send-stats" ref="instance('fr-import-stats')"
method="post" action="echo:" replace="all"/>

If you run this upon XForms initialization, instance "fr-import-stats"
will be the response of loading that XForms document. There is no need
to change the epilogue this way.

-Erik

On Thu, Aug 2, 2012 at 2:10 PM, Harshal <[hidden email]> wrote:

> After playing a little with XML processors in epilogue.xpl, This is what I
> came up with:
>
> 1. Add entry in page-flow.xml
> <config xmlns="http://www.orbeon.com/oxf/controller">
>     <page path-info="/Services/XForms/test-service"
> view="/Services/XForms/test-service.xhtml"/>
>     <epilogue url="oxf:/config/xforms-service-epilogue.xpl"/>
> </config>
>
> xforms-service-epilogue.xpl is attached
> http://orbeon-forms-ops-users.24843.n4.nabble.com/file/n4655572/xforms-service-epilogue.xpl
> xforms-service-epilogue.xpl
>
> 2. Call test-service.xhtml with xforms:submission
>
> 3. In test-service.xhtml write a processing code inside
> xforms-model-construct-done event.
> Inside xforms:body put only single xforms:output statement with id which
> outputs result of service.
>
> sample test-service.xhtml reads as follows:
> <xhtml:html
>     xmlns:xforms="http://www.w3.org/2002/xforms"
>     xmlns:xhtml="http://www.w3.org/1999/xhtml">
> <xhtml:head>
>    <xforms:model>
>        <xforms:instace id="result"><result/><xforms:instance>
>        <xforms:action ev:event="xforms-model-construct-done">
>
>         </xforms:action>
>    </xforms:model>
> </xhtml:head>
> <xhtml:body>
>    <xforms:output id="response" ref="instance('result')"/>
> </xhtml:body>
> </xhtml:html>
>
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Using-Xforms-App-as-a-service-tp4655550p4655572.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Using Xforms App as a service

Harshal
Thanks Erik.

I tried echo: URL scheme as you suggested.
But I get following error-

Expected scheme-specific part at index 5: echo:

Orbeon Version: 3.9.0.201105152046 CE

I also tried echo: scheme on other submissions and that fails with same error as well.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Using Xforms App as a service

Erik Bruchez
Administrator
The "echo:" scheme might have been implemented after that. A precursor
was called "test:". Does that one work for you?

-Erik

On Thu, Aug 9, 2012 at 1:25 PM, Harshal <[hidden email]> wrote:

> Thanks Erik.
>
> I tried echo: URL scheme as you suggested.
> But I get following error-
>
> /Expected scheme-specific part at index 5: echo:/
>
> Orbeon Version: 3.9.0.201105152046 CE
>
>
> I also tried echo: scheme on other submissions and that fails with same
> error as well.
>
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Using-Xforms-App-as-a-service-tp4655550p4655610.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Using Xforms App as a service

Harshal
I tried "test:" scheme as well.
But it works only with replace="none" or replace="instance".

action="test:" and replace="all" fails with same error.
java.net.URISyntaxException: Expected scheme-specific part at index 5: test:

I repeated experiment with milestone build (4.0.0.m9.201208080300 CE) and it worked perfectly
with "echo:" scheme and replace="all"

Thanks for all the help.

--Harshal