Login  Register

Re: Re: multiple instances submission

Posted by Alexandru Ionita on Dec 13, 2009; 4:22pm
URL: https://discuss.orbeon.com/multiple-instances-submission-tp954566p963013.html


Hello again. 

The things are not moving very smooth with XPL. I'm trying to send an XML instance over SOAP and first I have to escape the XML instance in order to send it over SOAP. But this seams not to be as trivial as I thought because the type of the Java method is String and the xs:string attribute is loosing it's schema during the XSTL process since it is not needed from it's point of view. So far I didn't find ways to force the XSLT processor to keep the schema. (Tried also to add a dummy attribute with that schema, but nothing happens. I suppose that the xml is not valid anymore and Orbeon doesn't take it into account).
Below you may find the XPL file.

regards,
Alexandru


<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:delegation="http://orbeon.org/oxf/xml/delegation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://localhost:13569/InvoiceCyclePSNV/services/CheckFormController">

<p:param name="formData" type="input" debug="form-data"/> 
<p:param name="checkMessages" type="output"/>

<p:processor name="oxf:xslt">
<p:input name="data" href="#formData" />
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<xsl:element name="result">
<xsl:element name="delegation:execute">
<xsl:attribute name="service">escape-xml</xsl:attribute>
<xsl:attribute name="operation">escapeXml</xsl:attribute>
<xsl:element name="param1">
<xsl:attribute name="xsi:type">xs:string</xsl:attribute>
<xsl:copy-of select="/user-response/updatedXformModel"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:output name="data" id="sub-pipeline-config" />
</p:processor> 
<p:processor name="oxf:delegation">
<p:input name="formData" href="#formData" debug="form-data"/>
<p:input name="interface">
<config>
<service id="escape-xml" type="javabean" class="org.apache.commons.lang.StringEscapeUtils" />
</config>
</p:input>
<p:input name="call" href="#sub-pipeline-config"/> 
<p:output name="data" ref="checkMessages" debug="escapedXml"/>
</p:processor>


</p:config>

On Sun, Dec 13, 2009 at 10:18, Alexandru Ionita <[hidden email]> wrote:

Ok,

For now I found the solution about building the XPL that will call the webservice and send the appropriate parameters. What I don't know for now is how to send/receive the XML content to/from webservice, since SOAP is not able to handle XML content in the parameters (or at least I don't know how to do make it to accept XML content in the in/out parameters). 

I was thinking to encode/decode the XML before and after calling the webservice. Is this a good idea?

Here is how my XLP looks like:

<p:param name="formData" type="input" debug="form-data"/> 
<p:param name="checkMessages" type="output"/>

<p:processor name="oxf:xslt">
<p:input name="data" href="#formData" />
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<xsl:element name="delegation:execute">
<xsl:attribute name="service">check-form</xsl:attribute>
<xsl:attribute name="operation">checkForm</xsl:attribute>
<xsl:element name="id0">
<xsl:value-of select="/user-response/sapRequestId"/> 
</xsl:element>
<xsl:element name="id1" >
<xsl:copy-of select="/user-response/updatedXformModel"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:output name="data" id="sub-pipeline-config" />
</p:processor> 
<p:processor name="oxf:delegation">
<p:input name="formData" href="#formData" debug="form-data"/>
<p:input name="interface">
<config>
<service id="check-form" type="webservice" style="rpc"
<operation nsuri="urn:avernet" name="checkForm" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</service>
</config>
</p:input>
<p:input name="call" href="#sub-pipeline-config"/> 
<p:output name="checkMessages" ref="checkMessages" />
</p:processor>


regards,
Alexandru




On Fri, Dec 11, 2009 at 10:27, Alexandru Ionita <[hidden email]> wrote:


Hello Erik,

thanks for your reply.

Meanwhile I have changed my logic and what I'm trying to do now is to call a pipeline with two input parameters like this:

<xf:insert nodeset="instance('formCheckMessages')"
               origin="xxforms:call-xpl(
               '<%=StringUtils.getRemoteXplProcessor(StringUtils.CHECK_FORM_PROCESSOR) %>', 
               ('requestId','formData'), 
               (instance('userResponse')/sapRequestId, instance('content')), 'checkMessages')"/>


and the pipe line is like this:


<p:param name="requestId" type="input" debug="req-id"/> 
<p:param name="formData" type="input" debug="form-data"/> 
<p:param name="checkMessages" type="output"/> 
<p:processor name="oxf:delegation">
<p:input name="requestId" href="#requestId" debug="req-id"/>
<p:input name="formData" href="#formData" debug="form-data"/>
<p:input name="interface">
<config>
<service id="check-form" type="webservice" style="document"
<operation name="checkForm" soap-action="checkForm" />
</service>
</config>
</p:input>
<p:input name="call">
<delegation:execute service="check-form" operation="checkForm">
<m:checkForm>
<m:requestId></m:requestId>
<m:formData></m:formData>
</m:checkForm>
</delegation:execute>
</p:input>
<p:output name="checkMessages" ref="checkMessages" />
</p:processor>


</p:config>




but my problem now is that I don't know how to refer these two input parameters inside the webservice call. The first one, requestId, is a long variable and the second, formData, is a xml instance that is backing the xform and I want to send it as it is (xml) to the webservice.


Thanks and regards,
Alexandru 


On Fri, Dec 11, 2009 at 04:33, Erik Bruchez <[hidden email]> wrote:
Alexandru,

Something like this should work:

<xf:submission id="postResponse" method="post"
ref="instance('aggregate')" action="/service/dispatchRequest.do">
   <xforms:action ev:event="xforms-submit">
       <xf:delete nodeset="instance('aggregate')/*"/>
       <xf:insert context="instance('aggregate')" nodeset="*"
origin="instance('userResponse')"/>
       <xf:insert context="instance('aggregate')" nodeset="*"
origin="instance('initialData')"/>
   </xforms:action>
</xf:submission>

<xf:instance id="aggregate">
 <response/>
</xf:instance>

Re. question 2, yes it's possible. You can do this with 2 submissions:

* 1st one submits data to your service implemented in XPL and
retrieves the result
* Upon 1st submission's xforms-submit-done, send 2nd submission

-Erik

On Mon, Dec 7, 2009 at 9:46 AM, Alexandru Ionita
<[hidden email]> wrote:
>
>
> Hello guys,
>
> I have two questions:
>
> 1. How can I submit multiple instances to a J2EE servlet? now I do it like
> this:
>
> <xf:submission id="postResponse" method="post"
> ref="instance('userResponse')" action="/service/dispatchRequest.do"/>
>
> <xf:action ev:event="DOMActivate">
>   <xf:setvalue ref="/user-response/userAction">accept</xf:setvalue>
>   <xf:send submission="postResponse"/>
> </xf:action>
>
> but I want to merge the instance of userResponse with another instance
> available in my model. Something similar to aggregate("response",
> instance('userResponse'), instance('initialData'))   (this is not working
> unfortunately).
>
> and the 2nd question: is there possible to submit this model to a pipe line
> processor, apply some rules on it and then post the final response to the
> particular J2EE servlet.
>
>
> Thank you,
> Alexandru
>
>
> --
> 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






--
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