10 Replies Latest reply on Feb 15, 2012 7:35 PM by JimG

    Loging into OSES using Search Service API


      we are currently trying to develo a custom search application using Oracle Secure Enterprise Search. We successfully installed the the system and, using the GUI administration, crawled serveral sources, including an NTFS typ, requiring authentication to be searchable. Logging in via the searche's GUI works fine, i.e. after logging in search results from the NTFS collection are found as well. However, doing the same via the OSES JAVA API does not return any search results from the NTFS collection, although the logging in returns as status "successfull". What goes wrong? Why doesn't the login change the search results as expected? I attach the source code below:

      OracleSearchServiceLocator locator = new OracleSearchServiceLocator();

      OracleSearchPort port = locator.getOracleSearchPort();
      Status status = port.login(username, password);
      System.out.println("Status: " + status.getStatus()); // prints "Status: successfull"
      OracleSearchResult result = port.doOracleSimpleSearch(searchTerm, 0, 10, false, false, true);
      System.out.println(result.getEstimatedHitCount()); // prints 26 instead 31
        • 1. Re: Loging into OSES using Search Service API
          I have exactly the same issue.

          When I use the provided broswer interface, I get far more results when I log in than when I don't log in.

          When I use the api, I get the same results whether or not I log in. I'm only getting the results that are visible to everyone, not the results where my login has access.
          • 2. Re: Loging into OSES using Search Service API
            Roger Ford-Oracle
            Can you post the code you're using? Is it the same as the earlier post?
            • 3. Re: Loging into OSES using Search Service API
              It's pretty close.

              I've written it in C#. The bolded lines are the calls to the webservice.

              String strUsername = textBoxUsername.Text.ToString();
              String strPassword = textBoxPassword.Text.ToString();
              String strSearch = textBoxSearchString.Text.ToString();
              OracleSearchResult osr = new OracleSearchResult();
              Status stat = new Status();
              stat.status = "successful";
              String strResults = "";

              int nCount = 0;

              if (checkBoxLogin.Checked)
              strResults = "AttemptingLogin";
              textBoxResults.Text = strResults;
              stat = oses.login(strUsername, strPassword);
              strResults = String.Format("Login {0}", stat.status);
              textBoxResults.Text = strResults;

              if (stat.status == "successful")
              osr = oses.doOracleSimpleSearch(strSearch, 1, 1000, false, false, true);

              if (checkBoxLogin.Checked)

              nCount = osr.docsReturned;


              strResults = String.Format("Query: {0}\r\n", strSearch);
              strResults += String.Format("query returned {0} results\r\n", nCount);
              for (int i = 0; i < nCount; ++i)
              strResults += String.Format(osr.resultElements[ i ].url);
              strResults += "\r\n";
              textBoxResults.Text = strResults;


              Edited by: JimG on Feb 6, 2012 1:21 PM
              • 4. Re: Loging into OSES using Search Service API
                Roger Ford-Oracle
                Looks OK - are you sure it's going through the login code section?

                To display code better wrap it in { code } tags

                { code }
                blah blah
                { code }

                - without the spaces between the braces and the word code. Will then look like:
                blah blah
                Note the start and end tags are the same, there are no slashes or anything.
                • 5. Re: Loging into OSES using Search Service API
                  Yes, I'm sure. I single-stepped through the code. And I added the optional login logic after first encountering the problem.
                  • 6. Re: Loging into OSES using Search Service API
                    Roger Ford-Oracle
                    I don't suppose you have two SES servers connected by a load balancer? If that were the case, it would be possible for the login request to go to one server, but the search request to another.

                    Otherwise, I wonder if perhaps C# is not maintaining the context between the login and the search. I'm not sure how the context is held - I'm guessing there's a cookie involved. Could it be that something is preventing the cookie from being stored?
                    • 7. Re: Loging into OSES using Search Service API
                      No, I don't. It is a single instance.

                      I don't know how the context is maintained either. They are separate calls to login and doOracleSimpleSearch. There is no parameter in the doOracleSimpleSearch method (or any of the doOracle*Search methods) to indicate whether or not to use the login information.

                      It seems like that may be an oversight in the API to not allow logged in searches?
                      • 8. Re: Loging into OSES using Search Service API
                        I discovered that if I dig through the base classes of the instance of the OracleSearchService class there is variable named cookieJar and another one named CookieContainer that are both set to null even after I log in
                        • 9. Re: Loging into OSES using Search Service API
                          Also tried this with a Java application with the same results.

                          Also experimented with the method setSessionContext() with no luck.

                          I've captured the HTML stream, and I do see that the server is returninig "Set-Cookie: JSESSIONID=..." with each response, but I don't see that value being sent back from my client on the next call. Since .Net automatically creates the code that builds the response, I don't have direct control over that. Should that be in the SOAP envelope? In the HTML?

                          Below is the packet that is sent when I call the doOracleSimpleSearch() method:
                          POST /search/query/OracleSearch HTTP/1.1
                          User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.239)
                          VsDebuggerCausalityData: uIDPo42WgOBikQlDqj3ZSze+U14AAAAAhXChmxroT0ivenjNI3AdiI8o74URZCZLuA2j9qJZnoMACQAA
                          Content-Type: text/xml; charset=utf-8
                          SOAPAction: ""
                          Host: oracleses:7777
                          Content-Length: 912
                          Expect: 100-continue
                          <?xml version="1.0" encoding="utf-8"?>
                          <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://oracle.search.query.webservice/OracleSearchService.wsdl" xmlns:types="http://oracle.search.query.webservice/OracleSearchService.wsdl/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                             <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                                <q1:doOracleSimpleSearch xmlns:q1="OracleSearchService">
                                   <query xsi:type="xsd:string">test</query>
                                   <startIndex xsi:type="xsd:int">1</startIndex>
                                   <docsRequested xsi:type="xsd:int">1000</docsRequested>
                                   <dupRemoved xsi:type="xsd:boolean">false</dupRemoved>
                                   <dupMarked xsi:type="xsd:boolean">false</dupMarked>
                                   <returnCount xsi:type="xsd:boolean">true</returnCount>
                          Edited by: JimG on Feb 14, 2012 9:49 AM
                          • 10. Re: Loging into OSES using Search Service API
                            Solved! At least in .NET.

                            I was actually on the right track before. The CookieContainer class must be initialized before logging in.

                            I found
                            which describes how to do it in .NET

                            Also, when using Java, this blog describes how to do it there (my java developer will be trying that approach).

                            Edited by: JimG on Feb 15, 2012 1:34 PM

                            Edited by: JimG on Feb 15, 2012 1:35 PM