Lumesse Forums

General

RSS Feed

FoAdvert WS getSimpleAdvertisements returns empty string

  1. Im trying to run an example (getSimpleAdvertisements - Live) provided within "Career Portal Web Service bundle activation".

    Here is my code private void button1_Click(object sender, EventArgs e) {
    //Create a request object System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://api3.lumesse-talenthub.com/CareerPortal/SOAP/FoAdvert?api_key=testAPIKEY");

            request.ContentType = "text/xml;charset=\"utf-8\"";
            request.Method = "POST";
            request.Headers.Add("SOAPAction", "\"\"");
            //request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
            //request.AutomaticDecompression = DecompressionMethods.None;
    
            string soap = @"<soapenv:Envelope xmlns:ws=""http://ws.mrted.com/"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">
                              <soapenv:Header>
                                <wsse:Security xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" soapenv:mustUnderstand=""1"">
                                  <wsse:UsernameToken wsu:Id=""UsernameToken-2"">
                                    <wsse:Username>TESTCREDENTIAL</wsse:Username>
                                    <wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"">TEST</wsse:Password>
                                    <wsse:Nonce EncodingType=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"">LDLrK/6rRWC8+HymCyYrNQ==</wsse:Nonce>
                                    <wsu:Created>2013-06-27T08:48:35.153Z</wsu:Created>
                                  </wsse:UsernameToken>
                                </wsse:Security>
                              </soapenv:Header>-<soapenv:Body>
                                <ws:getSimpleAdvertisements>
                                  <ws:firstResult>0</ws:firstResult>
                                  <ws:maxResults>10</ws:maxResults>
                                  <ws:searchCriteriaDto/>
                                  <ws:sortingDetailsDto/>
                                  <ws:langCode>US</ws:langCode>
                                </ws:getSimpleAdvertisements>
                              </soapenv:Body>
                            </soapenv:Envelope>
                            ";
    
            System.IO.StreamWriter objStream = new System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.UTF8);
            objStream.Write(soap);
            objStream.Close();
            objStream = null;
    
            HttpWebResponse objHTTPRes = default(HttpWebResponse);
            objHTTPRes = (HttpWebResponse)request.GetResponse();
            System.IO.Stream SourceStream = objHTTPRes.GetResponseStream();
    
            //It's up to you how you save the response 
            //You could save it as an XML document
            System.Xml.XmlDocument objXML = new System.Xml.XmlDocument();
            objXML.Load(SourceStream);
    
            //Or you could save it to a String
            string ret = null;
            System.IO.StreamReader sr = new System.IO.StreamReader(SourceStream);
            ret = sr.ReadToEnd();
    
            MessageBox.Show(ret);
    
        }
    

    It returns an empty string. But in the example it supposed to return one job advert.

    Message edited by Chandra Sheshan 5 years ago

  2. Chandra Sheshan5 years ago

    Hi,

    I have tested the same in .NET and it does currently return 3 advertisements. It would be helpful if you could package your application and send across. We Will be able to resolve this at the earliest.

  3. Chandra Sheshan5 years ago

    Further testing your code. There is only one change that needs to be applied. Please uncomment line and change it to below request.AutomaticDecompression = DecompressionMethods.GZip;

    FYR, Below is the working code.

    string m_URL = "https://api3.lumesse-talenthub.com/CareerPortal/SOAP/FoAdvert?api_key=ReplaceActualKey"; System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(m_URL); request.ContentType = "text/xml;charset=\"utf-8\""; request.Method = "POST"; request.Headers.Add("SOAPAction", "\"\""); request.AutomaticDecompression = DecompressionMethods.GZip;

            string m_PostMsg = "";
    
            m_PostMsg = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                        <soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ws=""http://ws.mrted.com/"">
                        <soapenv:Header>
                        <wsse:Security soapenv:mustUnderstand=""1"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">
                        <wsse:UsernameToken wsu:Id=""UsernameToken-3"">
                        <wsse:Username>REPLACE-USERNAME</wsse:Username>
                        <wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"">REPLACE-PASSWORD</wsse:Password>
                        </wsse:UsernameToken>
                        </wsse:Security>
                        </soapenv:Header>
                        <soapenv:Body>
                        <ws:getSimpleAdvertisements>
                            <ws:firstResult>0</ws:firstResult>
                            <ws:maxResults>10</ws:maxResults>
                            <ws:searchCriteriaDto/>
                            <ws:sortingDetailsDto/>
                            <ws:langCode>US</ws:langCode>
                        </ws:getSimpleAdvertisements>
                        </soapenv:Body>
                        </soapenv:Envelope>";
    
            System.IO.StreamWriter objStream = new System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.UTF8);
            objStream.Write(m_PostMsg);
            objStream.Close();
            objStream = null;
    
            HttpWebResponse objHTTPRes = default(HttpWebResponse);
            objHTTPRes = (HttpWebResponse)request.GetResponse();
            System.IO.Stream SourceStream = objHTTPRes.GetResponseStream();
    
            //get the response as an xml document so we can access specific nodes
            System.Xml.XmlDocument objXML = new System.Xml.XmlDocument();
            objXML.Load(SourceStream);
    
[ Page 1 of 1 ]