Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to build a web mapping app that retrieves data from our WFS server. I'd like to avoid JavaScript for the main search scripts.

From what's I've read the best way to send the XML POST request to the server is to use CURL.

I have tested the following very simple XML in GeoServer and it's fine. Hwever, when I send the request as below I get an error.

I have trawled Google but can't seem to find any examples of doing this. I can't believe I'm the only one trying to do this!

The PHP Code:

//Set variables.
$url = "http://squirrel.bis.local:8080/geoserver/wfs";
$post = '<GetCapabilities 
    xsi:schemaLocation="    /wfs.xsd"/>';

$post = str_replace("\r", "", $post); //Clean string.
$post = str_replace("\n", "", $post);
$post = str_replace("\t", "", $post);
$post = str_replace("> <", "><", $post); //Clean any leading spaces between elements.

//What are we sending?
echo "Post Request:<br />";
echo htmlentities($post);
echo "<br /><br />";

//Send post request.
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

//Collect result.
$result = curl_exec($ch);
curl_close ($ch);

//What did we get?
echo "Post Response:<br />";
echo "<pre>" . htmlentities($result) . "</pre>";
echo "<br /><br />";


The error is:

<ows:ExceptionReport version="1.0.0"
http://squirrel.bis.local:8080/geoserver/schemas/ows/1.0.0                   /owsExceptionReport.xsd"
xmlns:xsi=""     xmlns:ows="">
<ows:Exception exceptionCode="MissingParameterValue" locator="request">
<ows:ExceptionText>Could not determine geoserver request from http request         org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@19f0b0a6

Thanks Steve

share|improve this question
up vote 1 down vote accepted

You have to make sure to set the HTTP Content-Type/Content-Length headers:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', 'Content-Length: '.strlen($post)));

In this case, the value of Content-Length would be the size of your XML request.

share|improve this answer
Job done! Working perfectly!! Thanks you very much for your help! – user8262 Jun 21 '12 at 8:40

You need to check what is actually sent to the server but I suspect you have deleted all the white space between the attributes in your request so it looks something like


If I'm right then try (replace \t etc with space):

$post = str_replace("\r", " ", $post); //Clean string.
$post = str_replace("\n", " ", $post);
$post = str_replace("\t", " ", $post);
share|improve this answer
Checked this and I don't think it's the issue. I was careful to add a trailing space at the end of each line of XML in case this happened. I have added the space as suggested and the response is the same. The string being sent is: <GetCapabilities service="WFS" xmlns=""; xmlns:xsi=""; xsi:schemaLocation=""/>; – user8262 Jun 20 '12 at 13:15
are there really ; in there between the lines? if so that's the problem. – iant Jun 20 '12 at 13:55
No - that's just someting that's crept in during copy and paste! – user8262 Jun 21 '12 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.