本文整理汇总了PHP中xmlrpcmsg类的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpcmsg类的具体用法?PHP xmlrpcmsg怎么用?PHP xmlrpcmsg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpcmsg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSocketConnect
public function getSocketConnect()
{
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$is_sesson = $this->checkConfigurationChange();
if (!$is_sesson || !is_int($userId)) {
$sock = $this->getSocket();
$msg = new xmlrpcmsg('login');
$msg->addParam(new xmlrpcval(self::$odoo_db, "string"));
$msg->addParam(new xmlrpcval(self::$odoo_user, "string"));
$msg->addParam(new xmlrpcval(self::$odoo_pwd, "string"));
$resp = $sock->send($msg);
if ($resp->faultCode()) {
$userId = $resp->faultString();
} else {
$val = $resp->value();
$id = $val->scalarval();
if ($id > 0) {
$userId = $id;
} else {
$userId = 'Invalid Odoo Login Details.';
}
}
Mage::getSingleton('adminhtml/session')->setUserId($userId);
}
}
示例2: xmlrpcCall
function xmlrpcCall($url, $method, $params)
{
// xmlrpc encode parameters
for ($i = 0; $i < count($params); $i++) {
if (get_class($params[$i]) != 'xmlrpcval') {
$params[$i] = xmlrpc_encode($params[$i]);
}
}
// send request
$message = new xmlrpcmsg($method, $params);
debug("XML-RPC message", $message->serialize());
$addr = parse_url($url);
$client = new xmlrpc_client($url, $addr['host'], $addr['port']);
//if($debug)
// $client->setDebug(1);
debug("XML-RPC", "call to " . $url);
$response = $client->send($message);
// process response
debug("XML-RPC Response", $response->serialize());
if (!$response) {
debug("No response", "probably host is unreachable");
} elseif ($response->faultCode() != 0) {
// there was an error
debug("Error response: ", $response->faultCode() . " " . $response->faultString());
} else {
$retval = $response->value();
if ($retval) {
$retval = xmlrpc_decode($retval);
}
debug("Response", $retval);
return $retval;
}
return NULL;
}
示例3: __createXmlRpcMsg
function __createXmlRpcMsg($server_method, $params_arr)
{
$xml_val = my_xmlrpc_encode($params_arr);
$xml_msg = new xmlrpcmsg($server_method);
$xml_msg->addParam($xml_val);
return $xml_msg;
}
示例4: gFaultXmlRequest
function gFaultXmlRequest($faultCode, $faultString)
{
global $stylevar;
$faultMethod = 'return_fault';
$xml = new xmlrpcmsg($faultMethod);
$xml->addParam($faultCode);
$xml->addParam($faultString);
$rxml = $xml->serialize($stylevar['charset']);
return $rxml;
}
示例5: syncStoreAtOdoo
public function syncStoreAtOdoo($store_data)
{
$response = 0;
$auto_warehouse_generation = Mage::getStoreConfig('magerpsync/mobmultishop/auto_warehouse_generation');
$auto_pricelist_generation = Mage::getStoreConfig('magerpsync/mobmultishop/auto_pricelist_generation');
$store_data['auto_warehouse'] = $auto_warehouse_generation;
$store_data['auto_pricelist'] = $auto_pricelist_generation;
$store_array = php_xmlrpc_encode($store_data);
$helper = Mage::helper('magerpsync/connection');
$context = $helper->getOdooContext();
$client = $helper->getClientConnect();
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg->addParam(new xmlrpcval("magento.store.view", "string"));
$msg->addParam(new xmlrpcval("sync_store_view", "string"));
$msg->addParam($store_array);
$msg->addParam(new xmlrpcval($context, "struct"));
$resp = $client->send($msg);
if ($resp->faultCode()) {
$error = "Sync Error, Store " . $store_data['name'] . " >>" . $resp->faultString();
Mage::log($error, null, 'odoo_connector.log');
} else {
$response = 1;
$odoo_id = $resp->value()->me["int"];
$store = Mage::getModel("mobmultishop/mobmultishop");
$store->setOdooStoreId($odoo_id);
$store->setMageStoreId($store_data['store_id']);
$store->setCreatedBy($helper::$mage_user);
$store->save();
}
return $response;
}
示例6: exportAttributeSet
public function exportAttributeSet($setName, $setId)
{
$helper = Mage::helper('magerpsync/connection');
$client = $helper->getClientConnect();
$context = $helper->getOdooContext();
$mapped_ids = $this->getMappedAttributeSetIds();
if (!in_array($setId, $mapped_ids)) {
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$attributeset_array = array('name' => new xmlrpcval($setName, "string"), 'set_id' => new xmlrpcval($setId, "int"), 'created_by' => new xmlrpcval($helper::$mage_user, "string"));
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg->addParam(new xmlrpcval("magento.attribute.set", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($attributeset_array, "struct"));
$msg->addParam(new xmlrpcval($context, "struct"));
$resp = $client->send($msg);
if ($resp->faultCode()) {
$error_message = $resp->faultString();
return array('erp_set_id' => 0, 'success' => false, 'message' => $error_message);
} else {
$odoo_id = $resp->value()->me["int"];
$mapping_data = array('name' => $setName, 'mage_id' => $setId, 'odoo_id' => $odoo_id, 'created_by' => $helper::$mage_user);
$this->setmapping($mapping_data);
return array('success' => true, 'erp_set_id' => $odoo_id);
}
}
return array('success' => true);
}
示例7: register
/**
* Dekodiere die via XMLRPC übertragenen Atributte, dann führe die
* parent Methode aus und transformiere die Antwort.
*
* @param xmlrpcmsg $xmlrpcmsg Die XMLRPC Anfrage
* @return xmlrpcresp Gibt den Statuscode 1 für Erfolg zurück
*/
public function register($xmlrpcmsg)
{
$name = $xmlrpcmsg->getParam(0)->scalarval();
//Zugriff auf den ersten Parameter
$age = $xmlrpcmsg->getParam(1)->scalarval();
//Zugriff auf den zweiten Parameter
$res = parent::register($name, $age);
//übergebe Parameter an parent Methode
$resConverted = new xmlrpcval($res, "int");
//Kodiere Rückgabewert der parent Methode
return new xmlrpcresp($resConverted);
//Erstelle XMLRPC Antwort aus dem Rückgabewert für Clienten
}
示例8: exec
function exec($method, $params = NULL)
{
$message = new xmlrpcmsg($method);
if ($params && is_array($params)) {
foreach ($params as $value) {
$message->addParam(php_xmlrpc_encode($value));
}
}
$result = $this->db->send($message, 15);
if ($result->faultCode()) {
throw new Exception($result->faultString());
}
return $result->value();
}
示例9: CheckOdooActiveConfig
public function CheckOdooActiveConfig()
{
$helper = Mage::helper('magerpsync/connection');
$helper->getSocketConnect();
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
if ($userId > 0) {
$mage_url = Mage::getBaseUrl();
$client = $helper->getClientConnect();
$fields = array('magento_url' => new xmlrpcval($mage_url, "string"));
$msg2 = new xmlrpcmsg('execute');
$msg2->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg2->addParam(new xmlrpcval($userId, "int"));
$msg2->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg2->addParam(new xmlrpcval("magento.configure", "string"));
$msg2->addParam(new xmlrpcval("fetch_connection_info", "string"));
$msg2->addParam(new xmlrpcval($fields, "struct"));
$resp = $client->send($msg2);
if ($resp->faultcode()) {
$error = $this->__("Fetch Odoo Config Error,") . $resp->faultString();
Mage::log($error, null, 'odoo_connector.log');
} else {
$data = $resp->value()->scalarval();
if ($data) {
$this->ERP_CATEG = $data['category']->me['array'][0]->me['int'];
$this->ERP_LANG = $data['language']->me['string'];
$this->ERP_WAREHOUSE = $data['warehouse_id']->me['array'][0]->me['int'];
$this->ERP_INSTANCE = $data['id']->me['int'];
$this->setToSession();
return true;
}
}
}
return false;
}
示例10: CheckOdooActiveConfig
public function CheckOdooActiveConfig()
{
$helper = Mage::helper('magerpsync/connection');
$mage_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
/*$fields = array('magento_url'=>new xmlrpcval($mage_url, "string"),);*/
$helper->getSocketConnect();
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
if ($userId > 0) {
$client = $helper->getClientConnect();
$fields = array('magento_url' => new xmlrpcval($mage_url, "string"));
$msg2 = new xmlrpcmsg('execute');
$msg2->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg2->addParam(new xmlrpcval($userId, "int"));
$msg2->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg2->addParam(new xmlrpcval("magento.configure", "string"));
$msg2->addParam(new xmlrpcval("fetch_connection_info", "string"));
$msg2->addParam(new xmlrpcval($fields, "struct"));
$resp = $client->send($msg2);
$data = $resp->value()->scalarval();
if ($data) {
$this->ERP_CATEG = $data['category']->me['array'][0]->me['int'];
$this->ERP_LANG = $data['language']->me['string'];
$this->ERP_WAREHOUSE = $data['warehouse_id']->me['array'][0]->me['int'];
$this->ERP_INSTANCE = $data['id']->me['int'];
$this->setToSession();
return true;
}
}
return false;
}
示例11: forward_request
/**
* Forward an xmlrpc request to another server, and return to client the response received.
* @param xmlrpcmsg $m (see method docs below for a description of the expected parameters)
* @return xmlrpcresp
*/
function forward_request($m)
{
// create client
$timeout = 0;
$url = php_xmlrpc_decode($m->getParam(0));
$c = new xmlrpc_client($url);
if ($m->getNumParams() > 3) {
// we have to set some options onto the client.
// Note that if we do not untaint the received values, warnings might be generated...
$options = php_xmlrpc_decode($m->getParam(3));
foreach ($options as $key => $val) {
switch ($key) {
case 'Cookie':
break;
case 'Credentials':
break;
case 'RequestCompression':
$c->setRequestCompression($val);
break;
case 'SSLVerifyHost':
$c->setSSLVerifyHost($val);
break;
case 'SSLVerifyPeer':
$c->setSSLVerifyPeer($val);
break;
case 'Timeout':
$timeout = (int) $val;
break;
}
// switch
}
}
// build call for remote server
/// @todo find a weay to forward client info (such as IP) to server, either
/// - as xml comments in the payload, or
/// - using std http header conventions, such as X-forwarded-for...
$method = php_xmlrpc_decode($m->getParam(1));
$pars = $m->getParam(2);
$m = new xmlrpcmsg($method);
for ($i = 0; $i < $pars->arraySize(); $i++) {
$m->addParam($pars->arraymem($i));
}
// add debug info into response we give back to caller
xmlrpc_debugmsg("Sending to server {$url} the payload: " . $m->serialize());
return $c->send($m, $timeout);
}
示例12: createOdooOrder
public function createOdooOrder($This_order, $pricelist_id, $erpAddressArray)
{
$odoo_order_id = 0;
$partner_id = $erpAddressArray[0];
$partner_invoice_id = $erpAddressArray[1];
$partner_shipping_id = $erpAddressArray[2];
$increment_id = $This_order->getIncrementId();
$helper = Mage::helper('magerpsync/connection');
$client = $helper->getClientConnect();
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$warehouse_id = Mage::getSingleton('adminhtml/session')->getErpWarehouse();
$order_array = array('partner_id' => new xmlrpcval($partner_id, "int"), 'partner_invoice_id' => new xmlrpcval($partner_invoice_id, "int"), 'partner_shipping_id' => new xmlrpcval($partner_shipping_id, "int"), 'pricelist_id' => new xmlrpcval($pricelist_id, "int"), 'date_order' => new xmlrpcval($This_order->getCreatedAt(), "string"), 'client_order_ref' => new xmlrpcval($increment_id, "string"), 'warehouse_id' => new xmlrpcval($warehouse_id, "int"), 'channel' => new xmlrpcval('magento', "string"));
/* Adding Shipping Information*/
if ($This_order->getShippingMethod()) {
$shipping_method = $This_order->getShippingMethod();
$shipping_code = explode('_', $shipping_method);
if ($shipping_code) {
$shipping_code = $shipping_code[0];
$erp_carrier_id = Mage::getModel('magerpsync/carrier')->checkSpecificCarrier($shipping_code);
if ($erp_carrier_id > 0) {
$order_array['carrier_id'] = new xmlrpcval($erp_carrier_id, "int");
}
}
}
/* Adding Payment Information*/
$payment_method = $This_order->getPayment()->getMethodInstance()->getTitle();
if ($payment_method) {
$payment_info = 'Payment Information:- ' . $payment_method;
$order_array['note'] = new xmlrpcval($payment_info, "string");
}
/* Adding Store Information */
$store_id = $This_order->getStoreId();
$collection = Mage::getModel('mobmultishop/mobmultishop')->getCollection()->addFieldToFilter('mage_store_id', array('eq' => $store_id));
foreach ($collection as $col) {
$erp_store_id = $col->getOdooStoreId();
$order_array['wk_shop'] = new xmlrpcval($erp_store_id, "int");
}
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg->addParam(new xmlrpcval("sale.order", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($order_array, "struct"));
$resp = $client->send($msg);
if ($resp->faultcode()) {
$error = "Export Error, Order " . $increment_id . " >>" . $resp->faultString();
Mage::log($error, null, 'odoo_connector.log');
} else {
$odoo_order_id = $resp->value()->me["int"];
}
return $odoo_order_id;
}
示例13: atheme
function atheme($hostname, $port, $path, $sourceip, $username, $password, $service, $command, $params)
{
$message = new xmlrpcmsg("atheme.login");
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($password, "string"));
$client = new xmlrpc_client($path, $hostname, $port);
$response = $client->send($message);
$session = NULL;
if (!$response->faultCode()) {
$session = explode("<string>", $response->serialize());
$session = explode("</string", $session[1]);
$session = $session[0];
} else {
return "Authorisation failed";
}
$message = new xmlrpcmsg("atheme.command");
$message->addParam(new xmlrpcval($session, "string"));
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($sourceip, "string"));
$message->addParam(new xmlrpcval($service, "string"));
$message->addParam(new xmlrpcval($command, "string"));
if ($params != NULL) {
if (sizeof($params) < 2) {
foreach ($params as $param) {
$message->addParam(new xmlrpcval($param, "string"));
}
} else {
$firstparam = $params[0];
$secondparam = "";
for ($i = 1; $i < sizeof($params); $i++) {
$secondparam .= $params[$i] . " ";
}
$message->addParam(new xmlrpcval($firstparam, "string"));
$message->addParam(new xmlrpcval($secondparam, "string"));
}
$response = $client->send($message);
}
if (!$response->faultCode()) {
return $response->serialize();
} else {
return "Command failed: " . $response->faultString();
}
}
示例14: call
function call($url, $method, $params)
{
// xmlrpc encode parameters
for ($i = 0; $i < count($params); $i++) {
if (get_class($params[$i]) != 'xmlrpcval') {
$params[$i] = xmlrpc_encode($params[$i]);
}
}
// send request
$message = new xmlrpcmsg($method, $params);
if ($this->debug) {
// $this->display_xml($message->serialize());
print "<PRE>" . htmlentities($message->serialize()) . "</PRE>\n";
//("XML-RPC message:\n $message->serialize()",0);
}
$addr = parse_url($url);
$client = new xmlrpc_client($url, $addr['host'], $addr['port']);
if ($this->debug) {
$client->setDebug(1);
}
debug("XML-RPC", "call to " . $url);
$response = $client->send($message);
if ($this->debug) {
print "<PRE>" . htmlentities($response->serialize()) . "</PRE>\n";
}
// process response
//debug("XML-RPC Response", $response->serialize());
if (!$response) {
addError("No response: probably host is unreachable");
} elseif ($response->faultCode() > 0) {
// there was an error
addError("Error response: " . $response->faultCode() . " " . $response->faultString());
} else {
$retval = $response->value();
if ($retval) {
$retval = xmlrpc_decode($retval);
}
//debug("Response", $retval);
return $retval;
}
return NULL;
}
示例15: Erp_customer_create
public function Erp_customer_create($customer_array, $mage_customer_id, $mage_address_id)
{
$odoo_id = 0;
$helper = Mage::helper('magerpsync/connection');
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$client = $helper->getClientConnect();
$context = $helper->getOdooContext();
$customer = Mage::getModel('customer/customer')->load($mage_customer_id);
$mage_id = $customer->getStoreId();
$language_mapping = Mage::getModel('mobmultilang/mobmultilang')->getCollection()->addFieldToFilter('mage_store_id', array('eq' => $mage_id));
$erp_lang = '';
foreach ($language_mapping as $mapping) {
$erp_lang = $mapping->getOdooLang();
}
$customer_array['lang'] = new xmlrpcval($erp_lang, "string");
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg->addParam(new xmlrpcval("res.partner", "string"));
$msg->addParam(new xmlrpcval("create", "string"));
$msg->addParam(new xmlrpcval($customer_array, "struct"));
$msg->addParam(new xmlrpcval($context, "struct"));
$resp = $client->send($msg);
if ($resp->faultCode()) {
$error = "Export Error, Customer Id " . $mage_customer_id . "(" . $mage_address_id . ") >>" . $resp->faultString();
$response['odoo_id'] = 0;
$response['error'] = $error;
Mage::log($error, null, 'odoo_connector.log');
} else {
$odoo_id = $resp->value()->me["int"];
/* entry inside Mapping table*/
if ($odoo_id && $mage_customer_id && $mage_address_id) {
$mapping_data = array('erp_customer_id' => $odoo_id, 'mage_customer_id' => $mage_customer_id, 'mage_address_id' => $mage_address_id, 'created_by' => $helper::$mage_user);
Mage::getModel("magerpsync/magerpsync")->mappingerp($mapping_data);
if ($odoo_id > 0 && $mage_address_id) {
$map_array = array('cus_name' => new xmlrpcval($odoo_id, "int"), 'oe_customer_id' => new xmlrpcval($odoo_id, "int"), 'mag_customer_id' => new xmlrpcval($mage_customer_id, "string"), 'mag_address_id' => new xmlrpcval($mage_address_id, "string"), 'created_by' => new xmlrpcval($helper::$mage_user, "string"), 'instance_id' => $context['instance_id']);
$map = new xmlrpcmsg('execute');
$map->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$map->addParam(new xmlrpcval($userId, "int"));
$map->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$map->addParam(new xmlrpcval("magento.customers", "string"));
$map->addParam(new xmlrpcval("create", "string"));
$map->addParam(new xmlrpcval($map_array, "struct"));
$msg->addParam(new xmlrpcval($context, "struct"));
$resp = $client->send($map);
}
}
}
return $odoo_id;
}