Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Howdy,

I've worked a lot with Frontier::Daemon, so I'll try to answer your question. I confess that the way you phrased your question confuses me, so let me try to rephrase it.

Frontier::Deamon is weird. I'm supposed to pass the constructor a hash reference whose keys are those of the XML-RPC Web Service API that I'm trying to implement and whose values are subroutine references. When XML-RPC clients talk to this bad boy, how are parameters passed to my subroutines?

If this is your question, it's a good one. Frontier::Daemon is a subclass of HTTP::Daemon, which is another class whose new() method doesn't return. When a client connects to a Frontier::Daemon object, the request XML is parsed into a perl string. This string is then eval()'ed. The code that does this is in Frontier::RPC2::serve() and looks like this:

eval { $result = &{ $methods->{$method} }(@{ $call->{'value'} })};

Here, $method is the API name of the requested method and $call->{'value'} is an array reference that has the parameters to be passed to the "method." Method is an inaccurate term here: this isn't an object method call happening here at all. The $methods hash reference is the hash you passed in at Frontier::Daemon object instantiation. This may look a little weird if you're not up on references, but it's really using a code reference to invoke a subroutine. What's even stranger, perhaps, is that you could rewrite that line as:

eval{ $methods->{$method}->( @{ $call->{values} } ) };

This, to me, makes it look even more like a method call. Of course, it's not really.

Now, this may not have been your question.

Is your question more along the lines of:

I've got an HTML form, some of whose values I want to pass to my Frontier::Daemon object. What kind of form handler do I need to do this?

A common problem with the name "Web Service" is that it seems to imply CGI to folks. That's not right (apologies to Kevin Meanie). The "web" in Web Services refers to the fact that both web pages and "Web Services" travel across the wire speaking HTTP.

To get HTML form values to be processed by your Web Service, you'll need to create a form handler in the language of your choice (Perl) which unpacks the CGI parameters, packs up the relevant values into an XML-RPC request, make the request, extract the response, the paint a new HTML page which does something with the answer. I wrote a few articles about XML-RPC and SOAP for IBM's developerWorks site (under 'web services'), so have a look there for copious details.

Finally, if your question is:

Man, Frontier::Daemon is really F'ed up! I want my module to screw with users' heads just like that! Where do I begin?

To this, I can only say: Screw up your courage and dive into the source. For bonus points, do look at DBI.pm and Tk.pm. There be dragons...

Good luck.


In reply to Re: 'new' constructors by jjohn
in thread 'new' constructors by emcb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-04-18 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found