Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Given soap url how read soap envelope for a method

$
0
0

Each soap method has envelope.how to read those envelop and assign to string like below
string str=@"<?xml version like that.

class Soap
    {
        static void Main(string[] args)
        {
            string soapStr =
    @"<?xml version=""1.0"" encoding=""utf-8""?><soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Body><CopyIntoItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/""><SourceUrl>http://devint/a/ceo/Pages/BasePage.aspx<SourceUrl><DestinationUrls><string>http://sptestmnc.nevcounty.net/Resources/Images</string></DestinationUrls><Fields><FieldInformation Type=""Text"" DisplayName=""Title"" InternalName=""Title"" Value=""{0}"" Id=""{{bc91a437-52e7-49e1-8c4e-4698904b2b6d}}"" /></Fields><Stream>{1}</Stream></CopyIntoItems></soap:Body></soap:Envelope>";

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
            req.Headers.Add("SOAPAction", "\"http://tempuri.org/" + MethodName + "\"");
            req.ContentType = "text/xml;charset=\"utf-8\"";
            req.Accept = "text/xml";
            req.Method = "POST";

            using (Stream stm = req.GetRequestStream())
            {

                soapStr = string.Format(soapStr, "testFile.png",content);
                using (StreamWriter stmw = new StreamWriter(stm))
                {
                    stmw.Write(soapStr);
                }
            }

            using (StreamReader responseReader = new StreamReader(req.GetResponse().GetResponseStream()))
            {
                XDocument ResultXML;
                string ResultString;
                string result = responseReader.ReadToEnd();
                ResultXML = XDocument.Parse(result);
                ResultString = result;
            }
        }
    }

req.Headers.Add("SOAPAction", "\"http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems\"");


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>