How to browse a folder of Oracle Fusion UCM by SOAP request
To send a SOAP request to Oracle UCM service, you can use the WebCenter Content Generic SOAP Web Service. You can also use oracle.ucm.idcws.client UploadTool which is a generic SOAP-based transfer utility.
You can find sample SOAP requests for use in WebCenter Content (WCC/UCM) 11g and 12c calls to the GenericSoapService (GenericSoapPort) in this Oracle document.
string envelope = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ucm=\"http://www.oracle.com/UCM\"><soapenv:Body> <ucm:GenericRequest webKey=\"cs\"> <ucm:Service IdcService=\"FLD_BROWSE\"><ucm:Document><ucm:Field name=\"fFolderGUID\">FLD_ROOT</ucm:Field></ucm:Document>
</ucm:Service></ucm:GenericRequest> </soapenv:Body></soapenv:Envelope>";
using (var client = new HttpClient())
{
var req = new HttpRequestMessage(HttpMethod.Post, url);
req.Headers.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes($"{user}:{pwd}")));
var cont = new StringContent(envelope, Encoding.UTF8, "text/xml");
req.Content = cont;
req.Headers.Add("SOAPAction", "urn:GenericSoap/GenericSoapOperation");
using (var resp = client.SendAsync(req).Result)
{
if (resp.IsSuccessStatusCode)
{
var respString = resp.Content.ReadAsStringAsync().Result;
var xml = GetXml(respString);
ConsoleWriteXml(xml);
}
}
}
private static XmlDocument GetXml(string respEnvelope)
{
int start = respEnvelope.IndexOf("<env:Envelope");
int end = respEnvelope.IndexOf("</env:Envelope>");
var xml = new XmlDocument();
xml.LoadXml(respEnvelope.Substring(start, end - start + 15));
return xml;
}
private static void ConsoleWriteXml(XmlDocument d)
{
var mgr = new XmlNamespaceManager(d.NameTable);
mgr.AddNamespace("ns0", "http://www.oracle.com/UCM");
mgr.AddNamespace("env", "http://schemas.xmlsoap.org/soap/envelope/");
foreach (var x in d.DocumentElement.SelectNodes("//ns0:Document/ns0:Field", mgr).Cast<XmlNode>())
{
if (x.Attributes["name"].Value != "AttributeInfo")
Console.WriteLine($"{x.Attributes["name"].Value} : {x.InnerText}");
}
var fi = d.DocumentElement.SelectSingleNode("//ns0:ResultSet[@name='FolderInfo']", mgr);
}