0

I am using some c# .net webapplication. This webapplication is execute some webmethods from a webservice from SharePoint. It is doing some CRUDS functionality on a document library. Is it possible to monitor/watch the xml from the request and response of these sharepoint webservice requests/response?

Maybe somewhere on the sharepoint servers, maybe logging? Where can I see/find the xml?

2
  • 1
    All communications to web services can be captured with Fiddler (on the client and / or on the server itself) – Robert Lindgren Dec 15 '14 at 11:05
  • 1
    Even Firebug, the Chrome dev tools, and IE Dev tools can view the XML going back and forth. Just hit F12 in your browser and go to the Network tab to start viewing the traffic. – Eric Alexander Dec 15 '14 at 13:13
0

from what i know Robert is correct, as you are creating a webapp you can also send/request this xml info as the webservice also sends and recives this info!

this is slightly complex but simple! I am updating a list with a batch request to a webservice, obviously I wanted to know the output which below does for me:

    private void batchUpdateItems(string listGUID, string listViewId, StringBuilder sb, string siteUrl)
    {
        /*Declare and initialize a variable for the Lists Web service.*/
        serviceWebRef.Lists listService = new serviceWebRef.Lists();

        /*Authenticate the current user by passing their default
        credentials to the Web service from the system credential cache.*/
        listService.UseDefaultCredentials = true;
        listService.PreAuthenticate = true;
        listService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

        /*Set the Url property of the service for the path to a subsite.*/
        listService.Url = siteUrl+"/_vti_bin/Lists.asmx";

        /*Get Name attribute values (GUIDs) for list and view. */
        string strListID = listGUID;
        string strViewID = listViewId;

        /*Create an XmlDocument object and construct a Batch element and its
        attributes. Note that an empty ViewName parameter causes the method to use the default view. */
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
        batchElement.SetAttribute("OnError", "Continue");
        batchElement.SetAttribute("ListVersion", "1");
        batchElement.SetAttribute("ViewName", strViewID);

        /*Specify methods for the batch post using CAML. To update or delete, 
        specify the ID of the item, and to update or add, specify 
        the value to place in the specified column.*/
        batchElement.InnerXml = sb.ToString();

        /*Update list items. This uses the list GUID, 
        but the list display name will also work.*/
        try
        {
            XmlNode xmlnodes = listService.UpdateListItems(strListID, batchElement);
            XmlNamespaceManager nsm = new XmlNamespaceManager(xmlnodes.OwnerDocument.NameTable);
            nsm.AddNamespace("sp", xmlnodes.NamespaceURI);

            XmlNodeList results = xmlnodes.SelectNodes("//sp:Result", nsm);
            foreach (XmlNode result in results)
            {
                //print out xml result from xmlnode sent from webservice
                XmlNode node = result.SelectSingleNode("./sp:ErrorCode", nsm);
                WriteLog(node.OuterXml + Environment.NewLine);
            }
        }
        catch (SoapServerException ex)
        {
            WriteLog("service error : " + ex.Message + ex.InnerException + ex.StackTrace + ex.Source + Environment.NewLine);
        }

    }

the important part is the fact that im sending the webservice an xml chucnk here:

listService.UpdateListItems(strListID, batchElement);

then im putting the result xml in a xmlnode so i can read from it:

XmlNode xmlnodes = listService.UpdateListItems(strListID, batchElement);
1
  • Thank you for the great answer. But what to do If I do not have access to the source code of this webapplication? Where can I find the xml of the request and response? IIS log, ULS log, eventviewer??? – Ola Dec 15 '14 at 13:13
0

I am using Fiddler (listening on port 8888) together with this code:

        clientContext.ExecutingWebRequest += (sen, args) =>
        {
            var proxy = new System.Net.WebProxy
                        {
                            Address = new Uri("http://localhost:8888"),
                            //Credentials = new System.Net.NetworkCredential(this.proxyUserName, this.proxyPassword)
                        };
            args.WebRequestExecutor.WebRequest.Proxy = proxy;
        };

I don't know if that helps.

But I cannot say I understand the XMLs that I see much... :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.