You have to create a FeatureType before you can create a Layer (i.e. publish it). If you have already created a test layer then fetch the feature type of that one (like http://geoserver.ianturton.com/rest/workspaces/topp/datastores/bgs/featuretypes/test_uk_625k_mapped_feature.xml) but you should be able to delete quite a lot of that and leave it for GeoServer to fill in.
<featureType>
<name>test_uk_625k_mapped_feature</name>
<nativeName>test_uk_625k_mapped_feature</nativeName>
<namespace>
<name>topp</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://geoserver.ianturton.com/rest/namespaces/topp.xml" type="application/xml"/>
</namespace>
<title>uk_625k_mapped_feature</title>
<description>net.opengis.wfs20.impl.AbstractTypeImpl@1f89241 (value: Just for testing, lang: <unset>)</description>
<keywords>
<string>uk_625k_mapped_feature</string>
<string>features</string>
</keywords>
<nativeCRS class="projected">PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB 1936",
SPHEROID["Airy 1830", 6377563.396, 299.3249646, AUTHORITY["EPSG","7001"]],
TOWGS84[446.448, -125.157, 542.06, 0.15, 0.247, 0.842, -20.489],
AUTHORITY["EPSG","6277"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic longitude", EAST],
AXIS["Geodetic latitude", NORTH],
AUTHORITY["EPSG","4277"]],
PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]],
PARAMETER["central_meridian", -2.0],
PARAMETER["latitude_of_origin", 49.0],
PARAMETER["scale_factor", 0.9996012717],
PARAMETER["false_easting", 400000.0],
PARAMETER["false_northing", -100000.0],
UNIT["m", 1.0],
AXIS["Easting", EAST],
AXIS["Northing", NORTH],
AUTHORITY["EPSG","27700"]]</nativeCRS>
<srs>EPSG:27700</srs>
<nativeBoundingBox>
<minx>-132576.78915711527</minx>
<maxx>743466.6249987332</maxx>
<miny>-15669.960592884949</miny>
<maxy>1248847.1762802668</maxy>
<crs class="projected">EPSG:27700</crs>
</nativeBoundingBox>
<latLonBoundingBox>
<minx>-11.801005644638966</minx>
<maxx>4.349696858682689</maxx>
<miny>49.5245056714837</miny>
<maxy>61.11839723246307</maxy>
<crs>GEOGCS["WGS84(DD)",
DATUM["WGS84",
SPHEROID["WGS84", 6378137.0, 298.257223563]],
PRIMEM["Greenwich", 0.0],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic longitude", EAST],
AXIS["Geodetic latitude", NORTH]]</crs>
</latLonBoundingBox>
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
<enabled>true</enabled>
<store class="dataStore">
<name>bgs</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://geoserver.ianturton.com/rest/workspaces/topp/datastores/bgs.xml" type="application/xml"/>
</store>
<maxFeatures>0</maxFeatures>
<numDecimals>0</numDecimals>
<overridingServiceSRS>false</overridingServiceSRS>
<skipNumberMatched>false</skipNumberMatched>
<circularArcPresent>false</circularArcPresent>
<attributes>
<attribute>
<name>uuid</name>
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
<nillable>true</nillable>
<binding>java.lang.String</binding>
</attribute>
<attribute>
<name>lex</name>
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
<nillable>true</nillable>
<binding>java.lang.String</binding>
</attribute>
<attribute>
<name>rcs</name>
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
<nillable>true</nillable>
<binding>java.lang.String</binding>
</attribute>
<attribute>
<name>lex_rcs</name>
<minOccurs>1</minOccurs>
<maxOccurs>1</maxOccurs>
<nillable>true</nillable>
<binding>java.lang.String</binding>
</attribute>
<attribute>
<name>the_geom</name>
<minOccurs>0</minOccurs>
<maxOccurs>1</maxOccurs>
<nillable>true</nillable>
<binding>com.vividsolutions.jts.geom.Geometry</binding>
</attribute>
</attributes>
</featureType>
Experiment and when it works update the documentation for the next person along.
Actually, this has nothing to do with the way you make the request. RESTful services can provide different representations of their state depending on the output format you request. So the information you get back is the same in the browser and the command line if you go to a URL like:
http://localhost:8080/geoserver/rest/layers/topp:states.xml
in the browser or using CURL (or you can drop the .xml
in CURL and add -H "accept: application/xml"
). If however, you go to
http://localhost:8080/geoserver/rest/layers/topp:states.html
You will get the HTML representation back, this has less information in it as it's designed for humans not machines. In this case, you will see the HTML by default in the web browser if you don't specify the extension as that is what browsers expect to get.
Best Answer
There are some PHP REST samples already mentioned at this other answer but links are dead.
You can also use the samples at IBM DeveloperWorks "Get started with GeoServer and its REST API" (to download and in the post).