كيفية الاستعلام عن خدمة فهرس Windows 2008 X64 من تطبيقات ASP 32 بت؟
-
29-09-2019 - |
سؤال
لقد تعثرت مؤخرًا على مشكلة تتضمن نقل مواقع ASP الكلاسيكية من خادم W2K3 إلى بيئة W2K8 64. وشملت الحصول على خدمات الفهرسة للعمل مع ASP Classic. لقد بحثت في كل مكان جربت فيه العديد من الحلول وفشلوا جميعًا.
المشكلة: أدى تشغيل خدمة فهرسة 64 بت على تجمع تطبيقات 32bit (لـ ASP Classic) لطلب تشغيل طلب ASP إلى خدمة الفهرسة إلى خطأ حيث فشل كائن الخادم في التحميل. على الرغم من أن خدمة الفهرسة كانت تعمل والمجلد الذي يحتوي على مستندات للموقع حيث تم فهرسة خدمة الفهرسة في وضع 64 بت والمجمع في وضع 32 بت. لم يكن من الممكن الركض.
كانت بعض الحلول المقترحة هي إعادة كتابة الكود لاستخدام "بحث Windows" الجديد ، ولكن نظرًا لأن هذا يعمل أيضًا في 64 بت ، لا يمكن تشغيله في وضع تطبيق 32 بت. أدى التبديل إلى وضع متوافق مع 32 بت في تجمع إلى عدم وجود قواعد بيانات عمل وغيرها من كائنات COM المستخدمة في مواقع ASP.
المحلول
بعد بضعة أيام ، استسلمت تقريبًا ، لكن في منتصف الليل حصلت على فكرة رائعة لجعلها تعمل كل شيء. ماذا لو قمت بإجراء مكالمة AJAX إلى مجال فرعي على خادم الويب الذي يعمل في وضع 64 بت مع الدلائل الافتراضية التي تحتوي على الدلائل المفهرسة للمواقع التي تعمل في وضع تطبيق 32 بت.
في اليوم التالي بعد نوم مضطرب ، حصلت على العمل ، أضافت نطاقًا فرعيًا جديدًا في IIS7 أضافت الدلائل الافتراضية إلى الدلائل المفهرسة للمواقع الإلكترونية. وأضفت صفحة "indexer.asp" التي تحتوي على معالج طلب.
<%@ Language=VBScript %><%
Option explicit
response.buffer=true
dim RequestIndex, strFileError, RequestSearchString, FSOA, RequestMax
RequestIndex=request.querystring("Index")
RequestSearchString=request.querystring("Search")
RequestMax=request.querystring("Size")
' INDEXER
sub DoIndexSearch(target, RequestIndex)
dim foundfilearray:foundfilearray=false
dim ixQuery ' Index Server query object.
set ixQuery = Server.CreateObject("ixsso.Query")
if (Err.description <> "") Then
strFileError= ("<div><strong>Query object Error : " & Err.description & ".</strong></div>")
response.write strFileError
Exit sub
end if
ixQuery.Query =(target)
'ixQuery.SortBy = "DocLastSavedTm[d]"
ixQuery.SortBy = "Rank[d]"
ixQuery.Columns = "FileName," 'Parameter: columns returned (one this case a one dimensional array)
ixQuery.LocaleID = 1043 'Parameter: language
ixQuery.MaxRecords =RequestMax 'Parameter: max returned documents
ixQuery.Catalog = RequestIndex 'IndexService ' Which indexing service
' Create a search utility object to allow us to specify the search type as deep,meaning it will search recursively down through the directories
dim util
set util = Server.CreateObject("ixsso.Util")
util.AddScopeToQuery ixQuery, Server.MapPath(RequestIndex), "deep"
if (Err.description <> "") Then
strFileError= ("<div><strong>Search Utility Error : " & Err.description & "</strong></div>")
response.write strFileError
Exit sub
end if
' Run the query (i.e. create the recordset).
dim QueryRS
set queryRS = ixQuery.CreateRecordSet("nonsequential")
' Check the query result. If it timed out or return no records, then show
' an appropriate message. Otherwise, show the hits.
if (Err.description <> "") Then
strFileError= "<div><strong>search error : " & Err.description & "</strong></div>"
response.write strFileError
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
elseif queryrs.recordcount = 0 then
strFileError="<div><strong>no documents found.</strong></div>"
response.write strFileError
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
else
FSOA= QueryRS.getrows()
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
end if
end Sub
call DoIndexSearch(RequestSearchString,RequestIndex)
' TESTING PURPOSE
dim strTestResult
strTestResult= "<html><head></head><body style=""font-family:Verdana, arial"">"
strTestResult=strTestResult& "<h1>Testing 64bit classic asp indexing using windows 2008 64bit server</h1>"
strTestResult=strTestResult& "<h3>Search in index <em>"&RequestIndex&"</em> for <em>"&RequestSearchString&"</em> with max <em>"&requestMax&"</em> results</h3>"
strTestResult=strTestResult& "<p>Using a seperate website running a 64bit classic pool, wich contains a virtual directory named after the Index which contains the path to the directory of the website that is indexed.</p>"
strTestResult=strTestResult& "<p>The returned results is a one dimensional array containing the filenames where searchstring is found in. This array can be passes back using ajax/json</p>"
if isarray(fsoa) then
strTestResult=strTestResult& " <hr>"
strTestResult=strTestResult& "<fieldset><legend>Found items for "&RequestSearchString&" </legend>"
dim xloop:xloop=0
strTestResult=strTestResult& " <ol>"
for each xloop in fsoa
strTestResult=strTestResult& "<li>"&Xloop&" </li>"
next
strTestResult=strTestResult& " </ol></fieldset></body></html>"
strTestResult=strTestResult& "<hr>"
strTestResult=strTestResult& "<h1>AJAX return array</h1>"
else
strTestResult=strTestResult& " no items found"
end if
' response.write strTestResult ' (Remark when done testing)
' END TESTING
' RETURN INDEXING RESULT TO AJAX/JSON CALLER (one dim array)
if strFIleError="" then
xloop=0
dim ajaxresult
for each xloop in FSOA
ajaxresult=ajaxresult & ucase(Xloop) &"|"
next
ajaxresult=Left(ajaxresult,Len(ajaxresult)-1)
response.write ajaxresult
end if
%>
ثم قدمت صفحة طلب على أحد مواقع الويب التي تعمل في وضع تطبيق 32 بت:
dim FSOA 'return documents file array
'search inside documents
sub DoSearchText(target, indexservice)
'target = search string
'indexservice = catalog name (index service)
dim IndexArray() 'one dimensional array for index result
dim xmlhttp, tempArray, IndexUrl
'url to the 64bit indexer subdomain
IndexURL = ("http://indextest.subdomain.local/indexer.asp?Index="&IndexService&"&Search="&target&"&Size=50")
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", IndexURL, false
xmlhttp.send ""
if xmlhttp.status >= 400 and xmlhttp.status <=599 then
response.write " error processing: " &xmlhttp.status &" - "&xmlhttp.statusText
else
tempArray= xmlhttp.responseText
end if
set xmlhttp = nothing
'put result into a array
FSOA= split(tempArray,"|")
end Sub
call DoSearchText("chapter one", "sitebooks")
if isarray(FSOA) then
dim docloop
for each docloop in FSOA
response.write "<div>"&docloop&"</div>"
next
else
response.write "No documents found"
end if
`
تفسير:
- تحليل كتالوج خدمة الفهرسة ، سلسلة البحث ، أقصى مستندات ناتجة
- في النطاق الفرعي إنشاء أدلة افتراضية (اسمه كتالوج الفهرس) الذي يعيد التوجيه إلى الموقع الأصلي للدليل الذي تم فهرسته
- إضافة صفحة مفهرس
- تغيير رمز كائن الطلب الحالي من صفحة الويب الأصلية لإجراء مكالمة AJAX إلى نطاق فرعي أعلاه
فوائد:
- قم بتقديم طلب AJAX من موقع ASP Classic الذي يعمل في وضع تطبيق 32bit إلى تطبيق 64bit ونتائج الإرجاع.
- يمكنك أيضًا تضمين Adobe pdf ifilter (64bit) لفهرسة PDF وقراءة داخل ملفات PDF.
- من السهل تغيير رمز المواقع ASP الحالية. تغييرات طفيفة
- قم بتشغيل فهرس على تجمع 64 بت والوحات الفرعية منفصلة
- أضف فهرسة متعددة سهلة الحفاظ على موقع واحد
- جعل المستحيل ممكنًا: تشغيل ASP Classic مع خدمة فهرسة 64 بت في وضع تطبيق 32 بت 32 بت