Apache上的ISAPI Web服务

时间:2010-11-25 09:41:31

标签: delphi apache delphi-7 isapi

我在Delphi 7中使用客户端的WebService(ISAPI DLL)。当我用我的客户端调用我的WebService时,一切正常。问题出在另一家公司的.NET客户端。如果作为服务器runnig apache(使用isapi-handler),则Web服务不会运行。在IIS服务器上一切正常。

问题在于函数HttpExtensionProc(var ECB:TEXTENSION_CONTROL_BLOCK):DWORD;来自ISAPIApp.pas。在此入口点缺少内容数据(ECB.cbTotalBytes = 0,ECB.lpbData ='')。但仅限于Apache(2.2.17)和.NET客户端。


Request sent from delphi client - all ok, content is present in entery point:
24.11.2010 10:29:34 - lpszContentType: text/xml; charset="utf-8"
24.11.2010 10:29:34 - cbSize: 144
24.11.2010 10:29:34 - dwVersion: 1280
24.11.2010 10:29:34 - dwHttpStatusCode: 0
24.11.2010 10:29:34 - cbTotalBytes: 640
24.11.2010 10:29:34 - cbAvailable: 640
24.11.2010 10:29:34 - lpszLogData:
24.11.2010 10:29:34 - lpszMethod: POST
24.11.2010 10:29:34 - lpszQueryString:
24.11.2010 10:29:34 - lpszPathInfo: /soap/IWESS_WS
24.11.2010 10:29:34 - lpszPathTranslated: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\soap\IWESS_WS
24.11.2010 10:29:34 - lpbData: <?xml version="1.0"?>
<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/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:Login xmlns:NS1="urn:WESS_WSIntf-IWESS_WS"><DBProfile xsi:type="xsd:string">WS test</DBProfile><Username xsi:type="xsd:string">LD</Username><Password xsi:type="xsd:string">ld</Password><Id_Function_Place xsi:type="xsd:int">5</Id_Function_Place></NS1:Login></SOAP-ENV:Body></SOAP-ENV:Envelope>

fiddler log: POST http://tresnak:8080/cgi-bin/WESS_WS.dll/soap/IWESS_WS HTTP/1.1 SOAPAction: "urn:WESS_WSIntf-IWESS_WS#Login" Content-Type: text/xml User-Agent: Borland SOAP 1.2 Host: tresnak:8080 Content-Length: 657 Connection: Keep-Alive Pragma: no-cache

<?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/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:Login xmlns:NS1="urn:WESS_WSIntf-IWESS_WS"><DBProfile xsi:type="xsd:string">WS test</DBProfile><Username xsi:type="xsd:string">LD</Username><Password xsi:type="xsd:string">ld</Password><Id_Function_Place xsi:type="xsd:int">5</Id_Function_Place></NS1:Login></SOAP-ENV:Body></SOAP-ENV:Envelope>

Request sent from .NET client - fail, content is NOT present in entery point: 24.11.2010 10:29:46 - lpszContentType: text/xml; charset=utf-8 24.11.2010 10:29:46 - cbSize: 144 24.11.2010 10:29:46 - dwVersion: 1280 24.11.2010 10:29:46 - dwHttpStatusCode: 0 24.11.2010 10:29:46 - cbTotalBytes: 0 24.11.2010 10:29:46 - cbAvailable: 0 24.11.2010 10:29:46 - lpszLogData: 24.11.2010 10:29:46 - lpszMethod: POST 24.11.2010 10:29:46 - lpszQueryString: 24.11.2010 10:29:46 - lpszPathInfo: /soap/IWESS_WS 24.11.2010 10:29:46 - lpszPathTranslated: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\soap\IWESS_WS 24.11.2010 10:29:46 - lpbData:

fiddler log: POST http://tresnak:8080/cgi-bin/WESS_WS.dll/soap/IWESS_WS HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4952) Content-Type: text/xml; charset=utf-8 SOAPAction: "urn:WESS_WSIntf-IWESS_WS#Login" Host: tresnak:8080 Content-Length: 728 Expect: 100-continue Connection: Keep-Alive

<?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://www.gordic.cz/g3/ess/v01" xmlns:types="http://www.gordic.cz/g3/ess/v01/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:Login xmlns:q1="urn:WESS_WSIntf-IWESS_WS"><DBProfile xsi:type="xsd:string">WS TEST</DBProfile><Username xsi:type="xsd:string">LD</Username><Password xsi:type="xsd:string">ld</Password><Id_Function_Place xsi:type="xsd:int">3</Id_Function_Place></q1:Login></soap:Body></soap:Envelope>

哪里有问题?如果调用者是.NET而服务器是Apache,为什么ECB.lpbData不包含SOAP请求?

感谢您帮助解决问题。

我尝试在apache中启用调试日志并使用DumpIO模块,并且.NET调用中不存在soap请求。如果调用来自Delphi客户端,则SOAP请求将记录在调试日志中。

Delphi客户端的Apache调试日志:

