Skip to content

Instantly share code, notes, and snippets.

@ewg118
Created August 8, 2017 14:43
Show Gist options
  • Save ewg118/c182a8b4a69ff57bdb6b025950332e55 to your computer and use it in GitHub Desktop.
Save ewg118/c182a8b4a69ff57bdb6b025950332e55 to your computer and use it in GitHub Desktop.
Attempting to post multipart/form-data via Orbeon XForms. File attachments not working according to W3C spec
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:exist="http://exist.sourceforge.net/NS/exist"
xmlns:mods="http://www.loc.gov/mods/v3" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<head>
<title>etdpub Administration</title>
<link rel="stylesheet" href="/fr/style/bootstrap/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="/fr/style/form-runner-bootstrap-override.css" type="text/css" />
<link rel="stylesheet" href="/apps/etdpub/xforms/css/style.css" />
<xforms:model>
<xforms:instance id="control-instance" xxforms:exclude-result-prefixes="#all">
<controls xmlns="">
<crossref-api>https://test.crossref.org/servlet/deposit</crossref-api>
</controls>
</xforms:instance>
<!-- crossref authentication stored in XML file -->
<xforms:instance id="crossref-config" xxforms:exclude-result-prefixes="#all">
<xi:include href="../crossref-config.xml"></xi:include>
</xforms:instance>
<xforms:instance id="crossref-form-data" xxforms:exclude-result-prefixes="#all">
<formData xmlns="">
<operation>doMDUpload</operation>
<login_id></login_id>
<login_passwd></login_passwd>
<fname filename="" mediatype="" size=""></fname>
<!-- <fname/>-->
</formData>
</xforms:instance>
<xforms:bind nodeset="instance('crossref-form-data')">
<xforms:bind nodeset="fname" as="xs:anyURI"></xforms:bind>
</xforms:bind>
<!-- ************* SUBMISSIONS **************** -->
<xforms:submission id="post-crossref" action="{instance('control-instance')/crossref-api}" ref="instance('crossref-form-data')" instance="crossref-form-data"
replace="instance" method="form-data-post" serialization="multipart/form-data">
<xforms:message ev:event="xforms-submit-error" level="modal" value="event('response-body')"></xforms:message>
<xforms:action ev:event="xforms-submit-done">
<xforms:message level="modal" value="event('response-body')"></xforms:message>
</xforms:action>
</xforms:submission>
</xforms:model>
</head>
<body>
<xforms:upload ref="instance('crossref-form-data')/fname">
<xforms:filename ref="@filename"></xforms:filename>
<xforms:mediatype ref="@mediatype"></xforms:mediatype>
<xxforms:size ref="@size"></xxforms:size>
</xforms:upload>
<xforms:trigger>
<xforms:label>Submit</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('crossref-form-data')/login_id" value="instance('crossref-config')/username"></xforms:setvalue>
<xforms:setvalue ref="instance('crossref-form-data')/login_passwd" value="instance('crossref-config')/password"></xforms:setvalue>
<xforms:send submission="post-crossref"></xforms:send>
</xforms:action>
</xforms:trigger>
<fr:xforms-inspector id="orbeon-xforms-inspector"></fr:xforms-inspector>
</body>
</html>
@ewg118
Copy link
Author

ewg118 commented Aug 8, 2017

event('response-body') returns "No files uploaded!" on xforms-submit-error on the post-crossref submission. This is the same error response when failing to attach a file via curl on the command line. However, I am convinced that the username and password are being sent correctly in the crossref-form-data instance, as if I omit these values, I get a different response-body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment