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
Solved! Go to Solution.
Solved by gluckett. Go to Solution.
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:
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
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.
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?
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! 😞
The data can be displayed without any problem. Should I use the SDF file directly instead of <FeatureSource>Library://GEOTECHNICAL/Slope.FeatureSource</FeatureSource>?
Thanks 🙂