Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GeoRest PUT with AIMS 2013

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
gluckett
2092 Views, 7 Replies

GeoRest PUT with AIMS 2013

Hi All, has anyone tried a PUT with XML with GeoRest with AIMS 2013?

 

I am getting an "Update Done" with a responseText but the data actually isn't updating.

 

Any clues? I am using IIS 7.5

 

 

7 REPLIES 7
Message 2 of 8
gluckett
in reply to: gluckett

Steps to reproduce:

1. Modify the existing restcfg.xml in the C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\GeoREST\conf\Sheboygan\Property\ folder to (A) point to AIMS and (B) Make XML editable:

<Resource uripart="property">
<Source type="MapGuide">
<FeatureSource>Library://Samples/Sheboygan/Data/Parcels.FeatureSource</FeatureSource>
<FeatureClass>SHP_Schema:Parcels</FeatureClass>
<ServerIp>127.0.0.1</ServerIp>
<ServerPort>2802</ServerPort>
</Source>

<Representation renderer="JSON" pattern=".json"/>
<Representation renderer="XML" pattern=".xml">
<Method name="GET" />
<Method name="PUT" />
<Method name="POST" />
<Method name="DELETE" />
</Representation>

 

2. Restart IIS to refresh the Config in GeoRest 

 

3. Test the site to make sure you can see the parcel data:

georest_aims2013.png

 

4. Now write the PUT code to change the RACRE from 14.25 to 500

<script language=javascript>

var xml='<?xml version="1.0" encoding="UTF-8" ?><FeatureSet><Features><Feature>';
xml=xml+ '<Property><Name>RACRE</Name>';
xml=xml+ '<Value>500</Value></Property>';
xml=xml+ '</Feature></Features></FeatureSet>';


var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = function(evt)
{
if(this.readyState == 4)
{
alert(this.responseText);
}
};
xmlhttp.open("PUT",'http://localhost/rest/data/property/1.xml',true);
xmlhttp.setRequestHeader("Content-Type","application/xml; charset=UTF-8");
xmlhttp.send(xml);
}
</script>

 

 

This returns "Update Done" but the data actually does not update (this worked with MG2011)

Load the 1.html to verify 

Message 3 of 8
gluckett
in reply to: gluckett

Aha!  You need to remove the read-only tag - unfortunately, you have to install MapGuide Maestro because there is not an option (at least I can't find it) in Autodesk Infrastructure Studio 2013 to remove this flag from the Datasource.

 

maestro_readonly_georest.png

Message 4 of 8
ericsn.tang
in reply to: gluckett

Hi Gluckett,

 

I still cannot make the PUT - Georest work! I created a new feature source which the data source is in sqlite format. I have tried to use SDF, SQLite. I using AIMS 2014 and the server is Windows Server 2008 R2 64-bit.

 

The restcfg.xml is:

 

<Resource uripart="building">
   <Source type="MapGuide">
    <FeatureSource>Library://Samples/Sheboygan/Data/BuildingOutlines.FeatureSource</FeatureSource>
    <FeatureClass>SHP_Schema:BuildingOutlines</FeatureClass>
   </Source>
   <Representation renderer="JSON" pattern=".json"/>
   <Representation renderer="XML" pattern=".xml"><Method name="PUT" /><Method name="POST" /><Method name="GET" /></Representation>
   <Representation renderer="Template" pattern=".html" mimetype="text/html" >
    <Templates section="BUILDING" prefix="BUILDING_">
      <Many file="building_map_html_many.tpl" />
      <Single file="building_map_html_single.tpl" />
      <None file="building_map_html_none.tpl" />
      <Error file="building_map_html_error.tpl" />
    </Templates>
    <Method name="GET" defaultcount="20" maxcount="500" />
   </Representation>

 

The building_map_html_single.tpl is:

 

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="/css/voka_int.css"> {{#BUILDING}} </head> <script> function UpdateFeature() {   var xml = '<?xml version="1.0" encoding="UTF-8"?><FeatureSet><Features><Feature>';   xml = xml+'<Property><Name>NAME</Name><Value>'+document.getElementById('feature_NAME').value+'</Value></Property>';   xml = xml+'</Feature></Features></FeatureSet>';                   

  var xmlhttp;

  if (window.XMLHttpRequest)

  {

    xmlhttp=new XMLHttpRequest();

    xmlhttp.onreadystatechange = function(evt)

    {

     if(this.readyState == 4)

     {

        alert(this.responseText);

     }

    };

    xmlhttp.open("PUT",'/rest/data/building/{{BUILDING_ID}}.xml',true);

    xmlhttp.setRequestHeader("Content-Type","application/xml; charset=UTF-8");

    xmlhttp.send(xml);

  }

} </script>

<table width="100%" height="50" id="feature_TABLE" class="mainfont">

               <tr>

                              <th height="10" align="left" valign="left" bgcolor="#E6E6E6" >Edit building data</th>

  </tr>

               <tr>

                              <td class="mainfont" height="10" >

                              <strong ><em>ID: </em></strong><input type="text" name="feature_ID" id="feature_ID" value="{{BUILDING_ID}}" size="17"/></td>

               </tr>

               <tr>

                              <td class="mainfont" height="10" >

                              <strong ><em>Name: </em></strong><input type="text" name="feature_NAME" id="feature_NAME" value="{{BUILDING_NAME}}" size="17"/></td>

                              </td>

               </tr>

               </table>

               <input type="button" name="send" id="button" value="Send" onClick="UpdateFeature()" size="17"/>

{{/BUILDING}}

</td>

</tr>

</table> </body> </html>

 

I found the feature class of Maestro is "Default: BuildingOutlines". It is not work if I change the feture class of restcfg.xml file to "Default: BuildingOutlines. Is there anything missing?

 

Tags (1)
Message 5 of 8
gluckett
in reply to: ericsn.tang

Make sure your SQLLITE file is editable in Windows Security (perhaps try "ALL USERS" - then restrict as you go).

Message 6 of 8
ericsn.tang
in reply to: gluckett

Thanks. I have grant the permission with write to the user "Everyone" and restart the machine. Finally It still cannot be updated via the georest! 😞

Message 7 of 8
gluckett
in reply to: ericsn.tang

Are you able to see the data read-only?
Message 8 of 8
ericsn.tang
in reply to: gluckett

The data can be displayed without any problem. Should I use the SDF file directly instead of <FeatureSource>Library://GEOTECHNICAL/Slope.FeatureSource</FeatureSource>?

 

Thanks 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report