RPC::XML questions
I've been using XSLT, DOM, and SAX for about a year now to do device independent web sites. I want to start doing some web services. I have Programming Web Services with Perl and it all makes sense so far, but I have a few questions. I figured I'd start with RPC as thats where the book starts. Ive tested and used Apache::XMLRPC::Lite and it works great. I wanted to try Apache::RPC::Server because of the built in documentation system and status gui. I have two questions: question id=1 I put the following right before the part about: #Section 2 main server: Perl use Apache::RPC::Server (); $main::ecgRpc = Apache::RPC::Server-new( path = '/rpc', auto_methods = 1, auto_updates = 1 ); $Location{'/rpc'} = { SetHandler = 'perl-script', PerlHandler = '$main::ecgRpc', }; $Location{'/rpc-status'} = { SetHandler = 'perl-script', PerlHandler = 'Apache::RPC::Status', }; /Perl The server IS running: [trwww@devel_rh trwww]$ perl require RPC::XML; require RPC::XML::Client; $cli = RPC::XML::Client-new('http://localhost/rpc'); $resp = $cli-send_request('system.listMethods'); print( ((ref $resp) ? join(', ', @{$resp-value}) : Error: $resp), \n); Ctrl-D system.identity, system.introspection, system.listMethods, system.methodHelp, system.methodSignature, system.multicall, system.status but when I point my browser at http://localhost/rpc-status, it says that there are 0 servers running? /question question id=2 I also have SOAP::Lite installed, which provided a simple program called RPCXMLsh.pl. I thought I would be able to use it to query my Apache::RPC::Server server because RPC is RPC no matter how it is implemented, but I got: [trwww@devel_rh rpc]$ perl /usr/bin/XMLRPCsh.pl http://localhost/rpc Usage: method[(parameters)] system.listMethods --- SYNTAX ERROR --- Unexpected Content-Type '' returned Ctrl-D I took a look at Apache/RPC/Server.pm and I think I understand why this dosent work. The code for the handler checks that an incoming http header called content-type is set to 'text/xml' But I couldnt find methods in XMLRPC::Lite or SOAP::Lite to add/modify httpd headers? /question Thank you, Todd W.
Re: Apache::Session and user sessions
It's just a storage mechanism. Typically the procedure is that one a user identified herself with some kind of login process, you put her user ID (a primary key to a database table) into the session, and keep it as a key for accessing that data. I have a table with some basic user information (first name, last name, address, phone number, etc...). That's permanent data, not session data. Session data is transient. Okay... That makes sense What i did was created the two columns, and hoped it would work without the id column being the primary key. It won't. All of the Apache::Session data is in a blob in the a_session column. It has no access to the other columns. Thats what I was looking for. I ran through the code with ptkdb but since I wasnt using it right, it never did a lookup anyway. So now Trying to decide what to do, in a perlHeaderParserHandler Ill just get an id from Sys::UniqueID, send it to the browser each request in a cookie or whatever, then use DBI::Tie to reinstate the session for each request. (Thinking about it, that sounds easier than Apache::Session anyways) Isn't your user table referenced by a user ID? Yeah. I said that in the OP but you snipped it. You have to connect the user ID to a browser somewhere. The normal way to do this is give the browser an ID (the session ID) and then store the relationship with Apache::Session. If you have no other transient data besides the user ID, you can skip Apache::Session and just send a user ID cookie. Make sure you have security in place to prevent people from simply entering another user ID in their cookie and gaining access to another person's information. Yeah, Ill relate the users id and a session id when she logs in. Writing Apache Modules in Perl and C has some good suggestions about securing the cookie. This all makes good sense after you distinguished the difference between session data and permanent data for me. By the way Tie::DBI is slow. Writing some kind of module for accessing your specific user table would be faster. Okay. Thanks for all your insight. Todd W. _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx
Apache::Session and user sessions
Im looking at Apache::Session and trying to figure out what it does. What I want to do is tie sessions to a particular record in a database table. From what I can tell, Apache::Session will only give generic sessions, of which I know nothing about the user untill they give me information during that particular session. I have a table with some basic user information (first name, last name, address, phone number, etc...). Apache::Session says I have to have a column named id and one called a_session. It says that the id column must be primary key, but my table already has a primary key, an auto-increment column for the userid. What i did was created the two columns, and hoped it would work without the id column being the primary key. I stuck a 32 character string I got from Sys::UniqueID in the id column and tried to do: ... my($dbh) = DBI-connect( MISANet::Util::DatabaseOpts::getOpts() ); my($id) = '3D898BE8C0A80125229B0001'; my(%hash); tie %hash, 'Apache::Session::MySQL', $id, { Handle = $dbh, LockHandle = $dbh }; $r-content_type('text/html'); $r-send_http_header(); $r-print( htmlheadtitleDummy/title/headbodydivHello, $hash{firstName} $hash{lastname}/div/body/html ); ... in a perlHandler where firstName and lastName are columns in the database. %hash never gets defined and $! dosent report anything. So now Trying to decide what to do, in a perlHeaderParserHandler Ill just get an id from Sys::UniqueID, send it to the browser each request in a cookie or whatever, then use DBI::Tie to reinstate the session for each request. (Thinking about it, that sounds easier than Apache::Session anyways) What do you guys think? Am I using Apache::Session wrong, or are there better alternatives than what Ive came up with? Thanks in advance for the input. Todd W. _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx