다음 코드를 고려하십시오.초과 cfhttp 시간 초과 오류
숫자를 전달하고 7-8 필드의 정보를 다시 가져 오는 SOAP 요청을 보냅니다. 내 비누 봉투를 통과하는 숫자가 170,000 개의 레코드가있는 CSV 파일에서 가져옵니다.
<cffile action="READ" file="http://filepath/Myfile.csv" variable="FileContent">
<cfset CSVArray = CSVtoArray(FileContent)>
<cfset CSVArrayLength = ArrayLen(CSVarray)>
Total Records:<cfdump var="#CSVArrayLength#" >
<cfloop index="LoopCount" from = "2" to = "#CSVArrayLength#">
<cfsavecontent variable="soap"><?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:vtsInfoLookup" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:vtsInfoLookup">
<SOAP-ENV:Header>
<userName>xyz</userName>
<password>JiunskeT1</password>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<infoLookup SOAP-ENV:EncodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<Number><cfoutput>#CSVArray[LoopCount][2]#</cfoutput></Number>
<userName>xyz</userName>
<password>passwd</password>
</infoLookup>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>
<cfhttp url ="https://myurl/abc.php?wsdl" method = "post" result = "httpResponse" throwonerror= "Yes">
<cfhttpparam type="header" name="accept-encoding" value="no-compression" />
<cfhttpparam type="header" name="content-type" value="application/soap+xml">
<cfhttpparam type="header" name="content-length" value="#len(soap)#">
<cfhttpparam type="xml" value="#trim(soap)#">
</cfhttp>
<cfset XMLResponse = XmlParse(httpResponse.fileContent.Trim()) />
<cfset arrNumber = XmlSearch(XMLResponse,"//*[name()='Number']") />
<cfset Number = trim(arrNumber[1].xmlText)>
// Similarly parsing for other 7-8 fields
<cfquery name="vQuery" datasource="XX.XX.X.XXX">
INSERT INTO
VALUES (<cfqueryparam cfsqltype = "cf_sql_varchar" value = "#trim(Number)#" null = "#NOT len(trim(Number))#"/>,
// 7 - 8 fields more here
)
</cfquery>
</cfloop>
내가 여기에 2에서 시작하고 그 이유는 내 CSV 파일의 첫 번째 행에 열 이름을 가지고 있다는 것입니다 : 여기에 내가 뭐하는 거지의 코드 이다. 번호는 CSV의 두 번째 행에서부터 시작됩니다. 으로 설정> 설정, (초) 후 시간 초과 요청에 대한 값을 - 그게 내가 내 서버에서, 이후 here
을 통해 언급 한 바와 같이 나는 CSVToarray 기능을 사용하고
위 #CSVArray[LoopCount][2]#
을 언급 한 이유 요청이 허용 시간 제한 태그를 초과
: 7천2백초, 내 요청이 오류 메시지와 함께 2 시간 후에 시간 초과와 cfhttp는
그래서, CSV에서 170,000 기록에서, 그것은 1900을 삽입 한 후 중지 요청 제한 시간의 결과로 SQL Server 2008의 0 레코드.
코드를 효율적으로 만들 수있는 방법이 있습니까? <cfthread>
의 사용을 제안하는 사람들 somewhere을 읽으시겠습니까?
당신은 항상 그냥 페이지에 대한 제한 시간을 증가시킬 수있다. 또는 해당 csv를 사용하여 SQL에 170k 다른 쿼리를 전달하는 대신 SQL Server에서 직접 실행할 수있는 .sql 파일을 만들 수 있습니다. 또는 인서트를 청크 당 1000 개의 인서트로 분해하십시오. –