I found my mistake i forgot this line:

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);


On Tue, Oct 22, 2013 at 2:27 PM, Макс Кливер <[email protected]> wrote:

> Hi.
>
> I can create new style with cURL:
>
> *curl.exe -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d
> "<style><name>tester</name><filename>tester.sld</filename></style>"
> 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<http://www.ibm.com/developerworks/library/os-geoserver/>.
> 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:
>
>
>
> *    $contentType = 'application/vnd.ogc.sld+xml';
>     $ch = curl_init();
>     curl_setopt($ch, CURLOPT_URL, 
> '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);
>
> *
>
> And test data is a simple sld file:*
>
>     *
> *<?xml version="1.0" encoding="ISO-8859-1"?>
>   <StyledLayerDescriptor version="1.0.0"
>   xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
>   xmlns="http://www.opengis.net/sld";
>   xmlns:ogc="http://www.opengis.net/ogc";
>   xmlns:xlink="http://www.w3.org/1999/xlink";
>   xmlns:xsi="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>
>
>
>
> *
>
> There can be errors in code above?
>
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to