nusoapservermime server supporting MIME attachments defined at http://www.w3.org/TR/SOAP-attachments. More...
Inheritance diagram for nusoapservermime:
Collaboration diagram for nusoapservermime:Public Member Functions | |
| addAttachment ($data, $filename= '', $contenttype= 'application/octet-stream', $cid=false) | |
| adds a MIME attachment to the current response. | |
| clearAttachments () | |
| clears the MIME attachments for the current response. | |
| getAttachments () | |
| gets the MIME attachments from the current request. | |
| getHTTPBody ($soapmsg) | |
| gets the HTTP body for the current response. | |
| getHTTPContentType () | |
| gets the HTTP content type for the current response. | |
| getHTTPContentTypeCharset () | |
| gets the HTTP content type charset for the current response. | |
| parseRequest ($headers, $data) | |
| processes SOAP message received from client | |
Data Fields | |
| $requestAttachments = array() | |
| $responseAttachments | |
| $mimeContentType | |
nusoapservermime server supporting MIME attachments defined at http://www.w3.org/TR/SOAP-attachments.
It depends on the PEAR Mail_MIME library.
public
Definition at line 268 of file nusoapmime.php.
| nusoapservermime::addAttachment | ( | $ | data, | |
| $ | filename = '', |
|||
| $ | contenttype = 'application/octet-stream', |
|||
| $ | cid = false | |||
| ) |
adds a MIME attachment to the current response.
If the $data parameter contains an empty string, this method will read the contents of the file named by the $filename parameter.
If the $cid parameter is false, this method will generate the cid.
| string | $data The data of the attachment | |
| string | $filename The filename of the attachment (default is empty string) | |
| string | $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) | |
| string | $cid The content-id (cid) of the attachment (default is false) |
Definition at line 302 of file nusoapmime.php.
| nusoapservermime::clearAttachments | ( | ) |
clears the MIME attachments for the current response.
public
Definition at line 322 of file nusoapmime.php.
{
$this->responseAttachments = array();
}
| nusoapservermime::getAttachments | ( | ) |
gets the MIME attachments from the current request.
Each array element in the return is an associative array with keys data, filename, contenttype, cid. These keys correspond to the parameters for addAttachment.
Definition at line 336 of file nusoapmime.php.
{
return $this->requestAttachments;
}
| nusoapservermime::getHTTPBody | ( | $ | soapmsg | ) |
gets the HTTP body for the current response.
| string | $soapmsg The SOAP payload |
Reimplemented from soap_server.
Definition at line 347 of file nusoapmime.php.
References $data, and nusoap_base::debug().
{
if (count($this->responseAttachments) > 0) {
$params['content_type'] = 'multipart/related; type=text/xml';
$mimeMessage =& new Mail_mimePart('', $params);
unset($params);
$params['content_type'] = 'text/xml';
$params['encoding'] = '8bit';
$params['charset'] = $this->soap_defencoding;
$mimeMessage->addSubpart($soapmsg, $params);
foreach ($this->responseAttachments as $att) {
unset($params);
$params['content_type'] = $att['contenttype'];
$params['encoding'] = 'base64';
$params['disposition'] = 'attachment';
$params['dfilename'] = $att['filename'];
$params['cid'] = $att['cid'];
if ($att['data'] == '' && $att['filename'] <> '') {
if ($fd = fopen($att['filename'], 'rb')) {
$data = fread($fd, filesize($att['filename']));
fclose($fd);
} else {
$data = '';
}
$mimeMessage->addSubpart($data, $params);
} else {
$mimeMessage->addSubpart($att['data'], $params);
}
}
$output = $mimeMessage->encode();
$mimeHeaders = $output['headers'];
foreach ($mimeHeaders as $k => $v) {
$this->debug("MIME header $k: $v");
if (strtolower($k) == 'content-type') {
// PHP header() seems to strip leading whitespace starting
// the second line, so force everything to one line
$this->mimeContentType = str_replace("\r\n", " ", $v);
}
}
return $output['body'];
}
return parent::getHTTPBody($soapmsg);
}
Here is the call graph for this function:| nusoapservermime::getHTTPContentType | ( | ) |
gets the HTTP content type for the current response.
Note: getHTTPBody must be called before this.
Reimplemented from soap_server.
Definition at line 406 of file nusoapmime.php.
{
if (count($this->responseAttachments) > 0) {
return $this->mimeContentType;
}
return parent::getHTTPContentType();
}
| nusoapservermime::getHTTPContentTypeCharset | ( | ) |
gets the HTTP content type charset for the current response.
returns false for non-text content types.
Note: getHTTPBody must be called before this.
Reimplemented from soap_server.
Definition at line 422 of file nusoapmime.php.
{
if (count($this->responseAttachments) > 0) {
return false;
}
return parent::getHTTPContentTypeCharset();
}
| nusoapservermime::parseRequest | ( | $ | headers, | |
| $ | data | |||
| ) |
processes SOAP message received from client
| array | $headers The HTTP headers | |
| string | $data unprocessed request data from client |
Reimplemented from soap_server.
Definition at line 437 of file nusoapmime.php.
References $data, soap_server::$headers, nusoap_base::debug(), and nusoap_base::setError().
{
$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
$this->requestAttachments = array();
if (strstr($headers['content-type'], 'multipart/related')) {
$this->debug('Decode multipart/related');
$input = '';
foreach ($headers as $k => $v) {
$input .= "$k: $v\r\n";
}
$params['input'] = $input . "\r\n" . $data;
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$structure = Mail_mimeDecode::decode($params);
foreach ($structure->parts as $part) {
if (!isset($part->disposition)) {
$this->debug('Have root part of type ' . $part->headers['content-type']);
$return = parent::parseRequest($part->headers, $part->body);
} else {
$this->debug('Have an attachment of type ' . $part->headers['content-type']);
$info['data'] = $part->body;
$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
$info['contenttype'] = $part->headers['content-type'];
$info['cid'] = $part->headers['content-id'];
$this->requestAttachments[] = $info;
}
}
if (isset($return)) {
return $return;
}
$this->setError('No root part found in multipart/related content');
return;
}
$this->debug('Not multipart/related');
return parent::parseRequest($headers, $data);
}
Here is the call graph for this function:| nusoapservermime::$mimeContentType |
Definition at line 285 of file nusoapmime.php.
| nusoapservermime::$requestAttachments = array() |
Definition at line 274 of file nusoapmime.php.
| nusoapservermime::$responseAttachments |
Definition at line 280 of file nusoapmime.php.
1.7.1