This project is read-only.

post to mdo:service?

Dec 30, 2010 at 1:24 PM


thanks for the answer on portal-image-size, I was trying an hard way when it was so simple!

I've got a new question: is it possible to make POST calls to an mdo:service? 

I'm doing some tests with ajaxForm, and have a simple xml mdo:service I wish to call to submit a form. If I use $.get() it all works, but I see errors if I try $.post():

System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space)
at System.Xml.XPath.XPathDocument..ctor(XmlReader reader, XmlSpace space)
at System.Xml.Xsl.Runtime.XmlQueryContext.ConstructDocument(Object dataSource, String uriRelative, Uri uriResolved)
at System.Xml.Xsl.Runtime.XmlQueryContext..ctor(XmlQueryRuntime runtime, Object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, WhitespaceRuleLookup wsRules)
at System.Xml.Xsl.Runtime.XmlQueryRuntime..ctor(XmlQueryStaticData data, Object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, XmlSequenceWriter seqWrt)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(XmlReader contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
at System.Xml.Xsl.XslCompiledTransform.Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
at Findy.XsltDb.Transformer.DoTransform(XslCompiledTransform t, XmlReader xr, XsltArgumentList xslArg, StringWriter sw) in d:\inetpub\wwwroot\\App_Code\XsltDb\XsltDbUtils.cs:line 1232
at Findy.XsltDb.Transformer.TransformRelease(String xml, String xsl, Helper h, String html, Boolean IsSuper) in d:\inetpub\wwwroot\\App_Code\XsltDb\XsltDbUtils.cs:line 1010
at Findy.XsltDb.Transformer.JustTransform(String xsl, String xml, Boolean debug, Boolean IsSuper) in d:\inetpub\wwwroot\\App_Code\XsltDb\XsltDbUtils.cs:line 638
at Findy.XsltDb.Transformer.ExecuteService(String xsl, String xml, String serviceName, Boolean IsSuper) in d:\inetpub\wwwroot\\App_Code\XsltDb\XsltDbUtils.cs:line 619
at ASP.desktopmodules_xsltdb_ws_aspx.Execute() in d:\inetpub\wwwroot\\DesktopModules\XsltDb\ws.aspx:line 114
at ASP.desktopmodules_xsltdb_ws_aspx.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\\DesktopModules\XsltDb\ws.aspx:line 38

Cannot understand what is causing this error: needed parameters (mod and service) are passed.

I'm using 02.00.20.


Dec 30, 2010 at 4:36 PM

I found something about this: first of all, mdo-service can handle POST (of course ;-)).

I get the error only if I try to call with two parameters, url and data - if I add post parameters to the url it works.

That is this fails with the error from ws.aspx:


<xsl:variable name="action">{{mdo:service-url('Taconite')}}<![CDATA[&]]>action=submit</xsl:variable>

<script type="text/javascript">'{{$action}}', queryString);



while this works:

<xsl:variable name="action">{{mdo:service-url('Taconite')}}<![CDATA[&]]>action=submit</xsl:variable>

<script type="text/javascript">'{{$action}}' + '&amp;' + queryString);


Still don't know why, but it's not XsltDb's fault.


Dec 31, 2010 at 12:10 PM

Actually, this is XsltDb bug!

XsltDb service treat request body as XML without looking at request's content type.
But $.post sends data as application/x-www-form-urlencoded.
And as far as it is not XML, XsltDb fails trying to parse it as XML.

Here is a workaround:

<xsl:variable name="action">{{mdo:service-url('Taconite')}}<![CDATA[&]]>action=submit</xsl:variable>

<script type="text/javascript">
  type: 'POST',
  contentType: 'text/xml',
  dataType: 'text',
  url: '{{$action}}',
  data: "<![CDATA[<r><some-value>21212</some-value></r>]]>",
  success: function(data) {

<div id="result"/>

<mdo:service name="Taconite">


Dec 31, 2010 at 12:12 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.