Thank you @Hans for the help. Your suggestion worked perfectly but still I
faced new error in it.
My code is like this now.
 var format = new ol.format.GML({
                    // // featureNS: 'http://argeomatica.com',
                    featureNS: 'housenumber',
                    // // featureType: 'playa_sample',
                    featureType: 'housetry',
                    // service: 'WFS',
                    // version: '1.1.0',
                    // request: 'GetFeature',
                    srsName: 'EPSG:3857'
                  });

                  var gml = format.writeGeometry(coords, {
                    dataProjection: 'EPSG:4326',
                    featureProjection: 'urn:ogc:def:crs:EPSG::4326',
                    rightHanded: false
                      }
                  );

                  var url1 = 'http://localhost:8080/geoserver/wfs';
                  var method = 'POST';
                  var postData1 =
                  '<wfs:Transaction service="WFS" version="1.1.0"\n' +
                  'xmlns:wfs="http://www.opengis.net/wfs"\n' +
                  'xmlns:housenumber="http://www.openplans.org/housenumber";
\n' +
                  'xmlns:gml="http://www.opengis.net/gml"\n' +
                  'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n'
+
                  // 'xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd
http://www.openplans.org/housenumber
http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=housenumber:housetry";>\n'
+
                  'xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd
http://www.openplans.org/housenumber
http://localhost:8080/geoserver/wfs/?service=wfs&amp;request=DescribeFeatureType&amp;version=1.1.0&amp;typename=housenumber:housetry
">\n' +
                  '<wfs:Insert>\n' +
                  '<housenumber:housetry>\n' +
                  '<housenumber:geom>\n' +
                  gml + '\n' +
                  '</housenumber:geom>\n' +
                  '<housenumber:area>' + area + '</housenumber:area>\n' +
                  '<housenumber:name_house>' + name_house +
'</housenumber:name_house>\n' +
                  '</housenumber:housetry>\n' +
                  '</wfs:Insert>\n' +
                  '</wfs:Transaction>\n';

This is the error I get now.
<?xml version="1.0" encoding="UTF-8"?><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://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd";>
  <ows:Exception exceptionCode="InvalidParameterValue">
    <ows:ExceptionText>Feature type 'housetry' is not available:
</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

 I think there is a problem with the feature type in the GML part. I tried
housenumber:housetry in the featureType but still it does not work.
Any suggestion and help will be appreciated.

Regards,
Abin


On Tue, Sep 27, 2022 at 3:21 PM Hans Yperman <hans.yper...@vliz.be> wrote:

> Hello abin,
>
>
>
> My guess is you are violating XML escaping.  See e.g.
> https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
>
>
>
> XML has escaping rules, e.g., if you want the character & in your XML, you
> should escape it as &amp;
>
> In your long schemalocation line, I see
>
>
>
> …fs&request…  and …1.1.0&typename
>
>
>
> These have ampersands and should be escaped, e.g.  …fs&amp;request=…
>
>
>
> The root cause of this trouble is that you are generating XML by
> concatenating strings together.  That makes you responsible for following
> all kinds of XML rules.  I’d advise you to find an XML (or SOAP?) library
> for your programming language(Java?), and let it write/send the correct XML
> for you.  While this is more effort short term, you’ll quickly gain it back
> by not worrying about this, with an additional bonus of security .  For
> example, some trouble you’ll have to tackle in the near future:
>
>
>
>    1. you need to escape the variables too: gml3, area and name_house
>    2. You are manually handling namespaces and prefixes, which can get
>    very complicated.
>
>
>
>
>
> *Hans Yperman*
>
> IT staff
>
> Department IT
>
> *Vlaams Instituut voor de Zee vzw*
>
> InnovOcean Campus, Jacobsenstraat 1
>
> 8400 Oostende, België
>
>
>
> T +32 (0) / M +32 (0)
>
> *www.vliz.be <http://www.vliz.be>*
>
>
>
>
>
> *From:* abin prajapati <abinprajap...@gmail.com>
> *Sent:* dinsdag 27 september 2022 10:45
> *To:* geoserver-users@lists.sourceforge.net
> *Subject:* [Geoserver-users] No applicable Code Error in Geoserver
>
>
>
> Hello all,
>
> I am inserting a polygon to my database using Geoserver Transaction
> Insert. My code is:
>
>                   '<wfs:Transaction service="WFS" version="1.1.0"\n' +
>
>                   'xmlns:housenumber="http://www.openplans.org/housenumber
> "\n' +
>
>                   'xmlns:ogc="http://www.opengis.net/ogc"\n' +
>
>                   'xmlns:wfs="http://www.opengis.net/wfs"\n' +
>
>                   'xmlns:gml="http://www.opengis.net/gml"\n' +
>
>                   'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n
> ' +
>
>                   'xsi:schemaLocation="http://www.opengis.net/wfs
> http://schemas.opengis.net/wfs/1.1.0/WFS-transaction.xsd
> http://www.openplans.org/housenumber
> http://localhost:8080/geoserver/wfs/?service=wfs&request=DescribeFeatureType&version=1.1.0&typename=housenumber:housetry
> ">\n' +
>
>                   '<wfs:Insert>\n' +
>
>                   '<housenumber:housetry>\n' +
>
>                   '<housenumber:geom>\n' +
>
>                   gml3 + '\n' +
>
>                   '</housenumber:geom>\n' +
>
>                   '<housenumber:area>' + area + '</housenumber:area>\n' +
>
>                   '<housenumber:name_house>' + name_house +
> '</housenumber:name_house>\n' +
>
>                   '</housenumber:housetry>\n' +
>
>                   '</wfs:Insert>\n' +
>
>                   '</wfs:Transaction>\n';
>
>
>
>
>
> I got this error:
>
> <?xml version="1.0" encoding="UTF-8"?><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://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd";>
>   <ows:Exception exceptionCode="NoApplicableCode">
>     <ows:ExceptionText>org.xmlpull.v1.XmlPullParserException: entity
> reference name can not contain character =' (position: START_DOCUMENT seen
> ...senumber http://localhost:8080/geoserver/wfs/?service=wfs&amp;request=...
> @7:199)
> entity reference name can not contain character =' (position:
> START_DOCUMENT seen ...senumber
> http://localhost:8080/geoserver/wfs/?service=wfs&amp;request=... @7:199)
> </ows:ExceptionText>
>   </ows:Exception>
> </ows:ExceptionReport>
>
>
>
> Could anybody help me in this regards? I have no idea with this error
> encountered.
>
>
>
>
>
>
>
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to