Page 1 of 1

Accessing the methods of xLocate service via WebClient in C#

Posted: Tue Mar 07, 2017 3:17 pm
by webdirekt
We want to create the dll which calls the methods of xLocate that is findAddress to get the geo-coordinates of given address.

So how can we call the method findAddress of xLocate, pass the Address object to that method and at last get the result without using the web service reference.

Is there any way to call the methods of xLocate service via WebClient.

Re: Accessing the methods of xLocate service via WebClient i

Posted: Thu Mar 09, 2017 8:42 am
by LNM_PTV
Hello,

here are two links to our Website where you can find Information about how to acces the xlocate Service in C#.

http://xserver.ptvgroup.com/en-uk/cookb ... lications/

http://xserver.ptvgroup.com/en-uk/cookb ... s-classes/

Does that help you?

Best regards,
Lars

Re: Accessing the methods of xLocate service via WebClient i

Posted: Mon Mar 13, 2017 5:37 am
by webdirekt
Dear Dr. Moritz,
Thanks for your help, we are moving ahead and will contact you in case we need any help.

Kind Regards
Ramanan

Re: Accessing the methods of xLocate service via WebClient i

Posted: Thu Mar 16, 2017 9:46 am
by webdirekt
Hello,

we have checked the client dlls which you have given to us, but in those dlls, we found only xroute client base available. Do we have to reference any thing else?
also in that dll, we need user id and password to initialize xroute client base. How can we get user id and password or xtoken to use xroute client base.

We have used HttpWebRequest to request xLocate using JSON object to get JSON result.
Sample code,

Code: Select all

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(domain + "/xlocate/rs/XLocate/findAddress");
            webRequest.ContentType = "application/json;charset=\"utf-8\"";
            webRequest.Accept = "application/json";
            webRequest.Method = "POST";

            // get content bytes
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            Byte[] byteArray = encoding.GetBytes(jsonAddress);

            webRequest.ContentLength = byteArray.Length;

            // add content into request steam
            using (Stream dataStream = webRequest.GetRequestStream())
            {
                 dataStream.Write(byteArray, 0, byteArray.Length);
            }

            // get response
            using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse())
            {
                 // read response into StreamReader
                 using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                 {
                      // get response into a string variable
                      string jsonResponse = rd.ReadToEnd();
                      console.write(jsonResponse);
                 }
             }
Is there any other way, we can achieve same result as above?

Kind regards,
Webdirekt Team

Re: Accessing the methods of xLocate service via WebClient i

Posted: Wed Mar 22, 2017 10:17 am
by Bernd Welter
Hi there,

ON PREMISE: For access to a local xServer you don't have to specify credentials (as long as you use a standard configuration where authentification is disabled by default).
ON CLOUD: For access to xServer INTERNET you need to set Username="xtok" and Password=yourtoken.

The DLLs: you should find the required x...dll's within the /clients folder of each server.
Worst case is to collect the different dll's manually.

Does this answer the question?

Best regards,
Bernd

PS: I usually create my connection classes via WSDL.exe.

Re: Accessing the methods of xLocate service via WebClient i

Posted: Thu Mar 23, 2017 7:40 am
by webdirekt
Hi Bernd,
Thanks for the details.
We have now used the xlocate-dotnetclient.dll and xserverbase-dotnet-client.dll in our program and it works fine.

Regards
Ramanan