0

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

  • please add the code you have so far, and a description of what is not working. – Ian Turton Apr 4 at 7:24
  • The post has been updated with my request attempt – Ido H Levi Apr 4 at 7:28
  • We'd also need to see the contents of UpdateXML and url – Ian Turton Apr 4 at 7:49
  • I've just updated them both – Ido H Levi Apr 4 at 8:07
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.