Yeah it isn't well documented, I've created a few REST APIs in the
past couple weeks and it works quite well with SimpleXMLElement.  I
just wish SXE threw exceptions instead of errors...

jbw

On 10/20/07, drmikecrowe <[EMAIL PROTECTED]> wrote:
>
> Joby,
>
> Thanks so much for this tip.  I had been struggling with how to do
> this, and it came right when I needed it.
>
> FWIW, I'm rewriting a RoR app in Symfony, and RoR has this interesting
> feature that it will pre-parse the XML in the POST area and provide to
> the application.  A Symphony version would be:
>
>     $stream = fopen("php://input", "r");
>     $data = stream_get_contents($stream);
>     fclose($stream);
>     $data = preg_replace('/^[^<]*</', '<', $data);
>     $data = preg_replace('/>[^>]*$/', '>', $data);
>     $xml = SimpleXMLElement($data);
>
> (with appropriate error catching).  Not sure if this should be a
> default behavior, but it is kinda cool.
>
> Mike
>
> On Oct 19, 2:59 pm, "Joby Walker" <[EMAIL PROTECTED]> wrote:
> > Doing the same thing.  The data is in 'php://input'.  So:
> >
> >         $stream = fopen("php://input", "r");
> >         $data = stream_get_contents($stream);
> >         fclose($stream);
> >
> > I've found it best to clean up the content before processing by
> > SimpleXML to eliminate any unwanted content outside the XML document:
> >
> > public static function trimRawBody($data)
> > {
> >         $data = preg_replace('/^[^<]*</', '<', $data);
> >         $data = preg_replace('/>[^>]*$/', '>', $data);
> >         return $data;
> >
> > }
> >
> > jbw
> >
> > On 10/19/07, Rune Sørensen <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Hi.
> >
> > > Having read the documentation and browsed the source of the sfRequest and
> > > sfWebRequest classes I can't detect any obvious way of extracting the 
> > > entire
> > > Message Body of an HTTP request.
> >
> > > The obligatory "parameter methods" for handling tradional web forms etc 
> > > are
> > > of course present. But how do you access the raw Message body as specified
> > > by w3 (
> > >http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3).
> >
> > > Working on an REST based XML API frontend to my business logic, getting 
> > > the
> > > entire message body of PUT and POST HTTP requests is necessary. In such 
> > > APIs
> > > the message body consists of complete XML documents, as I see it is is not
> > > good practice to "hide" the XML in a POST-like parameters foo=bar, where 
> > > bar
> > > is the xml document. Anyone else got experience deplyoing RESTful XML
> > > services with symfony?
> >
> > > I've only used symfoy for a couple of weeks, and maybe I've missed 
> > > something
> > > here... All help is appreciated.
> >
> > > Regards
> >
> > > Rune Sørensen
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to