我一直在遵循OpenSearch:https://inspire.ec.europa.eu/documents/technical-guidance-implementation-inspire-download-services下载服务官方技术指南构建一个原子提要
我被困在创建执行搜索的PHP上。
根据前面提到的指南,必须具有以下模板:
<Url type="application/zip" rel="results" template="http://myWeb/atom/search.php?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}"/>
<Url type="application/atom+xml" rel="describedby" template="http://myWeb/atom/search.php?spatial_dataset_identifier_code={inspire_dls:spatial_dataset_identifier_code?}&spatial_dataset_identifier_namespace={inspire_dls:spatial_dataset_identifier_namespace?}&crs={inspire_dls:crs?}&language={language?}&q={searchTerms?}"/> 该指南还提供了一个PHP脚本来帮助开发人员编写"search.php“文件。剧本的开头是这样的:
$returnFile = false;
foreach (apache_request_headers() as $name => $value) {
//echo("$name: $value\n");
if ($name=="Accept" && $value=="application/zip"){
$returnFile = true;
}
} 如果$returnFile为真,则必须返回一个ZIP文件。如果是false,则返回XML (这是脚本的其余部分)。
我的问题是,条件$name=="Accept" && $value=="application/zip"永远不是真,所以搜索总是返回一个XML。
$value怎么可能是application/zip
这是我在访问Accept时得到的http://myWeb/atom/search.php值
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 编辑:指南提供了更多关于这方面的信息:
The example given in Annex A uses content negotiation to identify which
operation to perform. This means that even though the operation endpoint is
only one, i.e. http://myWeb/search.php, the client has to set the HTTP
―Accept‖ Header to the correct value in order to receive the expected
result.因此,如果我在激励验证器中测试我的ATOM提要,那么客户机就是INSPIRE验证器(向search.php发送查询的客户机).我错了吗?
发布于 2017-11-14 13:52:09
我向验证器的开发人员提出了一个问题,他们证实这并不像预期的那样有效。验证器应该在请求中添加“接受”标题,但它将其保留为空白。他们正在解决问题。
https://stackoverflow.com/questions/46199031
复制相似问题