ThinkGeo.com    |     Documentation    |     Premium Support

WMTS authorization

Hi @Ethan , I’m facing an issue with the authorization with wmts layer. it’s coming 401 unauthorized , sometimes index out of array exception also root element is missing these type of error is coming. I’m giving all the credentials (username,password) ;

Hi Bibek,

Please sent us the server url and credentials so we can look whether it works.

Regards,

Ethan

Hi @Ethan,
All the credentials is given below.
user: tgeotmp
pwd: 8QTtUxHP1Ww8Svy

ActiveStyleName =avncolor"
TileMatrixSetName = “GoogleMapsCompatible”
ActiveLayerName = “satir”

Hi Bibek,

Where is the server url?

Regards,

Ethan

Sorry @Ethan ,https://35.200.222.237/wx/api/map/satir/wmts

Hi Bibek,

You should want to make the credentials works like this (Please modify your code to remove the username and password if it’s private).

wmtsLayer.SendingWebRequest += WmtsLayer_SendingWebRequest;


        private void WmtsLayer_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
    {
        Debug.WriteLine(e.WebRequest.RequestUri.ToString());

        var request = WebRequest.Create(e.WebRequest.RequestUri.ToString());
        string authInfo = "YourUserName:YourPassword";
        authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));

        request.Headers["Authorization"] = "Basic " + authInfo;
        e.WebRequest = request;
    }

But when you pass the validate, it still cannot parse correct, because the capability contains this node:

<ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84">
  <ows:LowerCorner>-180.0;-85.0511287798</ows:LowerCorner>
  <ows:UpperCorner>180.0;85.0511287798</ows:UpperCorner>
 </ows:WGS84BoundingBox>

It should be looks like “-180.0 -85.0511287798” but not “-180.0;-85.0511287798” here.

Please view your capability here: https://35.200.222.237/wx/api/map/satir/wmts/1.0.0/WMTSCapabilities.xml

Regards,

Ethan

Hello @Ethan, You can check now and if possible then provide a working sample. Thanks

Hi Bibek,

It looks the map won’t render because the server hadn’t reply correct tile. I view the sending url, it is correct for the capability, you can try to view it in browser here:

https://35.200.222.237/wx/api/map/satir/wmts/?service=WMTS&request=GetTile&version=1.0.0&layer=satir&style=avncolor&format=image/png&TileMatrixSet=GoogleMapsCompatible&TileMatrix=GoogleMapsCompatible:0&TileRow=0&TileCol=0

And here is the sample you can test:
9338.zip (173.5 KB)

If this server is created by you, it should have a sample page, if you find this sample page, you can compare the parameters and see whether any parameter is missed.

Regards,

Ethan

https://35.200.222.237/wx/api/map/satir/wmts/?service=WMTS&request=GetTile&version=1.0.0&layer=satir&style=avncolor&format=image/png&TileMatrixSet=GoogleMapsCompatible&TileMatrix=2&TileRow=2&TileCol=2

this is the url format they have given.
I just tried this to change the url . Now Regenerated URL have the image but still image is not coming.

string originalURL = e.WebRequest.RequestUri.ToString();
string newURL = originalURL;
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:0”, “TileMatrix=0”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:9”, “TileMatrix=9”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:1”, “TileMatrix=1”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:2”, “TileMatrix=2”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:3”, “TileMatrix=3”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:4”, “TileMatrix=5”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:5”, “TileMatrix=5”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:6”, “TileMatrix=6”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:7”, “TileMatrix=7”);
newURL = newURL.Replace(“TileMatrix=GoogleMapsCompatible:8”, “TileMatrix=8”);
// Replace 0 to 9
e.WebRequest = HttpWebRequest.Create(newURL);

Hi Bibek,

We have modified your sample 9338_20181126.zip (175.7 KB), and make it works fine. But there are some hard code in your sample, which is not recommended.

There are some disparities on your Wmts Server Capabilities, and our product parse it failed. Please modify them as below:

  1. We use the “Title” of layer as layer name, please modify the “Title” to match the “Identifier” of layer.
  2. We use the “Title” of style as style name, please modify the “Title” to match the “Identifier” of style.
  3. The Identifier format of tile matrix is not “{Zoom}”, please modify it as “{TileMatrixSetName}:{Zoom}”.

    For example:

If you have any questions, please feel free to contact us, we will promptly enthusiastically give reply!

Thanks,
Rex

As per your Suggestion they changed the xml but still it’s not coming.

Hi Bibek,

I tested the sample from Rex without any change, it works well.

If you still have problem, could you please let us know what’s the problem now?

Regards,

Ethan