{
    "mode": "perldoc",
    "parameter": "SOAP::Packager",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/SOAP%3A%3APackager/json",
    "generated": "2026-06-11T05:21:43Z",
    "sections": {
        "NAME": {
            "content": "SOAP::Packager - this class is an abstract class which allows for multiple types of packaging\nagents such as MIME and DIME.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The SOAP::Packager class is responsible for managing a set of \"parts.\" Parts are additional\npieces of information, additional documents, or virtually anything that needs to be associated\nwith the SOAP Envelope/payload. The packager then will take these parts and encode/decode or\n\"package\"/\"unpackage\" them as they come and go over the wire.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new Instantiates a new instance of a SOAP::Packager.\n\nparts\nContains an array of parts. The contents of this array and their types are completely\ndependent upon the Packager being used. For example, when using MIME, the content of this\narray is MIME::Entity's.\n\npushpart\nAdds a part to set of parts managed by the current instance of SOAP::Packager.\n\nparser\nReturns the parser used to parse attachments out of a data stream.\n\nheadershttp\nThis is a hook into the HTTP layer. It provides a way for a packager to add and/or modify\nHTTP headers in a request/response. For example, most packaging layers will need to override\nthe Content-Type (e.g. multipart/related, or application/dime).\n",
            "subsections": []
        },
        "ABSTRACT METHODS": {
            "content": "If you wish to implement your own SOAP::Packager, then the methods below must be implemented by\nyou according to the prescribed input and output requirements.\n",
            "subsections": [
                {
                    "name": "package",
                    "content": "The \"package\" subroutine takes as input the SOAP envelope in string/SCALAR form. This will\nserve as the content of the root part. The packager then encapsulates the envelope with the\nparts contained within \"parts\" and returns the properly encapsulated envelope in\nstring/SCALAR form.\n"
                },
                {
                    "name": "unpackage",
                    "content": "The \"unpackage\" subroutines takes as input raw data that needs to be parsed into a set of\nparts. It is responsible for extracting the envelope from the input, and populating \"parts\"\nwith an ARRAY of parts extracted from the input. It then returns the SOAP Envelope in\nstring/SCALAR form so that SOAP::Lite can parse it.\n"
                }
            ]
        },
        "SUPPORTED PACKAGING FORMATS": {
            "content": "SOAP::Packager::MIME\n\"SOAP::Packager::MIME\" utilizes MIME::Tools to provides the ability to send and receive\nMultipart/Related and Multipart/Form-Data formatted requests and responses.\n\nMIME METHODS\nThe following methods are used when composing a MIME formatted message.\n\ntransferencoding\nThe value of the root part's Content-Transfer-Encoding MIME Header. Default is: 8bit.\n\nenvid\nThe value of the root part's Content-Id MIME Header. Default is: <mainenvelope>.\n\nenvlocation\nThe value of the root part's Content-Location MIME Header. Default is: /mainenvelope.\n\nenvtype\nThe value of the root part's Content-Type MIME Header. Default is: text/xml.\n\nOPTIMIZING THE MIME PARSER\nThe use of attachments can often result in a heavy drain on system resources depending upon how\nyour MIME parser is configured. For example, you can instruct the parser to store attachments in\nmemory, or to use temp files. Using one of the other can affect performance, disk utilization,\nand/or reliability. Therefore you should consult the following URL for optimization techniques\nand trade-offs:\n\nhttp://search.cpan.org/dist/MIME-tools/lib/MIME/Parser.pm#OPTIMIZINGYOURPARSER\n\nTo modify the parser's configuration options consult the following code sample, which\nincidentally shows how to minimize memory utilization:\n\nmy $packager = SOAP::Packager::MIME->new;\n# $packager->parser->decodeheaders(1); # no difference\n# $packager->parser->extractnestedmessages(1); # no difference\n$packager->parser->outputtocore(0); # much less memory\n$packager->parser->tmptocore(0); # much less memory\n$packager->parser->tmprecycling(0); # promotes faster garbage collection\n$packager->parser->useinnerfiles(1); # no difference\nmy $client = SOAP::Lite->uri($NS)->proxy($URL)->packager($packager);\n$client->someMethod();\n\nCLIENT SIDE EXAMPLE\nThe following code sample shows how to use attachments within the context of a SOAP::Lite\nclient.\n\n#!/usr/bin/perl\nuse SOAP::Lite;\nuse MIME::Entity;\nmy $ent = build MIME::Entity\nType        => \"text/plain\",\nPath        => \"attachment.txt\",\nFilename    => \"attachment.txt\",\nDisposition => \"attachment\";\nmy $NS = \"urn:Majordojo:TemperatureService\";\nmy $HOST = \"http://localhost/cgi-bin/soaplite.cgi\";\nmy $client = SOAP::Lite\n->packager(SOAP::Packager::MIME->new)\n->parts([ $ent ])\n->uri($NS)\n->proxy($HOST);\nmy $response = $client->c2f(SOAP::Data->name(\"temperature\" => '100'));\nprint $response->valueof('//c2fResponse/foo');\n\nSERVER SIDE EXAMPLE\nThe following code shows how to use attachments within the context of a CGI script. It shows how\nto read incoming attachments, and to return attachments to the client.\n\n#!/usr/bin/perl -w\nuse SOAP::Transport::HTTP;\nuse MIME::Entity;\nSOAP::Transport::HTTP::CGI\n->packager(SOAP::Packager::MIME->new)\n->dispatchwith({'urn:Majordojo:TemperatureService' => 'TemperatureService'})\n->handle;\n\nBEGIN {\npackage TemperatureService;\nuse vars qw(@ISA);\n@ISA = qw(Exporter SOAP::Server::Parameters);\nuse SOAP::Lite;\nsub c2f {\nmy $self = shift;\nmy $envelope = pop;\nmy $temp = $envelope->dataof(\"//c2f/temperature\");\nuse MIME::Entity;\nmy $ent = build MIME::Entity\nType        => \"text/plain\",\nPath        => \"printenv\",\nFilename    => \"printenv\",\nDisposition => \"attachment\";\n# read attachments\nforeach my $part (@{$envelope->parts}) {\nprint STDERR \"soaplite.cgi: attachment found! (\".ref($part).\")\\n\";\nprint STDERR \"soaplite.cgi: contents => \".$part->stringify.\"\\n\";\n}\n# send attachments\nreturn SOAP::Data->name('convertedTemp' => (((9/5)*($temp->value)) + 32)),\n$ent;\n}\n}\n\nSOAP::Packager::DIME\nTODO\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "MIME::Tools, DIME::Tools\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 2000-2004 Paul Kulchenko. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Byrne Reese (byrne@majordojo.com)\n",
            "subsections": []
        }
    },
    "summary": "SOAP::Packager - this class is an abstract class which allows for multiple types of packaging agents such as MIME and DIME.",
    "flags": [],
    "examples": [],
    "see_also": []
}