The remote server returned an error: (401) Unauthorized.

Proper forum for all questions related to xServer INTERNET = the Azure based cloud solution. This forum deals with the architecture topics such as load balancing, available profiles and standard server settings.
Please be aware that questions about core functionality such as routing, mapping, geocoding in general should be placed in the xServers dedicated forum ;-)

The remote server returned an error: (401) Unauthorized.

Postby oostadr » Wed Nov 28, 2018 10:06 pm

I'm trying to use xlocate over xserver2
https://xserver2-europe-eu-test.cloud.p ... ocate?WSDL
I receive the error message not authorized. What's wrong?

Code: Select all
  var xlocateClient = new XLocate.XLocateClient();
            xlocateClient.ClientCredentials.UserName.UserName = "xtok";
            xlocateClient.ClientCredentials.UserName.Password = "xxxxxxxxxxx-xxxx-xxx-xxxx";

           
            try
            {
                var address = new Address();
                address.postalCode = "3823TB";
                address.country = "NLD";   
     
                var xLocateResult = xlocateClient.searchLocations(new SearchByAddressRequest
                {
                    address = address
                });
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
                else
                {
                    Console.WriteLine(e.Message);
                }
            }
oostadr
 
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

Re: The remote server returned an error: (401) Unauthorized.

Postby Bernd Welter » Thu Nov 29, 2018 8:18 am

Hello Adriaan,

as this challenge is related to "interfacing with xServer INTERNET" I decided to move it to the corresponding forum space.
I also informed your assigned technical consultant to get in touch with you. Easiest cause: trial period expired? Does the token work in the raw request runner?
https://xserver2-europe-eu-test.cloud.p ... n%7C_____2
Choose a geocoding sample and try to execute it by using username=xtok and password=[your token].

Best regards,
Bernd
Bernd Welter
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1370
Joined: Mon Apr 14, 2014 10:28 am

Re: The remote server returned an error: (401) Unauthorized.

Postby oostadr » Thu Nov 29, 2018 9:32 am

Yes, the token works.
I get a response
oostadr
 
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

Re: The remote server returned an error: (401) Unauthorized.

Postby KasperD » Thu Nov 29, 2018 3:29 pm

Adriaan,

Try the following code:

var routeBinding = new BasicHttpBinding { MaxReceivedMessageSize = 2147483647 };
routeBinding.Security.Mode = BasicHttpSecurityMode.Transport;
routeBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
xRouteClient.Endpoint.Binding = routeBinding;

var locateBinding = new BasicHttpBinding { MaxReceivedMessageSize = 2147483647 };
locateBinding.Security.Mode = BasicHttpSecurityMode.Transport;
locateBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
xLocateClient.Endpoint.Binding = locateBinding;

var tourBinding = new BasicHttpBinding { MaxReceivedMessageSize = 2147483647 };
tourBinding.Security.Mode = BasicHttpSecurityMode.Transport;
tourBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
xTourClient.Endpoint.Binding = tourBinding;

xRouteClient.ClientCredentials.UserName.UserName = "xtok";
xRouteClient.ClientCredentials.UserName.Password = "token";

xLocateClient.ClientCredentials.UserName.UserName = "xtok";
xLocateClient.ClientCredentials.UserName.Password = "token";

xTourClient.ClientCredentials.UserName.UserName = "xtok";
xTourClient.ClientCredentials.UserName.Password = "token";
KasperD
 
Posts: 11
Joined: Tue Jun 17, 2014 8:15 am

Re: The remote server returned an error: (401) Unauthorized.

Postby oostadr » Tue Dec 04, 2018 8:07 am

this works. Thx
oostadr
 
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

Re: The remote server returned an error: (401) Unauthorized.

Postby hcapera » Mon Jan 28, 2019 9:38 am

Hello,

I have the same error but in Java when I try to execute the following code:

Code: Select all
String host = "https://xserver2-europe-eu-test.cloud.ptvgroup.com/services/ws/XRoute";
         XRoute client = (XRoute) new XRoute_Service(new URL(host)).getXroute();


The error in the console is:

2019-01-25 17:35:18,961 ERROR [c.o.XPO_TasksManagement] OPEnrichmentDealSpecTask com.openpricer.spec.contract.EnrichmentDealSpecTask.opRun : RuntimeException = javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https://xserver2-europe-eu-test.cloud.ptvgroup.com/services/ws/XRoute'.: java.io.IOException: Server returned HTTP response code: 401 for URL: https://xserver2-europe-eu-test.cloud.p ... /ws/XRoute
java.io.IOException: Server returned HTTP response code: 401 for URL: https://xserver2-europe-eu-test.cloud.p ... /ws/XRoute
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
...

Best regards,
Harrison
hcapera
 
Posts: 1
Joined: Fri Jan 25, 2019 4:46 pm

Re: The remote server returned an error: (401) Unauthorized.

Postby Mathias.Heß » Wed Jan 30, 2019 9:16 am

Hello Harrison,

did you set the credentials? There is a how-to on https://xserver2-europe-eu-test.cloud.ptvgroup.com/dashboard/Default.htm#DevelopersGuide/DSC_UsingWithJava_Cloud.htm.

Furthermore you may have a look at https://xserver.ptvgroup.com/forum/viewtopic.php?f=41&t=992. Our test deployments currently have wsdl problem that affects the SOAP clients. The posting describes a workaround and the productive deployments are working as intended.

Regards,
Mathias
Mathias.Heß
 
Posts: 5
Joined: Fri May 29, 2015 8:53 am


Return to PTV xServer INTERNET (Admin=OH,SM)

cron