Как запросить службу Windows 2008 x64 Index Service из 32-разрядных приложений ASP? - PullRequest
3 голосов
/ 11 октября 2010

Недавно я столкнулся с проблемой, связанной с перемещением классических сайтов asp с сервера w2k3 в среду w2k8 64. Это включало создание сервисов индексирования для работы с asp classic. Я искал везде, где пробовал много решений, и все они потерпели неудачу.

Проблема: запуск 64-битной службы индексирования в 32-битном пуле приложений (для asp classic) Страницы ASP, выполняющие запрос к службе индексирования, привели к ошибке, когда объект сервера не удалось загрузить. хотя служба индексирования работала, а папка, содержащая документы сайта, на котором индексировалась, служба индексирования, работала в 64-битном режиме, а пул - в 32-битном режиме. Не удалось бежать.

Некоторые из предложенных решений состояли в том, чтобы переписать код для использования нового «поиска Windows». Но так как он также работает в 64-битной среде, он не может быть запущен в режиме 32-битных приложений. Переключение на 32-битный совместимый режим в пуле вызвано неработающими базами данных и другими com-объектами, используемыми узлами asp.

1 Ответ

2 голосов
/ 23 августа 2011

Через пару дней я почти сдался, но среди ночи мне пришла блестящая идея, чтобы все это заработало. Что делать, если я сделаю 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

`

Пояснение:

  • Анализировать имя каталога службы индексирования, строку поиска, максимальное количество найденных документов
  • В поддомене создайте виртуальные каталоги (называемые каталогом индекса), которые перенаправляют в исходное местоположение индексированного каталога
  • Добавить страницу indexer.asp, которая обрабатывает вызовы
  • изменить существующий объектный код запроса исходной веб-страницы, чтобы сделать ajax-вызов вышеуказанному поддомену

Преимущества:

  • Сделайте Ajax-запрос от классического веб-сайта asp, работающего в режиме 32-битного приложения, к 64-битному приложению и верните результаты.
  • Вы также можете включить Adobe PDF Ifilter (64 бита) для индексирования PDF и чтения внутри файлов PDF.
  • Легко изменить существующий код ASP сайтов. Незначительные изменения
  • Запуск индексатора на отдельном 64-битном пуле и поддомене
  • Добавление нескольких каталогов, легко поддерживаемых в одном месте
  • Делая невозможное возможным: запуск asp classic с 64-битной службой индексации в режиме 32-битных приложений
...