I'm using OpenLayers 3.8.2. I have wfs layer. I insert a feature. I save this feature as follow(I use geoserver 2.7-SNAPSHOT in server side):
var features = source.getFeatures();
var insertedArr = [];
var updateArr = [];
var deleteArr = [];
for (var i in features) {
var state = features[i].getProperties().state;
switch (state) {
case "insert":
console.log("------- INSERT -------")
var feature = features[i];
var properties = feature.getProperties();
if (properties.boundedBy)
delete properties.boundedBy;
if (properties.the_geom)
delete properties.the_geom;
if (properties.geometry)
delete properties.geometry;
if (properties.controllerId)
delete properties.controllerId;
var geometry = feature.getGeometry().clone();
geometry.transform("EPSG:3857", "EPSG:4326");
newFeature = new ol.Feature({
the_geom: geometry
});
newFeature.setGeometryName("the_geom");
newFeature.setProperties(properties);
newFeature.setId(feature.getId());
insertedArr.push(newFeature);
break;
case "update":
...
break
case "delete":
...
break;
}
}
var wfs = new ol.format.WFS();
var node = wfs.writeTransaction(insertedArr, updateArr, deleteArr, {
featureType: "mf",
featurePrefix: 'Calk',
featureNS: "http://itsme.calk.ir",
version: '1.1.0',
srsName: "EPSG:4326"
});
var s = new XMLSerializer();
var url = "http://localhost:8080/geoserver/wfs";
Ext.Ajax.request({
url: 'proxy.cgi?url=' + encodeURIComponent(url),
method: 'POST',
xmlData: s.serializeToString(node),
headers: {
'Content-Type': 'text/xml'
},
success: function(response_) {
response = response_;
}
});
It send a request to server as follow:
<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<Insert>
<mf xmlns="http://itsme.calk.ir">
<the_geom>
<Polygon xmlns="http://www.opengis.net/gml">
<exterior>
<LinearRing>
<posList>48.05419921875 37.30901407427592 ... 48.05419921875 37.30901407427592</posList>
</LinearRing>
</exterior>
</Polygon>
</the_geom>
<region>MyRegion</region>
<shape_len>10</shape_len>
</mf>
</Insert>
</Transaction>
But the server response as follow:
<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/ows
http://192.168.3.2:8082/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidParameterValue">
<ows:ExceptionText>Error performing insert: java.lang.String cannot be cast to com.vividsolutions.jts.geom.Geometry</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
The discribefeatureType of geoserver's layer is as follow:
<xsd:schema xmlns:Calk="http://itsme.calk.ir" xmlns:gml="http://www.opengis.net/gml"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://itsme.calk.ir">
<xsd:import namespace="http://www.opengis.net/gml"
schemaLocation="http://192.168.3.2:8082/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
<xsd:complexType name="mfType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="region" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="shape_len" nillable="true" type="xsd:int"/>
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiSurfacePropertyType"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="mf" substitutionGroup="gml:_Feature" type="Calk:mfType"/>
</xsd:schema>
Where is the problem? Why server reply Error performing insert: java.lang.String cannot be cast to com.vividsolutions.jts.geom.Geometry
?
requested
in question.