Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69926 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94757 invoked from network); 29 Oct 2013 08:45:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Oct 2013 08:45:20 -0000 Received: from [127.0.0.1] ([127.0.0.1:17430]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id FF/41-21587-0A57F625 for ; Tue, 29 Oct 2013 03:45:20 -0500 Authentication-Results: pb1.pair.com smtp.mail=karasek.krzysztof@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=karasek.krzysztof@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.173 as permitted sender) X-PHP-List-Original-Sender: karasek.krzysztof@gmail.com X-Host-Fingerprint: 209.85.192.173 mail-pd0-f173.google.com Received: from [209.85.192.173] ([209.85.192.173:55285] helo=mail-pd0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/B0-21587-B227F625 for ; Tue, 29 Oct 2013 03:30:35 -0500 Received: by mail-pd0-f173.google.com with SMTP id r10so8235054pdi.18 for ; Tue, 29 Oct 2013 01:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=owoeURCDbm+eJQZa/jwPPvnKqLAbTtesS3+yp8RLNic=; b=jg8ILWvpAY7fpZNE1QcZl8dCukxRmiHeeVj5fziAdCsP4SxlIVafXOpEe2X8aAeiV2 kHRefsO2ussyIA1kYhYHznPP5WSMiiQaXqyPUeQyXfN6r61NbudRLPk5uMrIsOrkevn5 v/rGDp+Ywq+fGKNpz/qbRGws2CCcjguNAPhASjpiM+V55GBkE9mZMgswh8QG1RupcQlb tB4GG880a9zuRE7CCawWacHNHvnp6lUquaV3QxXVo+qTkUJJamQs2rFYb4u7OMYm6xRD MGtH/kmmkz7X/m1OYeEt5mFf7ZnW9UOkleSK9azAPSpMRPpI+HkVA3ToaBgHCGQ4cSAx aPOw== MIME-Version: 1.0 X-Received: by 10.68.17.132 with SMTP id o4mr25531185pbd.44.1383035428414; Tue, 29 Oct 2013 01:30:28 -0700 (PDT) Received: by 10.68.75.229 with HTTP; Tue, 29 Oct 2013 01:30:28 -0700 (PDT) Date: Tue, 29 Oct 2013 09:30:28 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=bcaec52160d76c2aac04e9dd0797 Subject: Enchancement in SoapServer::handle method From: karasek.krzysztof@gmail.com (krzysztof karasek) --bcaec52160d76c2aac04e9dd0797 Content-Type: text/plain; charset=ISO-8859-1 Hi there, I'm not member of the PHP community, but ... I have a proposal to add one new optional boolean paramter for SoapServer::handle method. to allow control whether result is sent directly to output (true) or to string (false). Default value should be always true for backward compatibility. This small change will allow to enchance SoapServer implementation and add support for attachements. I tested it with PHP 5.3, 5.4 and it works great for me. Now I use it in all my PHP compilations. Below you'll find required code changes in hadle method and sample class that implements Soap response with attacheemnt (both MTOM and SWA) Cheers, Krzysztof C code change is very simple: zend_bool output = 1; .... if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &arg, &arg_len, &output) == FAILURE) { return; } .... /* Flush buffer */ php_end_ob_buffer(0, 0 TSRMLS_CC); if (doc_return) { /* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */ xmlDocDumpMemory(doc_return, &buf, &size); if (size == 0) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Dump memory failed"); } if(output){ ..... standard output handling } else { RETURN_STRINGL((char*)buf, size, 1); xmlFreeDoc(doc_return); xmlFree(buf); } } else { sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1); sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1); } ************************************************ class SWASOAPServer extends SoapServer { var $_executor = null; function echoSWAHeader($id){ header("MIME-Version: 1.0"); header("Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml; start=<$id>"); header("Content-Description: PHP Soap Server Response SWA."); } function echoMTOMHeader($id){ header("MIME-Version: 1.0"); header("Content-Type: Multipart/Related; boundary=MIME_boundary; type=\"application/xop+xml\"; start=\"<$id>\"; start-info=\"text/xml\"; charset=UTF-8"); header("Content-Description: PHP Soap Server Response MTOM."); } function echoMTOMSoap($soap, $id){ $this->echoMimeContent($soap, "application/xop+xml; charset=UTF-8; type=\"text/xml\";", "binary", $id); } function echoSWASoap($soap, $id){ $this->echoMimeContent($soap, "text/xml; charset=UTF-8", "8bit", $id); } function echoMimeContent($content, $mime, $encoding, $id){ echo "--MIME_boundary\n"; echo "Content-Type: $mime\n"; echo "Content-Transfer-Encoding: $encoding\n"; echo "Content-ID: <$id>\n\n"; echo $content; echo "\n\r"; } function echoMimeEnd(){ echo "--MIME_boundary--\n"; } function handle($input,$toOutput = false){ global $config; $result = parent::handle($input, $toOutput); if($this->_executor->attachements !=null){ if(strcmp($config['attachement_type'],'mtom')==0){ $id = '0.'.microtime(true); $this->echoMTOMHeader($id); $this->echoMTOMSoap($result, $id); } else { $id = '0.'.microtime(true); $this->echoSWAHeader($id); $this->echoSWASoap($result, $id); } foreach($this->_executor->attachements as $id => $attachement){ $this->echoMimeContent($attachement, $this->_executor->attachements_ctt[$id], 'binary', $id); } $this->echoMimeEnd(); } else { /*if ($soap_version == SOAP_1_2) { //header("Content-Type: application/soap+xml; charset=utf-8"); } else {*/ header("Content-Type: text/xml; charset=utf-8"); /*}*/ echo $result; } } function setExecutor($executor){ $this->_executor = $executor; } } --bcaec52160d76c2aac04e9dd0797--