Submitting POST XML query from Matlab



I'm trying to figure out how to do an OGC CSW (Catalog Service for the Web) simple POST operation using a blob of XML in Matlab. I've been reading the documentation for Mathworks urlread and the 3rd party urlread2, and I'm trying to replicate this simple example:



wget http://ift.tt/1EtL3Yr --post-file=./post_query.xml


where post_query.xml is:



<csw:GetRecords xmlns:csw="http://ift.tt/1ikcaic" version="2.0.2" service="CSW" resultType="results" startPosition="1" maxRecords="11" outputSchema="http://ift.tt/1ooKGHU"> <csw:Query typeNames="csw:Record" xmlns:ogc="http://ift.tt/KDbkOK" xmlns:gml="http://ift.tt/WaETtx" >
<csw:ElementSetName>full</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>apiso:modified</ogc:PropertyName> <ogc:Literal>2014-09-30</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>apiso:modified</ogc:PropertyName> <ogc:Literal>2014-10-02</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
</csw:Constraint>
</csw:Query>
</csw:GetRecords>


I've tried a lot of things, but the only thing I've been able to get to work is urlread2 like this:



url = 'http://ift.tt/1EtL3Yr'
paramString=fileread('post_query.xml')
header.name='Content-Type';
header.value='application/x-www-form-urlencoded';
[output,extras] = urlread2(url,'POST',paramString,header);


Is there a better way to solve this problem?


Is there a way to do this using urlread or some other tool in the standard Matlab distribution?


No comments:

Post a Comment