Making InfoPath XML data source scrape data from a web part page - InfoPath Dev
in

InfoPath Dev

Making InfoPath XML data source scrape data from a web part page

Last post 11-30-2012 01:54 AM by saurabh.dasgupta. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-29-2012 11:20 AM

    Making InfoPath XML data source scrape data from a web part page

    Hi all,
    I have a custom Sand box web part on a page which emits some information. The objective is to read this data using a XML file data connection from within InfoPath. This is IP 2007 in client mode. The data emitted by the web part is as simple as
    <data>some text</data>
    While browsing the web part page through IE the emitted data is correctly interpreted as XML.
    However, InfoPath will not let me create a data connection to this URL.
    The error message is
    The file is not a valid XML document. 
    
    Illegal qualified name character. Line 1, Position 2 
    

    Any clues? I know my information here is sparse. Thanks in advance.
  • 11-29-2012 04:02 PM In reply to

    Re: Making InfoPath XML data source scrape data from a web part page

    Do you have the following line at the beginning?

    <?xml version="1.0" encoding="UTF-8"?>

    Patrick Halstead
    Project Manager at Qdabra
  • 11-30-2012 12:47 AM In reply to

    Re: Making InfoPath XML data source scrape data from a web part page

    Hell Patrick,

    I tried this, but no luck. What surprises me is that I followed a similar approach in for another InfoPath which was scraping off a SP 2007 web page that had a SPDatasource in it and there was never a problem at all.I just ensured that the data from that page was a well formed XML.

     

    The code in the SharePoint page looks like this:
    <%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage" ContentType="text/xml" ResponseEncoding="utf-8" %>
    <%@ Register Tagprefix="WebPartPages"
        Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
        Namespace="Microsoft.SharePoint.WebPartPages" %><WebPartPages:SPUserCodeWebPart FrameType="None"
        SuppressWebPartChrome="True"  runat="server"   AssemblyFullName="IDSWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11e3ded9dc4537f1" SolutionId="83abfeb7-4747-4aca-9822-bee1a0e2b32c" ID="g_c96983fc_c9b5_409d_b39a_93c431b85927" TypeFullName="IDSWebParts.ExtractInfo.ExtractInfo"  WebPart="true"  ><Properties>
    <WebPartPages:SPUserCodeProperty Name="CountryRegionMappingListName" Value="CountryRegion"></WebPartPages:SPUserCodeProperty>
    </Properties>
    </WebPartPages:SPUserCodeWebPart>
    
    The code within the web part is something like this:
     
    
            {
                string login = "";
                string username = "";
                string citycode = "";
                string regioncode = "";
                string message = "";
                try
                {
                    GetInfo(out login, out username, out citycode, out regioncode);
                    writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    message = string.Format("<data>userdata,{0},{1},{2},{3},{4}</data>", login, username, citycode, regioncode,DateTime.Now.ToLongTimeString());
                    writer.Write(message);
                }
                catch (Exception ex)
                {
                    message = ex.ToString();
                    writer.Write(message);
                }           
            }
    
    
  • 11-30-2012 12:48 AM In reply to

    Re: Making InfoPath XML data source scrape data from a web part page

    I am now comparing the fiddler response on a sample InfoPath form which reads off a web page on SP 2007 and also my page on SP 2010. I do see a difference in the headers.

  • 11-30-2012 01:54 AM In reply to

    Re: Making InfoPath XML data source scrape data from a web part page

    I might have solved this. When I try to establish a data connection to  a /someservre/sites/site100/folder001/SomePage.aspx on SharePoint, InfoPath 2007 tries to determine some meta-data by calling the older RPC methods. Now, strangely InfoPath comes to the conclusion that this page is a document that might have been cached on the local disk and issues a request with the HEAD protocol. The response of this request has content with zero bytes and hence the error message "Illegal .."

    To solve this, I suffixed a query parameter at the end of the URL. /someservre/sites/site100/folder001/SomePage.aspx?junk=100 and this worked magically!

    A day of efforts lost. But, atleast I found a way out. I have not done a detailed dissection of what else is going on. I will press on with my actual work.

     

     

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.