Esempio n. 1
0
 /**
  * processes SOAP message returned from server
  *
  * @param	array	$headers	The HTTP headers
  * @param	string	$data		unprocessed response data from server
  * @return	mixed	value of the message, decoded into a PHP type
  * @access   private
  */
 function parseResponse($headers, $data)
 {
     $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)) {
                 $this->debug('Have root part of type ' . $part->headers['content-type']);
                 $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)) {
             return $return;
         }
         $this->setError('No root part found in multipart/related content');
         return;
     }
     $this->debug('Not multipart/related');
     return parent::parseResponse($headers, $data);
 }
 /**
  * 函数功能:原创调用适配
  */
 function remoteInvoke($service, $parameter)
 {
     // 合成XML
     $xdoc = new CreateXML($this->encoding);
     $xdoc->createRoot($service, $this->version);
     foreach ($parameter as $key => $val) {
         $xdoc->addNode($key, $val['type'], $val['value']);
     }
     // 加密 签名
     $xstr = $xdoc->getString();
     // echo "xstr: $xstr";
     $req_sign = strtoupper(md5($xstr . $this->md5key));
     $req_code = base64_encode($xstr);
     // 远程调用
     //生成SOAP调用是的参数
     $param = array('service' => $service, 'merchant' => $this->merchantid, 'encoding' => $this->encoding, 'type' => $this->type, 'code' => $req_code, 'sign' => $req_sign);
     // print_r($param);
     //调用网银提供的soap方法
     $soap_client = new soapclientw($this->soap_url, true);
     $rs = $soap_client->call($this->soap_method, $param);
     //echo "-----------------------------<br/>\n";
     //print_a('rs', $rs);
     // 处理返回值
     $rtcode = $rs['string'][0];
     $rtmsg = base64_decode($rs['string'][1]);
     //echo "code: $rtmsg<br\>\n";
     if (strtoupper(md5($rtmsg . $this->md5key)) == $rs['string'][2]) {
         echo "return sign OK! <br>\n";
         // 解码
         echo $rtmsg;
         return xml2array($rtmsg);
     } else {
         echo "Chinabank Soap SIGN ERR! <br>\n";
         return array('sname' => $service, 'result' => $this->MOTO_CLIENT_AUTH, 'error' => $this->MOTO_CLIENT_AUTH, '_error' => 'SING ERR');
     }
 }