Search
Xopher Design
Xopher Design > Posts
  
Get InfoPath submitted xml via web services using anonymous
//the list.svc does not appear to work on anonymous sites so we have to go old school. This is a hodgepodge of tutorial code mixed together so don't mind the formatting and traversal inconsistancies

{
            listsWR.Lists extLists = new listsWR.Lists();
            extLists.Url = "http://blahblah/_vti_bin/lists.asmx";
            extLists.UseDefaultCredentials = true;

            XmlDocument xDoc = new XmlDocument();
            XmlNode ndQuery = xDoc.CreateNode(XmlNodeType.Element, "Query", "");
            XmlNode ndViewFields = xDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
            XmlNode ndQueryOptions = xDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

            ndQuery.InnerXml = "";
            ndViewFields.InnerXml = "";
            ndQueryOptions.InnerXml = "";

            XmlNode rNodes =  extLists.GetListItems("ListName", "", ndQuery, ndViewFields, null, ndQueryOptions, null);

            foreach (XmlNode node in rNodes)
            {
                if (node.Name == "rs:data")
                {
                    for (int i = 0; i < node.ChildNodes.Count; i++)
                    {
                        if (node.ChildNodes[i].Name == "z:row")
                        {
                            for (int j = 0; j < node.ChildNodes[i].Attributes.Count; j++)
                            {
                                if (node.ChildNodes[i].Attributes[j].Name == "ows_Modified" || node.ChildNodes[i].Attributes[j].Name == "ows_Title")
                                {
                                    Literal1.Text += "<b>" + node.ChildNodes[i].Attributes[j].Name + "</b>=" + node.ChildNodes[i].Attributes[j].Value + "<br/>";
                                }
                                else if (node.ChildNodes[i].Attributes[j].Name == "ows_EncodedAbsUrl")
                                {
                                    copyWR.Copy myCopyWR = new copyWR.Copy();
                                    myCopyWR.UseDefaultCredentials = true;
                                    string copySource = node.ChildNodes[i].Attributes[j].Value;
                                    // Define the variables that will store the output from the web service call
                                    copyWR.FieldInformation myFieldInfo = new copyWR.FieldInformation();
                                    copyWR.FieldInformation[] myFieldInfoArray = { myFieldInfo };
                                    byte[] myByteArray;
                                    // Call the web service
                                    uint myGetUint = myCopyWR.GetItem(copySource, out myFieldInfoArray, out myByteArray);
                                    // Convert into Base64 String
                                    string base64String;
                                    base64String = Convert.ToBase64String(myByteArray, 0, myByteArray.Length);
                                    // Convert to binary array
                                    byte[] binaryData = Convert.FromBase64String(base64String);
                                    System.IO.MemoryStream myInStream = new System.IO.MemoryStream(binaryData);
                                    XmlDocument doc = new XmlDocument();
                                    doc.Load(myInStream);
                                    foreach (XmlNode fNode in doc.ChildNodes)
                                    {
                                        if (fNode.Name == "my:FormFields")
                                        {
                                            foreach (XmlNode myFormNode in fNode.ChildNodes)
                                            {
                                                Literal1.Text += "<b>------:" + myFormNode.Name + "</b>=" + myFormNode.InnerText + "<br/>";
                                            }
                                        }
                                    }
                                }
                            }
                            Literal1.Text += "---------------------------------------------------------------------------</br>";
                        }
                    }
                }

            }
            
        }
​Responses
  
There are no items to show in this view of the "Responses" list. To add a new item, click "New".