需要Perl SOAP :: Transport :: HTTP :: CGI健全性检查

时间:2014-02-03 19:08:43

标签: web-services perl soap

好吧,我认为没有简单(做那种懒惰)的方式来做我想要的但是给出了我想要做的Perl SOAP :: Transport :: HTTP :: CGI代码片段拦截所有SOAP操作传递通过服务并记录操作或故障的结果......

    SOAP::Transport::HTTP::CGI
        -> dispatch_to(
            #first arg needs to be the directory holding the PackageName.pm modules with no trailing "/". The args aftre the first are name of SPECIFIC packages to be loaded as needed by SOAP requests
            #Failure to call out specific moudules below will allow the external SOAP modules to be loaded, but the overall module @INC path for other Perl modules will be blocked for security reasons
            SOAP_MODULE_INCULDE, #name of the directory holding the PackageName.pm modules with no trailing "/"
            "TechnicalMetaDataExtraction", #prod - wrapper for EXIFTool
            "Ingest", #module (package) name
            "ImageManipulation", #module (package) name
            "FacebookBroadcast", #unfinished
            "CompressDecompress", #unfinished
            "ImageOCR", #prod - tesseract
            "HandleDotNet", #prod
            "Pipeline", #prod (needs work)
            "TwitterBroadcast", #prototype
            "Messaging", #prototype but text format email works
            "Property", #development
            "FileManager", #prototype
            "PassThrough" #prod - module to do location conversion (URL -> Fedora Obj+DS, Fedora Obj+DS -> file, URL -> InlineBase64, etc.) but format conversion
        ) #done with the dispacth_to section
        -> on_action(sub {
            #on_action method lets you specify SOAPAction understanding. It acceptsreference to subroutine that takes three parameters: SOAPAction, method_uri and method_name.
            #'SOAPAction' is taken from HTTP header and method_uri and method_name are extracted from request's body. Default behavior is match 'SOAPAction' if present and ignore it otherwise.
            #die SOAP::Data->type('string')->name('debug')->value("Intercepted call, SOAP request='".shift(@_)."'");

            if($Debug) {
                #@_ notes:
                #[0] - "http://www.example.org/PassThrough/NewOperation"
                #[1] - http://www.example.org/PassThrough/
                #[2] - NewOperation
                #[3] - "undefined"
                my %DataHash=(
                    message => @_[0]
                );

                #SendMessageToAMQTopic(localtime()." - ".@_[0]);
                SendDebugMessage(\%DataHash, "info");
            } #there's only one element passed at this level
        }) #end on_action
        #-> on_debug() #not valid for SOAP::Transport::HTTP::CGI
        #-> request() #valid, but does not fire - request method gives you access to HTTP::Request object which you can provide for Server component to handle request.
        #-> response() #does not fire - response method gives you access to HTTP::Response object which you can access to get results from Server component after request was handled.
        #-> options({compress_threshold => 10000}) #causes problems for the JavaScript soap client - removed for the moment
        -> handle() #fires but ignores content in sub - handle method will handle your request. You should provide parameters with request() method, call handle() and get it back with response().
    ;

最初我以为我可以从“on_action”方法获取我需要的信息,但是它只包含SOAP调用的目标(在它发送之前?)并且我正在寻找操作结果中的数据被发送回SOAP客户端。 “SOAP :: Transport :: HTTP :: CGI”的文档有点薄,在线的例子很少。

任何人都知道这是否可行给出上面代码的设置?如果没有,那么唯一的另一个选择是改变我的SOAP服务代码模块的每个方法以包含“SendDebugMessage”函数。

1 个答案:

答案 0 :(得分:0)

我建议继承SOAP::Transport::HTTP::CGI并挂钩handle()方法。一个未经测试的,可能是非工作的例子是:

package MySoapCGI;
use Data::Dumper;
use SOAP::Transport::HTTP;
use base 'SOAP::Transport::HTTP::CGI';

sub handle {
    my $self = shift;
    $self->SUPER::handle(@_);
    warn Dumper($self->request);
    warn Dumper($self->response);
}

将转储器替换为您想要的任何日志记录。您可能需要进行一些XML解析,因为这些将是原始的HTTP::RequestHTTP::Response