Skip to content

Commit 9d9e94e

Browse files
committedJun 9, 2017
Fix the mandatory OnlineResource
1 parent 2346f59 commit 9d9e94e

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed
 

‎src/server/services/wms/qgswmsgetcapabilities.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ namespace QgsWms
195195
doc.appendChild( wmsCapabilitiesElement );
196196

197197
//INSERT Service
198-
wmsCapabilitiesElement.appendChild( getServiceElement( doc, project, version ) );
198+
wmsCapabilitiesElement.appendChild( getServiceElement( doc, project, version, request ) );
199199

200200
//wms:Capability element
201201
QDomElement capabilityElement = getCapabilityElement( doc, project, version, request, projectSettings );
@@ -222,7 +222,8 @@ namespace QgsWms
222222
return doc;
223223
}
224224

225-
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version )
225+
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version,
226+
const QgsServerRequest &request )
226227
{
227228
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );
228229

@@ -283,14 +284,15 @@ namespace QgsWms
283284
}
284285

285286
QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
286-
if ( !onlineResource.isEmpty() )
287+
if ( onlineResource.isEmpty() )
287288
{
288-
QDomElement onlineResourceElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
289-
onlineResourceElem.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
290-
onlineResourceElem.setAttribute( QStringLiteral( "xlink:type" ), QStringLiteral( "simple" ) );
291-
onlineResourceElem.setAttribute( QStringLiteral( "xlink:href" ), onlineResource );
292-
serviceElem.appendChild( onlineResourceElem );
289+
onlineResource = serviceUrl( request, project ).toString();
293290
}
291+
QDomElement onlineResourceElem = doc.createElement( QStringLiteral( "OnlineResource" ) );
292+
onlineResourceElem.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
293+
onlineResourceElem.setAttribute( QStringLiteral( "xlink:type" ), QStringLiteral( "simple" ) );
294+
onlineResourceElem.setAttribute( QStringLiteral( "xlink:href" ), onlineResource );
295+
serviceElem.appendChild( onlineResourceElem );
294296

295297
QString contactPerson = QgsServerProjectUtils::owsServiceContactPerson( *project );
296298
QString contactOrganization = QgsServerProjectUtils::owsServiceContactOrganization( *project );

‎src/server/services/wms/qgswmsgetcapabilities.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ namespace QgsWms
6161
/**
6262
* Create Service element for get capabilities document
6363
*/
64-
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version );
64+
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version,
65+
const QgsServerRequest &request );
6566

6667
/** Output GetCapabilities response
6768
*/

‎tests/src/python/test_qgsserver_wms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ def test_wms_getcapabilities_url(self):
572572

573573
item_found = False
574574
for item in str(r).split("\\n"):
575-
if "OnlineResource" in item:
576-
self.assertEqual("xlink:href=\"my_wms_advertised_url?" in item, True)
575+
if "OnlineResource" in item and "xlink:href=\"my_wms_advertised_url?" in item:
577576
item_found = True
578577
self.assertTrue(item_found)
579578

‎tests/testdata/qgis_server/getcapabilities.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Content-Type: text/xml; charset=utf-8
1010
<KeywordList>
1111
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
1212
</KeywordList>
13+
<OnlineResource xlink:type="simple" xlink:href="https://www.qgis.org/?MAP=tests/testdata/qgis_server/test_project.qgs&amp;" xmlns:xlink="http://www.w3.org/1999/xlink"/>
1314
<ContactInformation>
1415
<ContactPersonPrimary>
1516
<ContactPerson>Alessandro Pasotti</ContactPerson>

‎tests/testdata/qgis_server/getcapabilities_inspire.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Content-Type: text/xml; charset=utf-8
1010
<KeywordList>
1111
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
1212
</KeywordList>
13+
<OnlineResource xlink:type="simple" xlink:href="?MAP=tests/testdata/qgis_server/test_project_inspire.qgs&amp;" xmlns:xlink="http://www.w3.org/1999/xlink"/>
1314
<ContactInformation>
1415
<ContactPersonPrimary>
1516
<ContactPerson>Alessandro Pasotti</ContactPerson>

‎tests/testdata/qgis_server/getprojectsettings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Content-Type: text/xml; charset=utf-8
1010
<KeywordList>
1111
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
1212
</KeywordList>
13+
<OnlineResource xlink:type="simple" xlink:href="https://www.qgis.org/?MAP=tests/testdata/qgis_server/test_project.qgs&amp;" xmlns:xlink="http://www.w3.org/1999/xlink"/>
1314
<ContactInformation>
1415
<ContactPersonPrimary>
1516
<ContactPerson>Alessandro Pasotti</ContactPerson>

0 commit comments

Comments
 (0)
Please sign in to comment.