in reply to Re^3: start over with SOAP in Perl?
in thread start over with SOAP in Perl?

You have to write a library to parse the response and generate the correct request, not for the underlying HTTP(S) protocol.

For your example, I have to parse "Error: Username/password invalid" into something, anything. The simplest way to handle this in soap is to throw a fault and do something like $response->get_fault->get_error_message.

Replies are listed 'Best First'.
Re^5: start over with SOAP in Perl?
by hardburn (Abbot) on Aug 31, 2006 at 19:33 UTC

    My point was that LWP::UserAgent has already written that code for you, if you design the server end to properly take advantage of what HTTP already has to offer. LWP::UserAgent already knows how to parse '401 Unauthorized'.

    You can still choose to write some additional error handling code, but your overall code will be simpler. More complicated things will need more complicated code, no matter if you use SOAP or REST, so no loss there.

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      Not true. You cannot use HTTP error codes for everything. What if you were to use a service where you needed to retieve a record. In SOAP, you don't have to parse the response content manually. It'd be returned back to you as your toolkit provides for you, either as a hash, an object or /something/.

      In REST, i have to put the effort in to take the format and use something on it, whether it's a comma delimited parsing module, an xml parsing module or something custom.

      Look at the perlmonks XML services. If it were in SOAP, I wouldn't need to run an XML parser on them. All of my data would automagically, by the toolkit, be passed back as a hash or set of objects.. or set of arrays. Less to think about.

        I can use HTTP error codes for user/pass authentication, but plenty of web apps out there don't. That's what REST is--make full use of HTTP where it already has that functionality. Use custom code for everything else.

        "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.