dcherng has asked for the wisdom of the Perl Monks concerning the following question:

We have WSDL SOAP API application. A Java client via SOAP can upload a file by using MTOM. Can Perl module support MTOM in SOPA::Lite? Thanks.
  • Comment on Any perl module support MTOM in SOAP::Lite?

Replies are listed 'Best First'.
Re: Any perl module support MTOM in SOAP::Lite?
by tokpela (Chaplain) on Aug 14, 2009 at 22:21 UTC

    This was quite a while ago and I don't remember the details.

    But here is a basic script that you can start with...

    Warning: this code is adapted and untested.

    use strict; use warnings; use SOAP::Lite +trace => "all"; use MIME::Base64 qw(encode_base64); $ENV{HTTPS_DEBUG} = 1; $ENV{HTTPS_VERSION} = '3'; $ENV{HTTPS_CERT_FILE} = 'C:/path/to/certificate.pem'; my $input_filename = "test.pdf"; my $input_filepath = "C:/path/$input_filename"; my $namespace = "http://host/path"; my $method_name = "MethodName"; my $soap_action = "http://host/path/soap_action"; my $end_point = "https://host/path/endpoint"; my $encoded_file = ''; my $buffer = ''; my $file_content = ''; if (open(my $ifh, $input_filepath)) { binmode($ifh); $file_content = do { local $/; <$ifh> }; close($ifh); } else { die "[Error] Could not open file - $input_filepath - $!"; } $encoded_file = encode_base64($file_content); my $file_size = -s $input_filepath; my $soap = SOAP::Lite -> uri($soap_action) -> on_action( sub { join '/', $namespace, $_ +[1] } ) -> proxy($end_point); my $method = SOAP::Data->name($method_name) ->attr( { xmlns => $namespace }); my @params = ( SOAP::Data->name("request" => \SO +AP::Data->value( SOAP::Data->name("FileName" => $in +put_filename)->type("string"), SOAP::Data->name("Filesize" => $fi +le_size)->type("int"), SOAP::Data->name("Data" => $en +coded_file)->type("base64Binary") )), ); print $soap->call($method => @params)->result;

        Thanks for the link, Anonymous!

        Yeah, as I said it's been quite a few years and I remember trying to get DIME and MTOM support working in SOAP::Lite and my head spinning.

        I forgot about the MIME conversion and sending as an attachment which we never ended up doing.

        For anyone coming to this post in the future, here is a good example showing the difference between my original post example and an actual MTOM message.