Ciao a tutti,sto sviluppando attraverso l'uso di Geoserver e OpenLayers, un semplice servizio wfs-t costituito per ora da un unico layer di punti.<br>Sto costruendo la toolbar per verificare che le operazioni di aggiunta punti ,rimozione punti e spostamento vadano a buon fine.Ho inserito un semplice link dove cliccando mi lascia salvare le operazioni che compio.Il problema è il seguente:<br>
<br>Vado ad aggiungere il punto e quando clicco sul link Save,mi appare questo alert:<br><br>WFS Transaction: FAILED <?xml version="1.0" ?><br><ServiceExceptionReport<br> version="1.2.0"<br>
xmlns="<a href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</a>"<br> xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"<br> xsi:schemaLocation="<a href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</a> <a href="http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd</a>"><br>
<ServiceException><br> java.lang.ClassCastException<br>null<br></ServiceException></ServiceExceptionReport><br><br><br>Inoltre se quello stesso punto lo vado a cancellare e salvo l'opezione di cancellazione mi appare quest'altro alert:<br>
<br>WFS Transaction: SUCCESS <?xml version="1.0" encoding="UTF-8"?><wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="<a href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</a>" xmlns:ogc="<a href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" xsi:schemaLocation="<a href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</a> <a href="http://localhost:8080/schemas/wfs/1.0.0/WFS-transaction.xsd">http://localhost:8080/schemas/wfs/1.0.0/WFS-transaction.xsd</a>"><wfs:InsertResult><ogc:FeatureId fid="new0"/></wfs:InsertResult> <wfs:TransactionResult> <wfs:Status> <wfs:SUCCESS/> </wfs:Status> </wfs:TransactionResult></wfs:WFS_TransactionResponse><br>
<br>Volevo capire dove avevo sbagliato o se devo impostare qualcosa in particolare affinchè l'operazione di aggiunta punto abbia successo come l'opezione di cancellazione.<br>Vi posto per sicurezza anche un po di codice,in modo da potervi dare piu info possibili:<br>
<br><br><br> function init(){<br><br><br> <br> map = new OpenLayers.Map('map');<br> <br> <br> <br> // create WFS layer<br> var perugia = new OpenLayers.Layer.WFS(<br> "Perugia",<br>
"/wfs?strict=true",<br> {typename: 'perugia:POI_Perugia'},<br> {<br> version:"1.0.0",<br> typename: 'POI_Perugia',<br>
featureNS: '<a href="https://sites.google.com/site/gisperugia/">https://sites.google.com/site/gisperugia/</a>',<br> extractAttributes: true,<br> isBaseLayer:true<br>
}<br><br> <br> );<br> perugia.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"}, <br> OpenLayers.Feature.Vector.style["default"]);<br>
<br> map.addLayer(perugia);<br><br><br> var panel = new OpenLayers.Control.Panel(<br> {displayClass: 'olControlEditingToolbar'}<br> );<br> <br><br><br> var drawPoint = new OpenLayers.Control.DrawFeature(<br>
perugia, OpenLayers.Handler.Point,<br> {displayClass: 'olControlDrawFeaturePoint',<br> title:'Add Point'});<br><br> drawPoint.featureAdded = function(feature) {<br>
feature.layer.eraseFeatures([feature]);<br> // cast to multipoint<br> feature.geometry = new OpenLayers.Geometry.MultiPoint(<br> feature.geometry<br> );<br>
feature.style.strokeColor = "#0000ff";<br> feature.state = OpenLayers.State.INSERT;<br> feature.layer.drawFeature(feature);<br> }<br> <br><br><br> <br> var edit = new OpenLayers.Control.ModifyFeature(perugia, {<br>
title: "Modify Feature",<br> displayClass: "olControlModifyFeature"<br> });<br><br><br> var del = new DeleteFeature(perugia, {title: "Delete Feature"});<br> panel.addControls([new OpenLayers.Control.Navigation(),drawPoint,edit,del]);<br>
<br> map.addControl(panel);<br> map.addControl(new OpenLayers.Control.LayerSwitcher());<br><br> map.zoomToExtent(<br> new OpenLayers.Bounds(4.9,40.663,15.106, 46.774)<br> ); <br>
<br> } <br> </script><br> </head><br> <body onload="init()"><br> <h3>Perugia wfs-t </h3><br> <br> <br> <div id="map"></div><br><a href="#" onclick="map.layers[0].commit();return false">Save</a><br>
</body><br></html><br><br><br>Grazie infinite.<br>Nicola.<br><br><br><br>