[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 50 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): POST /cgi-bin/WESS_WS.dll/soap/IWESS_WS HTTP/1.1\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 46 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): SOAPAction: "urn:WESS_WSIntf-IWESS_WS#Login"\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 41 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Content-Type: text/xml; charset="utf-8"\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 23 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): User-Agent: test 1234\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 20 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Host: tresnak:8080\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 21 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Content-Length: 640\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 24 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Connection: Keep-Alive\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 25 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Cache-Control: no-cache\r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 2 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): \r\n
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [readbytes-blocking] 640 readbytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 640 bytes
[Fri Nov 26 07:39:20 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): <?xml version="1.0"?>\r\n<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/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:Login xmlns:NS1="urn:WESS_WSIntf-IWESS_WS"><DBProfile xsi:type="xsd:string">WS test</DBProfile><Username xsi:type="xsd:string">LD</Username><Password xsi:type="xsd:string">ld</Password><Id_Function_Place xsi:type="xsd:int">5</Id_Function_Place></NS1:Login></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (data-HEAP): 205 bytes
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_out (data-HEAP): HTTP/1.1 200 OK\r\nDate: Fri, 26 Nov 2010 06:39:20 GMT\r\nServer: Apache/2.2.17 (Win32)\r\nContent-Length: 536\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text/xml; charset="utf-8"\r\n\r\n
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (data-TRANSIENT): 536 bytes
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_out (data-TRANSIENT): <?xml version="1.0"?>\r\n<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/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:LoginResponse xmlns:NS1="urn:WESS_WSIntf-IWESS_WS"><LogToken xsi:type="xsd:string">{56B3BC03-9E94-4345-B583-30E4EE71A3D9}</LogToken></NS1:LoginResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-FLUSH): 0 bytes
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-EOS): 0 bytes
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [eatcrlf-nonblocking] 0 readbytes
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(127): mod_dumpio: dumpio_in - 730035
[Fri Nov 26 07:39:23 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:39:29 2010] [debug] mod_dumpio.c(127): mod_dumpio: dumpio_in - 730060
[Fri Nov 26 07:39:29 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:39:29 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-FLUSH): 0 bytes
[Fri Nov 26 07:39:29 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-EOC): 0 bytes

来自.NET客户端的Apache调试日志:

[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 50 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): POST /cgi-bin/WESS_WS.dll/soap/IWESS_WS HTTP/1.1\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 96 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4952)\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 39 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Content-Type: text/xml; charset=utf-8\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 46 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): SOAPAction: "urn:WESS_WSIntf-IWESS_WS#Login"\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 20 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Host: tresnak:8080\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 21 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Content-Length: 728\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 22 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Expect: 100-continue\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 24 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): Connection: Keep-Alive\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(113): mod_dumpio: dumpio_in [getline-blocking] 0 readbytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_in (data-HEAP): 2 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_in (data-HEAP): \r\n
[Fri Nov 26 07:41:08 2010] [error] [client 192.168.222.6] Premature end of script headers: WESS_WS.dll
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (data-HEAP): 191 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_out (data-HEAP): HTTP/1.1 500 Internal Server Error\r\nDate: Fri, 26 Nov 2010 06:41:08 GMT\r\nServer: Apache/2.2.17 (Win32)\r\nContent-Length: 542\r\nConnection: close\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (data-HEAP): 542 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(74): mod_dumpio:  dumpio_out (data-HEAP): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>500 Internal Server Error</title>\n</head><body>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error or\nmisconfiguration and was unable to complete\nyour request.</p>\n<p>Please contact the server administrator,\n pavel.tresnak@haida.cz and inform them of the time the error occurred,\nand anything you might have done that may have\ncaused the error.</p>\n<p>More information about this error may be available\nin the server error log.</p>\n</body></html>\n
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-EOS): 0 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-FLUSH): 0 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(142): mod_dumpio: dumpio_out
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-FLUSH): 0 bytes
[Fri Nov 26 07:41:08 2010] [debug] mod_dumpio.c(55): mod_dumpio:  dumpio_out (metadata-EOC): 0 bytes

2 个答案:

答案 0 :(得分:1)

我知道这个主题有点老了,但是因为这是搜索此问题时的第一个问题,我认为解决方法(至少对于能够访问.net客户端的人来说)是有道理的。

问题是标题和soap正文分两步发送,由标题

表示
Expect: 100-continue

我没有发现这是Apache,mod_isapi还是delphi的问题,但是可以在.net客户端中禁止发送此标头:

System.Net.ServicePointManager.Expect100Continue = false;

我在这里找到了解决方案http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx

我希望这会对某人有所帮助。

答案 1 :(得分:0)

我能够从Delphi 7创建一个Apache模块(不需要Apache ISAPI包装器),对HTTPD2.pas进行一些更改以支持Apache 2.

http://xxm.svn.sourceforge.net/viewvc/xxm/trunk/Delphi/apache/

但是,我没有做太多的SOAP。所以我不确定如何将request_rec链接到处理SOAP请求并获得发送响应所需的工作。