Geographic Information Systems Asked by Ido H Levi on February 17, 2021
I have a geoserver which I want to edit using c-sharp, I managed to retrieve information from it, but I haven’t found a way to make any changes – I know that there is WFS-T but I haven’t found a way to initialize it, I made the xml file (with my insert/delete/update), but I’m not sure how to send it to my geoserver, how can I send it using csharp?
URL = "http://localhost:8080/geoserver/topp"
XML file:
<?xml version="1.0" ?>
<wfs:Transaction
version="2.0.0"
service="WFS"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:wfs="http://www.opengis.net/wfs/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0.0/wfs.xsd">
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:ValueReference>STATE_NAME</wfs:ValueReference>
<wfs:Value>Caliwhilenia</wfs:Value>
</wfs:Property>
<ogc:Filter>
<ogc:PropertyName>STATE_NAME</ogc:PropertyName>
<ogc:Literal>California</ogc:Literal>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
request code
WebRequest request = WebRequest.Create(url); //the geoserver url
request.ContentType = "text/xml";
request.Method = "POST";
request.Credentials = new NetworkCredential("admin", "geoserver");
byte[] buffer = File.ReadAllBytes(xmlrequest); //Makes a change to the state's name
Stream reqstr = request.GetRequestStream();
reqstr.Write(buffer, 0, buffer.Length);
reqstr.Close();
WebResponse response = request.GetResponse();
The geoserver is not changing the state’s name
Update: now it connects to the server but I’m getting a “OperationParsingFailed” exception, altough I find that there is noting wrong with my xml file
Problem was that I didn't used all of my namespaces which has made a conflict, removed the unnecessary ones and it works like magic
Answered by Ido H Levi on February 17, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP