Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapScript-PHP does not load params encoded in XML passed through "request body" #4330

Closed
iacovlev-pavel opened this issue May 29, 2012 · 8 comments

Comments

@iacovlev-pavel
Copy link

MapScript-PHP does not load params encoded in XML passed through "request body". At the moment this is a standard way for OpenLayers to request data via WFS protocol.

In php I can read the request body thought:

<?php
$request_body = file_get_contents('php://input'); 

But I don't know how to pass this data to OwsrequestObj, there are just set/get method for single params available in API.
Also from the documentation only the following inputs are supported by load params
loadParams(): REQUEST_METHOD, QUERY_STRING and HTTP_COOKIE.

@iacovlev-pavel
Copy link
Author

Any confirm on this issue ? In OpenLayers 2.12 you can use WFS only via "request body" and you have to add a deprecated WFS class to avoid this issue.

@keithamoss
Copy link

Has anyone had a chance to look at this? It's been a while :)

@dmorissette
Copy link
Contributor

Looking at the source of mapscript/php/owsrequest.c, the OWSRequestObj.loadParams() method should automatically read the XML POST data from PHP and make it available to the mapObj.OWSDispatch() method when you call it, without any special action on your part.

To verify that this is working as expected, after your call to OWSRequestObj.loadParams(), you can print the OWSRequestObj.postrequest member variable which should contain a copy of the XML POST data.

If that doesn't work as expected then we'll need to have a look.

@keithamoss
Copy link

Hi Daniel,

I'm afraid it's still not working.

Here's my test case:

<?php
$request = new OWSRequestObj();
$request->loadParams();

echo "numparams: $request->numparams\r\n";
echo "type: $request->type\r\n";
echo "postrequest: $request->postrequest\r\n";
?>

and here's my POST request:

<?xml version="1.0" encoding="utf-8"?><GetFeature xmlns="http://www.opengis.net/wfs"  xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.0.0" outputFormat="GML3" maxFeatures="15" handle="" ><Query typeName="layer7_fhs_last_0_12.shp" srsName="EPSG:4326"  /></GetFeature>

and the result:

numparams: -1
type: 0
<br >
<b>Fatal error</b>:  Uncaught exception 'MapScriptException' with message 'Property 'postrequest' does not exist in this object.'

I would expect the case to fail eventually, since it doesn't actually load a map file, but from my end it doesn't seem to even be getting to that point.

MapServer 6.1-dev running PHP via CGI.

@juliensam
Copy link
Contributor

I just tried the code you attached in the previous comment with MapServer 6.3-dev and got no error. Can you provide the revision your MapServer 6.1-dev is and provide the OpenLayers code you used to test? It may be related to the way OpenLayers builds the request.

Here's the code I used to call my PHP test script:

var request = OpenLayers.Request.POST({
    url: "http://127.0.0.1/test/test.php",
    data: '<?xml version="1.0" encoding="utf-8"?><GetFeature xmlns="http://www.opengis.net/wfs"  xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.0.0" outputFormat="GML3" maxFeatures="15" handle="" ><Query typeName="layer7_fhs_last_0_12.shp" srsName="EPSG:4326"  /></GetFeature>',
    callback: function(t) {
        console.log(t.responseText);
}
});

My PHP code was:

$request = new OWSRequestObj();
$request->loadParams();

echo "numparams: $request->numparams\r\n";
echo "type: $request->type\r\n";
echo "postrequest: $request->postrequest\r\n";

And the response:

numparams: 0
type: 1
postrequest: <?xml version="1.0" encoding="utf-8"?><GetFeature xmlns="http://www.opengis.net/wfs"  xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.0.0" outputFormat="GML3" maxFeatures="15" handle="" ><Query typeName="layer7_fhs_last_0_12.shp" srsName="EPSG:4326"  /></GetFeature>

@juliensam
Copy link
Contributor

For the record, MapServer 6.2.0 returns the exact same result for me. Is it possible for you to test with 6.2?

@keithamoss
Copy link

I'll give it a go and get back to you. Having some issues getting MS4W's version of 6.2 to run at the moment, though.

@jratike80
Copy link

Proofed to work with MS 6.2.0 and 6.3-dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants