Hi.
I can create new style with cURL:
curl.exe -v -u admin:geoserver -XPOST -H “Content-type: text/xml” -d “testertester.sld” http://localhost:8080/geoserver/rest/styles
curl.exe -v -u admin:geoserver -XPUT -H “Content-type: application/vnd.ogc.sld+xml” -d @tester.sld http://localhost:8080/geoserver/rest/styles/tester
Now i want to make same with php. I found GeoserverWrapper on ibm site. And when i was tied to create new style i got a blank style. So it’s mean that POST request works. But my style not upload on server.
There a code snippet of PUT request:
<b> $contentType = 'application/vnd.ogc.sld+xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '[http://localhost:8080/geoserver/rest/styles/tester](http://localhost:8080/geoserver/rest/styles/tester)');
curl_setopt($ch, CURLOPT_USERPWD, "admin:geoserver");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("Content-Type: $contentType",
'Content-Length: '.strlen(stripslashes($data)))
);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$rslt = curl_exec($ch);
$info = curl_getinfo($ch);</b>
And test data is a simple sld file:
<b><?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="[http://www.opengis.net/sld](http://www.opengis.net/sld) StyledLayerDescriptor.xsd"
xmlns="[http://www.opengis.net/sld](http://www.opengis.net/sld)"
xmlns:ogc="[http://www.opengis.net/ogc](http://www.opengis.net/ogc)"
xmlns:xlink="[http://www.w3.org/1999/xlink](http://www.w3.org/1999/xlink)"
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)">
<NamedLayer>
<Name>Dashed line</Name>
<UserStyle>
<Title>SLD Cook Book: Dashed line</Title>
<FeatureTypeStyle>
<Rule>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#0000FF</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
<CssParameter name="stroke-dasharray">5 2</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor></b>
There can be errors in code above?