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 ;-)
Post Reply
oostadr
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

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

Post by oostadr »

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);
                }
            }
User avatar
Bernd Welter
Site Admin
Posts: 2564
Joined: Mon Apr 14, 2014 10:28 am
Contact:

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

Post by Bernd Welter »

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
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
oostadr
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

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

Post by oostadr »

Yes, the token works.
I get a response
KasperD
Posts: 14
Joined: Tue Jun 17, 2014 8:15 am

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

Post by KasperD »

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";
oostadr
Posts: 6
Joined: Tue Nov 20, 2018 3:18 pm

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

Post by oostadr »

this works. Thx
hcapera
Posts: 1
Joined: Fri Jan 25, 2019 4:46 pm

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

Post by hcapera »

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.p ... /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
Mathias.Heß
Posts: 6
Joined: Fri May 29, 2015 8:53 am

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

Post by Mathias.Heß »

Hello Harrison,

did you set the credentials? There is a how-to on https://xserver2-europe-eu-test.cloud.p ... _Cloud.htm.

Furthermore you may have a look at https://xserver.ptvgroup.com/forum/view ... 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
Post Reply