<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi everybody,</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I'd like to generate a WFS GetFeature response with geotoolkit.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I've found here and there some clues but I just don't really know how to link everything together</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Here is the XML i'd like to generate:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><div><?xml version="1.0" encoding="UTF-8"?></div><div><wfs:FeatureCollection numberOfFeatures="1" timeStamp="2014-04-15T15:22:49.133+02:00" </div>
<div>      xsi:schemaLocation="<a href="http://www.resif.fr/station" target="_blank">http://www.resif.fr/station</a> <a href="http://localhost/wfs/schema.xsd" target="_blank">http://localhost/wfs/schema.xsd</a> <a href="http://www.opengis.net/wfs" target="_blank">http://www.opengis.net/wfs</a> <a href="http://ogo.heig-vd.ch/geoserver/schemas/wfs/1.1.0/wfs.xsd" target="_blank">http://ogo.heig-vd.ch:80/geoserver/schemas/wfs/1.1.0/wfs.xsd</a>" </div>
<div>      xmlns:station="<a href="http://www.resif.fr/station" target="_blank">http://www.resif.fr/station</a>" </div><div>      xmlns:ogc="<a href="http://www.opengis.net/ogc" target="_blank">http://www.opengis.net/ogc</a>" </div>
<div>      xmlns:wfs="<a href="http://www.opengis.net/wfs" target="_blank">http://www.opengis.net/wfs</a>" </div><div>      xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>" </div>
<div>      xmlns:gml="<a href="http://www.opengis.net/gml" target="_blank">http://www.opengis.net/gml</a>"  ></div><div><br></div><div>      <gml:featureMembers></div><div>      <station:station gml:id="cities.248"></div>
<div>        <station:station_name>Toulouse</station:station_name></div><div>        <station:the_geom></div><div>          <gml:Point srsDimension="2" srsName="<a href="http://www.opengis.net/gml/srs/epsg.xml#4326" target="_blank">http://www.opengis.net/gml/srs/epsg.xml#4326</a>"></div>
<div>            <gml:pos><a href="tel:1.4434%2043.6045" value="+14434436045" target="_blank">1.4434 43.6045</a></gml:pos></div><div>          </gml:Point></div><div>        </station:the_geom></div>
<div>      </station:station></div><div>      </gml:featureMembers></div><div>     </div><div>      </wfs:FeatureCollection></div><div><br></div><div>Here is my unworking coding attempt :</div><div><br></div>
<div><div>@Test</div><div><span style="white-space:pre-wrap">   </span>public void GetFeatureTest() throws Exception</div><div><span style="white-space:pre-wrap">    </span>{</div><div><span style="white-space:pre-wrap">                </span>final GeometryFactory gf = new GeometryFactory(); </div>
<div><span style="white-space:pre-wrap">          </span>GregorianCalendar c = new GregorianCalendar();</div><div><span style="white-space:pre-wrap">           </span>XMLGregorianCalendar timeStamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);</div>
<div><span style="white-space:pre-wrap">          </span>String version = "1.1.0";</div><div><span style="white-space:pre-wrap">              </span>FeatureCollectionType response = (FeatureCollectionType) WFSXmlFactory.buildFeatureCollection(version, "id", 2, timeStamp);</div>
<div><span style="white-space:pre-wrap">          </span></div><div><span style="white-space:pre-wrap">         </span>final FeatureTypeBuilder ftb = new FeatureTypeBuilder();</div><div><span style="white-space:pre-wrap">         </span>ftb.setName("station:stationType");</div>
<div><span style="white-space:pre-wrap">          </span>ftb.add("name", String.class);</div><div><span style="white-space:pre-wrap">         </span>DefaultGeographicCRS wgs84 = DefaultGeographicCRS.WGS84;</div><div><span style="white-space:pre-wrap">         </span>ftb.add("the_geom", PointType.class, wgs84);</div>
<div><span style="white-space:pre-wrap">          </span>ftb.setDefaultGeometry("the_geom");</div><div><span style="white-space:pre-wrap">            </span></div><div><span style="white-space:pre-wrap">         </span>final SimpleFeatureType sft = ftb.buildSimpleFeatureType();</div>
<div><span style="white-space:pre-wrap">          </span>SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(sft);</div><div><span style="white-space:pre-wrap">                </span>sfb.set("name", "Toulouse");</div><div><span style="white-space:pre-wrap">         </span>sfb.set("the_geom", gf.createPoint(new Coordinate(1.4526, 43.5957)));</div>
<div><span style="white-space:pre-wrap">          </span>final Feature feat = sfb.buildFeature("id-0");</div><div><br></div><div><span style="white-space:pre-wrap">                </span>Marshaller marshaller = WFSMarshallerPool.getInstance().acquireMarshaller();</div>
<div><span style="white-space:pre-wrap">          </span>final StringWriter sw = new StringWriter();</div><div><span style="white-space:pre-wrap">              </span>marshaller.marshal(response, sw);</div><div><span style="white-space:pre-wrap">                </span>WFSMarshallerPool.getInstance().recycle(marshaller);</div>
<div><span style="white-space:pre-wrap">          </span>System.out.println(sw.toString());</div><div><span style="white-space:pre-wrap">       </span>}</div></div><div><br></div><div>So, if someone can explain how to link FeatureType and FeaturePropertyType and all the other stuff, i'd be grateful :-) !</div>
<div><br></div><div>François</div></div></div>