MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion > Development

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-08-2009
Junior Member
White Belt
 
Join Date: Jun 2009
Location: perros-guirec
Posts: 3
Send a message via MSN to freediver29
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 :
Quote:
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #2 (permalink)  
Old 06-09-2009
Junior Member
White Belt
 
Join Date: Jun 2009
Location: perros-guirec
Posts: 3
Send a message via MSN to freediver29
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
File Type: zip mappoint_php_api-2005-10-19.zip (97.5 KB, 3 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3 (permalink)  
Old 06-10-2009
Junior Member
White Belt
 
Join Date: Jun 2009
Location: perros-guirec
Posts: 3
Send a message via MSN to freediver29
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;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4 (permalink)  
Old 06-10-2009
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 3,420
Blog Entries: 3
Re: Experiencing problems when using the findNearBy method of the MapPoint Web Service in PHP

Thanks for following up!

Eric
__________________
~ Now taking orders for MapPoint 2010 ~
~~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
experiencing, findnearby, mappoint, method, php, problems, service, web


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/experiencing-problems-when-using-findnearby-method-mappoint-web-service-php-10586.html

Posted By For Type Date
Site content newsletter - PHP Classes This thread Refback 06-30-2009 01:48 AM
The Magazine for MapPoint - MP2K Magazine This thread Refback 06-11-2009 12:20 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

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


All times are GMT -5. The time now is 08:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
MP2K Magazine
Visitor Map



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 59 60 61 62 63 64 65 66 67