I am trying to make a leaflet app that send and update point data using WFS-T, geoserver, postgis. Its a new field for me so bare with me. I found this XML structure for the request below but I dont really understand the function of the different xml tags.
EDIT: Here is a working template for how the request should look like in an attempt to make it blindly obvious for other beginners with wfs-t
var postData =
'<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:test_wfst="namespace URI" xmlns:gml="http://www.opengis.net/gml" version="1.1.0" service="WFS" xsi:schemaLocation="namespace URI">\
<Insert xmlns="http://www.opengis.net/wfs">\
<layername xmlns="namespace URI">\
<geom xmlns="namespace URI">\
<gml:Point srsName="EPSG:4326">\
<gml:coordinates cs="," >'+geometry+'</gml:coordinates>\
</gml:Point>\
</geom>\
<text xmlns="namespace URI">'+text+'</text>\
</layername>\
</Insert>\
</Transaction>';
I have replaced http://www.domain.com/app to the one I am using. I just want to make sure I am on the right track and that the XML is correct?
I get a POST (403) OK error. I have not set any restrictions on authorization for the layer atm as far as I know. (WFS-T works when I use it in QGIS without authorization) Does it mean the XML is correct but somehow there is still an authorization error, or could i get the error anyway if the XML is wrong?
EDIT: Log file
2016-09-28 15:13:22,781 INFO [geoserver.wfs] -
Request: getServiceInfo
2016-09-28 15:13:22,781 WARN [geotools.xml] - Schema location not specified as namespace/location pair. Ignoring https://www.domain.com/app (not real url)
2016-09-28 15:13:22,781 WARN [geotools.xml] - Could not find a schema
DescribeFeature request
<xsd:schema xmlns:gml="http://www.opengis.net/gml" xmlns:test_wfs_edit="test_wfst" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="test_wfst">
<xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://domain.com:80/geoserver/schemas/gml/2.1.2/feature.xsd"/>
<xsd:complexType name="wfs_punkt_testType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="id" nillable="false" type="xsd:int"/>
<xsd:element maxOccurs="1" minOccurs="0" name="notat" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="bol" nillable="true" type="xsd:boolean"/>
<xsd:element maxOccurs="1" minOccurs="0" name="verdi" nillable="true" type="xsd:int"/>
<xsd:element maxOccurs="1" minOccurs="0" name="dato" nillable="true" type="xsd:date"/>
<xsd:element maxOccurs="1" minOccurs="0" name="edited" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="geom" nillable="true" type="gml:PointPropertyType"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="wfs_punkt_test" substitutionGroup="gml:_Feature" type="test_wfs_edit:wfs_punkt_testType"/>
</xsd:schema>
JS:
var geometry = "63.00,23.00";
var postData =
'<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:skiltbase="http://www.domain.com/app" xmlns:gml="http://www.opengis.net/gml" version="1.1.0" service="WFS" xsi:schemaLocation="http://www.domain.com/app">\
<Insert xmlns="http://www.opengis.net/wfs">\
<order xmlns="http://www.domain.com/app">\
<geom xmlns="hhttp://www.domain.com/app">\
<gml:Point srsName="EPSG:4326">\
<gml:coordinates cs="," >'+geometry+'</gml:coordinates>\
</gml:Point>\
</geom>\
<date xmlns="http://www.domain.com/app">'+date+'</date>\
<id xmlns="http://www.domain.com/app">'+id+'</id>\
</order>\
</Insert>\
</Transaction>';
$.ajax({
type: "POST",
url: rooturl,
dataType: "xml",
contentType: "text/xml",
data: postData,
success: function(xml) {
alert('Success!!')
},
success: function(xml) {
alert('success')
},
error: function(xml){
console.log('error')
}