|
Support Incident Tracker GIT4.x
|
Inheritance diagram for nusoap_client_mime:
Collaboration diagram for nusoap_client_mime:Public Member Functions | |
| addAttachment ($data, $filename= '', $contenttype= 'application/octet-stream', $cid=false) | |
| clearAttachments () | |
| getAttachments () | |
| getHTTPBody ($soapmsg) | |
| getHTTPContentType () | |
| getHTTPContentTypeCharset () | |
| parseResponse ($headers, $data) | |
Data Fields | |
| $requestAttachments = array() | |
| $responseAttachments | |
| $mimeContentType | |
nusoap_client_mime client supporting MIME attachments defined at http://www.w3.org/TR/SOAP-attachments. It depends on the PEAR Mail_MIME library.
public
Definition at line 54 of file nusoapmime.php.
| addAttachment | ( | $ | data, |
| $ | filename = '', |
||
| $ | contenttype = 'application/octet-stream', |
||
| $ | cid = false |
||
| ) |
adds a MIME attachment to the current request.
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 88 of file nusoapmime.php.
| clearAttachments | ( | ) |
clears the MIME attachments for the current request.
public
Definition at line 108 of file nusoapmime.php.
{
$this->requestAttachments = array();
}
| getAttachments | ( | ) |
gets the MIME attachments from the current response.
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 122 of file nusoapmime.php.
{
return $this->responseAttachments;
}
| getHTTPBody | ( | $ | soapmsg | ) |
gets the HTTP body for the current request.
| string | $soapmsg | The SOAP payload |
Reimplemented from nusoap_client.
Definition at line 133 of file nusoapmime.php.
References $data, $output, count, and nusoap_base::debug().
{
if (count($this->requestAttachments) > 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->requestAttachments 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);
}
| getHTTPContentType | ( | ) |
gets the HTTP content type for the current request.
Note: getHTTPBody must be called before this.
Reimplemented from nusoap_client.
Definition at line 192 of file nusoapmime.php.
References count.
{
if (count($this->requestAttachments) > 0) {
return $this->mimeContentType;
}
return parent::getHTTPContentType();
}
| getHTTPContentTypeCharset | ( | ) |
gets the HTTP content type charset for the current request. returns false for non-text content types.
Note: getHTTPBody must be called before this.
Reimplemented from nusoap_client.
Definition at line 208 of file nusoapmime.php.
References count.
{
if (count($this->requestAttachments) > 0) {
return false;
}
return parent::getHTTPContentTypeCharset();
}
| parseResponse | ( | $ | headers, |
| $ | data | ||
| ) |
processes SOAP message returned from server
| array | $headers | The HTTP headers |
| string | $data | unprocessed response data from server |
Reimplemented from nusoap_client.
Definition at line 223 of file nusoapmime.php.
References $data, $return, nusoap_base::debug(), and nusoap_base::setError().
{
$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
$this->responseAttachments = 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) && (strstr($part->headers['content-type'], 'text/xml'))) {
$this->debug('Have root part of type ' . $part->headers['content-type']);
$root = $part->body;
$return = parent::parseResponse($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->responseAttachments[] = $info;
}
}
if (isset($return)) {
$this->responseData = $root;
return $return;
}
$this->setError('No root part found in multipart/related content');
return '';
}
$this->debug('Not multipart/related');
return parent::parseResponse($headers, $data);
}
| $mimeContentType |
Definition at line 71 of file nusoapmime.php.
| $requestAttachments = array() |
Definition at line 60 of file nusoapmime.php.
| $responseAttachments |
Definition at line 66 of file nusoapmime.php.