Hello,
I am using “Map Suite Desktop Evaluation Edition 7.0” and I am trying to connect to this WMS server :
bgis.benomad.com/bgis/wms?LA…HEIGHT=512
This server is protected with a login/password. I can give you them by PM.
I tried many things like “Credential” or the event “SendingWebRequest” but i have a exception when i use the “Open” method of the WmsRasterLayer object.
In fact, i don’t know if this problem is due to a wrong login/pwd setting or if this WMS server is not standart
Thanks
Thierry
Unable to display a protected WMS layer
Hi Thierry,
Could you please paste your exception information here?
I am not sure whether this WMS server support login parameters or not.
If it support login parameters, you can get the request url from “SendingWebRequest” event, then add your username/password int it and open it in browser for test.
If it only support credential, as below is a sample code for that:
wmsRasterLayer.Credentials = new MyCredential();
public class MyCredential : ICredentials
{
public NetworkCredential GetCredential(Uri uri, string authType)
{
NetworkCredential myCredential = new NetworkCredential(“UserName”, “Password”, “Domain”);
return myCredential;
}
}
If that’s different with how you tested before, please try it.
Regards,
Don
Hi Thierry,
I found two topic maybe helpful. Please login and view the header for make sure whether that works for you.
Please notice these items:
1. Try http and https
2. Try set PreAuthenticate equal true or false
3. If that’s NTLM, please try this: webRequest.Credentials = new CredentialCache().Add(uri, “Basic”, new NetworkCredential(“username”, “password”));
stackoverflow.com/questions/1702426/httpwebrequest-not-passing-credentials
stackoverflow.com/questions/5207660/401-unauthorized-returned-on-get-request-https-with-correct-credentials
Wish these information is helpful.
Regards,
Don
Thanks
Your messages helped me to find the solution
I just added this :
Private
Sub
Wms_SendingWebRequest(sender
As
Object
, e
As
ThinkGeo.MapSuite.Core.SendingWebRequestEventArgs)
Dim
sUsername
As
String
=
"XXX"
Dim
sPassword
As
String
=
"YYY"
Dim
credentialBuffer
As
Byte
() =
New
System.Text.UTF8Encoding().GetBytes(sUsername +
":"
+ sPassword)
e.WebRequest.Headers(
"Authorization"
) =
"Basic "
+ Convert.ToBase64String(credentialBuffer)
End
Sub
Maybe there is a better way to do this ?
Hi Sommer,
Great to hear the problem is sorted out, following code should also provide you a basic idea fot it:
WmsRasterLayer.Parameters.Add("id",yourID)
WmsRasterLayer.Parameters.Add("pasword",yourPassword)
Hope it helps
Summer