PostgREST / PostgREST/postgrest

feat: support XML?

Open
#2,188 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Haskell
Stars
27.7k
Forks
1.2k
Avg merge
1d 9h
Merged PRs (30d)
54

Description

Is there any interest in this project to support creating SOAP endpoints? I don't think it would be hard.

I am building upon #1927, especially:
Uploading raw text to a function. The function must be defined with a single unnamed text param and Content-Type: text/plain must be specified.

My investigation until now with postgrest 9.0: It works with...
  1. I have a function soap_endpoint(text) RETURNS text ...
  2. The HTTP request must contain header "Content-Type: text/plain"
  3. The HTTP request must contain header "Accept: text/plain" (otherwise the body seems to get enclosed in double quotes)
  4. My function currently sets PERFORM set_config('response.headers', '[{"content-type": "text/xml; charset=utf-8"}]', true);
  5. If my function returned data type xml, this would fail with Postgres error "Function string_agg(xml, unknown) does not exist".

But it would be nicer to be able to write a function soap_endpoint(xml) RETURNS xml ... and especially not having to deal with the HTTP header stuff.

Suggested changes:
  • To remedy my point 2, I think we would need (analogous to #1927):
    Uploading XML to a function. The function must be defined with a single unnamed xml param and Content-Type: text/xml or application/xml or application/soap+xml must be specified.

  • To remedy my points 3 and 4, I think we would need: If function return type is xml, automatically set response content-type to text/xml (or something like that)

  • To remedy my point 5, I think we would need: Allow returning xml data type, i. e. solve the string_agg issue - perhaps use xmlagg, or only allow scalar xml return values?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the PostgREST 9.0 behavior described with a soap_endpoint(text) function, then compare it with an xml parameter and return type using the listed Content-Type and Accept headers. Trace how function arguments, response headers, and XML aggregation are handled. Done means the intended XML request and response behavior is supported without the current header workarounds, with the xml return case defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
api, backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
22/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.