Page 1 of 1

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

Posted: Wed Nov 28, 2018 10:06 pm
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);
                }
            }

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

Posted: Thu Nov 29, 2018 8:18 am
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

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

Posted: Thu Nov 29, 2018 9:32 am
by oostadr
Yes, the token works.
I get a response

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

Posted: Thu Nov 29, 2018 3:29 pm
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";

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

Posted: Tue Dec 04, 2018 8:07 am
by oostadr
this works. Thx

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

Posted: Mon Jan 28, 2019 9:38 am
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

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

Posted: Wed Jan 30, 2019 9:16 am
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