Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

This is a discussion on Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP within the Development forums, part of the MapPoint Desktop Discussion category; Hello, I try to consum the MapPoint Web Service in PHP and especially, the findNearBy method. I want to use ...

  1. #1
    freediver29 is offline Junior Member White Belt
    Join Date
    Jun 2009
    Location
    perros-guirec
    Posts
    3

    Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

    Hello,

    I try to consum the MapPoint Web Service in PHP and especially, the findNearBy method.
    I want to use the filter capability on this request, and when I provide simple parameters as EntityTypeName, the call works fine.
    But when I provide more complex parameters as PropertyNames, WhereClause or Expression, I encounter always an error.

    For information, I got the equivalent of php classes of Mappoint here : MapPoint PHP API (image, Array, user, PHP) - PHP Classes.
    I found some information here on how to consum the MapPoint Web Service in PHP : Consuming MapPoint Web Service in PHP
    I use, to do the call to the wsdl, the native SOAP of PHP (in v5.2.5) and not the nusoap library.

    Here is a simple code that works fine :
    Code:
        // define the find range of the search options
        $loFindRange             = new FindRange();
        $loFindRange->StartIndex = 0;
        $loFindRange->Count      = $poSearchCriteria->count;
    
        // define the search options
        $loFindOptions                 = new FindOptions();
        $loFindOptions->ThresholdScore = 0;
        $loFindOptions->Range          = $loFindRange;
    
        // define the center of the search
        $loLatLong            = new LatLong();
        $loLatLong->Latitude  = $poSearchCriteria->latitude;
        $loLatLong->Longitude = $poSearchCriteria->longitude;
    
        // Set up the specification object
        $findAddressSpec                         = new FindAddressSpecification();
        $findAddressSpec->DataSourceName         = $poSearchCriteria->dataSourceName;
        $findAddressSpec->Distance               = $poSearchCriteria->distance;
        $findAddressSpec->Options                = $loFindOptions;
        $findAddressSpec->LatLong                = $loLatLong;
    
        // define the find filer of the search options
        $findAddressSpec->Filter                 = new FindFilter();
        $findAddressSpec->Filter->EntityTypeName = $poSearchCriteria->entityTypeName;
    But when I add the Expression parameter, I got an error :
    Code:
       // specify the text of the Expression.
       $loFilterExpression = new FilterExpression();
       $loFilterExpression->Text = "poi_name = {0}";
    
       // set the paramater values to match the placeholder in the Text string.
       $lAParameters                         = array();
       $lAParameters[0]                      = "Gare";
       $loFilterExpression->Parameters       = (object)$lAParameters;
       $findAddressSpec->Filter->Expression  = $loFilterExpression;
    And the error is the following :
    SoapFault exception: [soap:Client] The value of the specified parameter index is out of range. Argument: specification.Filter.Expression.Text[7] in...
    So what I understand, it's that the webservice is unable to recognize that {0} is the first index of my parameters array...it's strange...
    So am I misunderstanding the use of the webservice or can there be a problem with the parameters send when calling the webservice???

    Thanks for advices

  2. #2
    freediver29 is offline Junior Member White Belt
    Join Date
    Jun 2009
    Location
    perros-guirec
    Posts
    3

    Re: Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

    If you want to test this, just copy the script which is in attachments in your web server root directory and edit the four parameters in ./mappoint/ClassLoader.php:

    • MP_USER,
    • MP_PASS,
    • PROXY_HOST,
    • PROXY_PORT

    Try it by uncommenting/commenting the line 53 of the index.php file...When uncommented, an error occured...
    Attached Files Attached Files

  3. #3
    freediver29 is offline Junior Member White Belt
    Join Date
    Jun 2009
    Location
    perros-guirec
    Posts
    3

    Re: Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

    Ok I found the problem. It's a problem with the type of the parameters which are sent through the SOAP mechanism.
    If the parameter type is not specified, the SOAP content does specify the type of the parameter, this is the default behavior.
    The solution is consequently to indicate the type of the parameter with this line :

    Code:
    $lAParameters[0] = new SoapVar( "Gare", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
    I found another error, we don't have to cast the parameters array in object. So the final code is :

    Code:
    $lAParameters                         = array();
    $lAParameters[0]                      = new SoapVar( "Gare", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
    $loFilterExpression->Parameters       = $lAParameters;
    $findAddressSpec->Filter->Expression  = $loFilterExpression;

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,082
    Blog Entries
    4

    Re: Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

    Thanks for following up!

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FindNearby Method
    By trevorjdaniel in forum Bing Maps and MapPoint Web Service
    Replies: 1
    Last Post: 01-24-2009, 05:53 AM
  2. How to delete circle from map after Findnearby method
    By azorgnairelau in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 11-28-2007, 12:41 PM
  3. Is new datasource MapPointNAICS.NA support findnearby Method
    By saad in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-18-2005, 02:08 AM
  4. Method FindNearby() with a route object
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 12-19-2002, 08:06 AM
  5. FindNearby Method
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-24-2002, 09:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58