xServer.NET To xServer 2 Http Authentification

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
steiner
Posts: 15
Joined: Tue Mar 29, 2016 10:58 am
Contact:

xServer.NET To xServer 2 Http Authentification

Post by steiner »

Hello PTV Team,

we want to change our Setting xserver 1 + Ajaxmaps-control to xserver 2.31 + xserver.net and i have problems with the http authentification.

The clientsoftware is in c#.net framework 4.8 + xServer.net 1.7.10 + FormsMapCS

I get the map to work without the users.properties in <xserver-install-dir>\conf with the address MainMap.XMapUrl = "http://<myip>:50000/services/";

When i produce the users.properties with <myuser>=<mypassword> and the settings

MainMap.XMapUrl = "http://<myip>10.0.0.73:50000/services/";
MainMap.XMapCredentials = "<myuser>:<mypassword>";

i get following errors in the log-files:

2024-03-18 10:50:16,437;WARN;com.ptvgroup.xserver.runtime.cxf.ServicesLoader;Rejected request to /xmap/ws/XMap because it is invalid!
2024-03-18 10:50:16,888;WARN;com.ptvgroup.xserver.runtime.cxf.PTVServlet;Unauthorized access with user 'unknown' and password 'null' detected.
2024-03-18 10:50:16,901;WARN;com.ptvgroup.xserver.runtime.cxf.PTVServlet;Unauthorized access with user 'xtok' and password '<mypassword>' detected.

It seems the ServicesLoader means, its not a xServer2 (xmap instead of xservices in the path). But it does not make a different, when i add ;version=2.31 to the XMapUrl.

Can you help me?

Jürgen Winklhofer
User avatar
Oliver Heilig
Posts: 154
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: xServer.NET To xServer 2 Http Authentification

Post by Oliver Heilig »

Hello Jürgen,

looks like the XMapCredentials only works with xsi token authentication and not with generic basic auth for xMap-2. What should work is setting the basic auth header using the ModifyRequest delegate;

Code: Select all

            formsMap.XMapUrl = "http://xserver-2:50000/";
            LayerFactory.ModifyRequest = request =>
            {
                request.Headers["Authorization"] = "Basic "
                    + Convert.ToBase64String(Encoding.UTF8.GetBytes("myUser:myPassword"));
                return request;
            };
Hope that helps
Oli
Last edited by Oliver Heilig on Mon Mar 18, 2024 1:56 pm, edited 3 times in total.
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
steiner
Posts: 15
Joined: Tue Mar 29, 2016 10:58 am
Contact:

Re: xServer.NET To xServer 2 Http Authentification

Post by steiner »

Hello Oliver,

now it works. Thanks a lot.

greetings
Jürgen
Post Reply