how to pass parameter as object with xmlrpc - node module (github.com/baalexander/node-xmlrpc) - node.js

actually need to pass a parameter which is an xml as an object with xmlrpc node module github.com/baalexander/node-xmlrpc;
client call is :
client.methodCall('anAction', ['aParam'], function (error, value) {})
need to replace aParam with something like that:
<?xml version='1.0'?>
<methodCall>
<methodName>GetBalanceAndDate</methodName>
<params>
<param>
<value><struct>
<member>
<name>originTransactionID</name>
<value><string>90000001</string></value>
</member>
<member>
<name>originHostName</name>
<value><string>PADFVPZ452P01</string></value>
</member>
<member>
<name>subscriberNumber</name>
<value><string>24107482594</string></value>
</member>
<member>
<name>subscriberNumberNAI</name>
<value><int>1</int></value>
</member>
<member>
<name>originTimeStamp</name>
<value><dateTime.iso8601>20140626T14:53:53+0100</dateTime.iso8601></value>
</member>
<member>
<name>originNodeType</name>
<value><string>EXT</string></value>
</member>
</struct></value>
</param>
</params>
</methodCall>
I've tried :
var req1 = {
value: {
struct:{
member:{$name:'originTransactionID',value:'90000001'},
mamber:{$name:'originHostName',value:'GAGAPOPAAPZP01'},
member:{$name:'subscriberNumber',value:'24104151708'},
member:{$name:'subscriberNumberNAI',value: 1},
member:{$name:'originTimeStamp', value: new Date()},
member:{$name:'originNodeType', value: 'EXT'}
}
}
};
client.methodCall('GetBalanceAndDate', [req1], function (error, value) {})
but having error : faultString: 'Illegal request message'
any idea on how it works please??

try to pass xml as a parameter, I do so:
const request = `
<?xml version="1.0"?>
<methodCall>
<methodName>CheckBal</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>RMID</name>
<value><string>${rmid}</string></value>
</member>
<member>
...
</methodCall>`;
client.methodCall('CheckBal', [request], (error, value) => {
console.log(value);
});

Related

libxmljs: how to use xinclude?

I try to use libxmljs with nodejs.
In my sample I want to use the xi:include.
<ord:order xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">
<number>123ABBCC123</number>
<customer>
<name>Priscilla Walmsley</name>
<number>15466</number>
</customer>
<items>
<xi:include href="/Users/mar/ws_e/libxml/test/resources/chapter5prod.xml" />
</items>
</ord:order>
include File:
<ord:product xmlns:ord="http://example.org/ord"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/ord chapter04ord1.xsd">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<size system="US-DRESS">10</size>
<color value="blue"/>
</ord:product>
This is my code:
var xsdDoc = libxml.parseXml(schemaSource);
var xmlDocValid = libxml.parseXml(docSource);
var xmlDocInvalid = libxml.parseXml(xml_invalid);
xmlDocValid.validate(xsdDoc);
console.dir(xmlDocValid);
console.dir(xmlDocValid.validationErrors);
Then I get the error:
Document {
errors: [],
validationErrors:
[ { Error: Element '{http://www.w3.org/2001/XInclude}include': This element is not expected. Expected is ( product ).
So my question is how to use the x:include right at libxmljs?
Kind regards
Markus

BootstrapValidator dosen't work with xpages?

i'm a beginner in bootstrap,i was trying to build an Xpage with the BootstrapValidator to validate an inputText but it dosen't work,below the code source,can we help me to find a solution!
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.resources>
<xp:styleSheet href="/bootstrapValidator/css/bootstrap.css"></xp:styleSheet>
<xp:styleSheet href="/bootstrapValidator/css/bootstrapValidator.css"></xp:styleSheet>
<xp:script src="/JQueryXSnippet.js" clientSide="true"></xp:script>
<xp:script src="/bootstrapValidator/js/bootstrap.min.js" clientSide="true"> </xp:script>
<xp:script src="/bootstrapValidator/js/bootstrapValidator.js" clientSide="true"></xp:script>
</xp:this.resources>
<div class="col-md-5">
<xp:inputText id="username" title=" username"></xp:inputText>
</div>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[$(document).ready(
function() {
$("#{id:username}" ).bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
username: {
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and can\'t be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
message: 'The username can only consist of alphabetical, number, dot and underscore'
}
}
} } });
]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
Use the XPages compatible jQuery selector x$ instead of the native jQuery $ selector.
Also try using XSP.addOnLoad() instead of (document).ready().
Furthermore, your XPages xp:inputText field called "username" has an id in the browser called something like "view:_id1:_id2:_id8:username". So it's not called "username" as stated in your fields definition for bootstrapValidator. Therefore bootstrapValidator is unable to find the field. Try adding this to your scriptBlock instead of "username: {":
#{id:username}: {

OCMod not finding blocks of code

What is up with OCMod? It will not find a block of code [that I need to replace]
Here is what I have in my mod:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<file path="catalog/controller/information/information.php">
<operation>
<search><![CDATA[$data['breadcrumbs'] = array();]]></search>
<add position="after"><![CDATA[$template = 'newproducts.tpl';]]></add>
</operation>
<operation>
<search>
<![CDATA[
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/information.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/information.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/information/information.tpl', $data));
}
]]>
</search>
<add position="after"><![CDATA[echo 'booooooger';]]></add>
</operation>
</file>
</modification>
the First operation works just fine, the second does not find the block of code in the search [and it is there exactly - I've synced and diffed the files it IS there] Here is the error:
FILE: catalog/controller/information/information.php
CODE: $data['breadcrumbs'] = array();
LINE: 8
CODE: if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/information.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/information/information.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/information/information.tpl', $data));
}
NOT FOUND!
I've tried the search with the trim attribute set to both true and false... no luck.
How do I get this to work?
I suggest to use single line search, if you want to search multiline then you need to use regex or more.
<operation>
<search>
<![CDATA[
$this->response->setOutput($this->load->view('default/template/information/information.tpl', $data));
]]>
</search>
<add position="after" offset="1">
<![CDATA[
echo 'booooooger';
]]>
</add>
</operation>

Magento 1.7 Add attribute to category

I'm trying to add to the field list of the categories a new text field called "website_url".
I found many tutorials but none works on magento 1.7.
I created a new module as following :
-code\local\SaponeWebConcept\CategoriesAttributes\sql\categoriesattributes_setup\mysql4-install-0.1.0.php :
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_category', 'website_url', array(
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Lien du site',
'input' => 'text',
'class' => '',
'source' => '',
'global' => 0,
'visible' => 1,
'required' => 0,
'user_defined' => 0,
'default' => '',
'searchable' => 0,
'filterable' => 0,
'comparable' => 0,
'visible_on_front' => 0,
'unique' => 0,
'position' => 1,
));
$installer->endSetup();
-code\local\SaponeWebConcept\CategoriesAttributes\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<SaponeWebConcept_CategoriesAttributes>
<version>0.1.0</version>
</SaponeWebConcept_CategoriesAttributes>
</modules>
<global>
<resources>
<categoriesattributes_setup>
<setup>
<module>SaponeWebConcept_CategoriesAttributes</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</categoriesattributes_setup>
</resources>
</global>
</config>
And my module is correctly activated by this :
<SaponeWebConcept_CategoriesAttributes>
<active>true</active>
<codePool>local</codePool>
</SaponeWebConcept_CategoriesAttributes>
But when I access my category editing, I don't see any new field.
What am I doing wrong ? The module is supposed to work immediatly if the cache is off, right ?
Thanks in advance.
I had the same issue. This is how I solved it:
app/code/local/yourmodulename/sql/yourcustomattribute_setup/mysql4-upgrade-0.0.9-0.1.3.php
<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("catalog_category", "your_attribute", array(
"type" => "varchar",
"backend" => "",
"frontend" => true,
"label" => "Your Attribute",
"input" => "text",
"class" => "",
"source" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
"visible" => true,
"required" => false,
"user_defined" => false,
"default" => "",
"searchable" => false,
"filterable" => false,
"comparable" => false,
"visible_on_front" => true,
"unique" => true,
"note" => ""
));
$installer->endSetup();
app/code/local/yourmodulename/etc/config.xml
<config>
<modules>
<Yournamespace_Yourmodulename>
<version>0.1.3</version>
</Yournamespace_Yourmodulename>
</modules>
<frontend>
<routers>
<yourmodulename>
<use>standard</use>
<args>
<module>Yournamespace_Yourmodulename</module>
<frontName>categoryattribute</frontName>
</args>
</yourmodulename>
</routers>
<category>
<collection>
<attributes>
<yourmodulename />
</attributes>
</collection>
</category>
<layout>
<updates>
<yourmodulename>
<file>categoryattribute.xml</file>
</yourmodulename>
</updates>
</layout>
</frontend>
<global>
<helpers>
<yourmodulename>
<class>Yournamespace_Yourmodulename_Helper</class>
</yourmodulename>
</helpers>
<blocks>
<yourmodulename>
<class>Yournamespace_Yourmodulename_Block</class>
</yourmodulename>
</blocks>
<models>
<yourmodulename>
<class>Yournamespace_Yourmodulename_Model</class>
<resourceModel>categoryattribute_mysql4</resourceModel>
</yourmodulename>
</models>
<resources>
<yourmodulenamee_setup>
<setup>
<module>Yournamespace_Yourmodulename</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</yourmodulename_setup>
<yourmodulename_write>
<connection>
<use>core_write</use>
</connection>
</yourmodulename_write>
<yourmodulename_read>
<connection>
<use>core_read</use>
</connection>
</yourmodulename_read>
</resources>
</global>
</config>
app/etc/modules/Your_modulename.xml
<?xml version="1.0"?>
<config>
<modules>
<Yournamespace_Yourmodulename>
<active>true</active>
<codePool>local</codePool>
<version>0.1.3</version>
</Yournamespace_Yourmodulename>
</modules>
</config>
Check you database to see if the sql has been installed under "Eav Attribute"
You custom category attribute should now be showing in the frontend!!!!
Now all you need to do is show the attribute on the frontened using:
<?php echo $_product->getYourattributeid(); ?>
For those who have this kind of problems my solution in MAGENTO 1.8 whas only make sure that VERSION tag is setted.. if you dont put it cause mysql4-install-0.0.1.php never is called .
<config>
<modules>
<Yournamespace_Yourmodulename>
<active>true</active>
<codePool>local</codePool>
<version>0.0.1</version>
</Yournamespace_Yourmodulename>
</modules>
</config>

Management API - The request body XML was invalid or not correctly specified

Cross posting from http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/31b6aedc-c069-4e32-8e8f-2ff4b7c30793
I'm getting this error on changing configuration through the service management API: The request body XML was invalid or not correctly specified
The request body payload:
<?xml version="1.0" encoding="utf-8"?>
<ChangeConfiguration xmlns="http://schemas.microsoft.com/windowsazu
re">
<Configuration>PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxTZXJ2aWNlQ29uZmlndX
JhdGlvbiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIi
B4bWxuczp4c2Q9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIiB4bWxucz0iaHR0cDovL3
NjaGVtYXMubWljcm9zb2Z0LmNvbS9TZXJ2aWNlSG9zdGluZy8yMDA4LzEwL1NlcnZpY2VDb25maWd1cm
F0aW9uIiBzZXJ2aWNlTmFtZT0iIiBvc0ZhbWlseT0iMSIgb3NWZXJzaW9uPSIqIj4KICA8Um9sZSBuYW
1lPSJXZWJSb2xlMSI+CiAgICA8Q29uZmlndXJhdGlvblNldHRpbmdzPgogICAgICA8U2V0dGluZyBuYW
1lPSJNaWNyb3NvZnQuV2luZG93c0F6dXJlLlBsdWdpbnMuRGlhZ25vc3RpY3MuQ29ubmVjdGlvblN0cm
luZyIgdmFsdWU9IlVzZURldmVsb3BtZW50U3RvcmFnZT10cnVlIi8+CiAgICA8L0NvbmZpZ3VyYXRpb2
5TZXR0aW5ncz4KICAgIDxJbnN0YW5jZXMgY291bnQ9IjIiLz4KICAgIDxDZXJ0aWZpY2F0ZXMvPgogID
wvUm9sZT4KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4K</Configuration>
</ChangeConfiguration>
I'm passing it the following configuration:
$configuration = '<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" serviceName="" osFamily="1" osVersion="*">
<Role name="WebRole1">
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true"/>
</ConfigurationSettings>
<Instances count="2"/>
<Certificates/>
</Role>
</ServiceConfiguration>';
Does anyone know why this error occurs? I suspect it has something to do with encoding but not sure.
Are you getting this directly from the call to the API? If so, it should be coming back with a x-ms-requestid header.
If you take that and call out to
https://management.core.windows.net/<subscriptionID/operations/<requestId>
This should give you a much more detailed message about what is going on, usually telling you exactly what is going on.
Outside of that, I'd check the following:
1.) Check your encoding, then check it again. I only mention this because when I first wrapped the API I had an issue where my encoding was screwing something up. So what I finally did was write a bit of code that would read the file, encode it, decode that, save that to a new file. Then binary compare the two. I finally found they were different by a single byte and it broke the whole thing.
2.) Check your config. Upload that exact config file to your role via the portal and see if its accepted.
3.) Check API version header. Not sure on the SDK for PHP, but if possible can you explicitly check/set the x-ms-version header being sent to the api?
4.) Cause a valid failure, and reverse engineer from there. If all else fails, pass in a blank or random/invalid encoded string. Then use the GetOperationStatus endpoint to ensure you are getting errors to the tune of "Configuration is invalid". This way you know your request is being accepted, but the encoding/configuration is throwing an error.
EDIT: from your reply here and MSDN
5.) Try omitting the XML Declaration
<?xml version="1.0" encoding="utf-8"?>
from the request body.
When I run your exact request vs the same request created by my own .net api wrapper, the only difference is that XML declaration is not in the body of the POST. The wrapper-generated class works for me.
Thanks everyone! I've been reverse-engineering what the csmanage.exe sends over the wire, and it works now. Here's why:
Steve Marx' "/" solution (http://social.msdn.microsoft.com/Forums/en-US/windowsazuretroubleshooting/thread/31b6aedc-c069-4e32-8e8f-2ff4b7c30793?prof=required) was required (it should be: //services/hostedservices/phptest1/deploymentslots/production/?comp=config)
I removed the XML declaration
I had to replace all newlines in my XML and make it a one-liner
As a side note: I noticed there's a "x-ms-version: 2010-04-01" in csmanage.exe. Any news/docs on that version?
PS: This will end up in the Windows Azure SDK for PHP if you want to see it working
1) Getting the config from Azure as ASCII (?), uploading it again as ASCII fails, uploading it as UTF-8 fails as well.
2) Works
3) Works
4) All I get is this lausy error (should create a T-Shirt from that :-)): "The request body XML was invalid or not correctly specified", even when passing it an ampty XML.
For the record: RAW request and response are:
-----------------------
Request
-----------------------
object(Microsoft_Http_Client)#3 (15) {
["adapter:protected"]=>
object(Microsoft_Http_Client_Adapter_Socket)#5 (6) {
["socket:protected"]=>
NULL
["connected_to:protected"]=>
array(2) {
[0]=>
NULL
[1]=>
NULL
}
["out_stream:protected"]=>
NULL
["config:protected"]=>
array(15) {
["persistent"]=>
bool(false)
["ssltransport"]=>
string(3) "ssl"
["sslcert"]=>
string(51) "C:\Projects\Workspaces\Default\Azure\management.pem"
["sslpassphrase"]=>
string(11) "*************"
["maxredirects"]=>
int(5)
["strictredirects"]=>
bool(false)
["useragent"]=>
string(21) "Microsoft_Http_Client"
["timeout"]=>
int(10)
["httpversion"]=>
string(3) "1.1"
["keepalive"]=>
bool(false)
["storeresponse"]=>
bool(true)
["strict"]=>
bool(true)
["output_stream"]=>
bool(false)
["sslusecontext"]=>
bool(true)
}
["method:protected"]=>
string(3) "POST"
["_context:protected"]=>
resource(38) of type (stream-context)
}
["uri:protected"]=>
object(Microsoft_Uri_Http)#10 (9) {
["_username:protected"]=>
string(0) ""
["_password:protected"]=>
string(0) ""
["_host:protected"]=>
string(27) "management.core.windows.net"
["_port:protected"]=>
int(443)
["_path:protected"]=>
string(97) "/******************/services/hostedservices/phptest1/deploymentslots/production"
["_query:protected"]=>
string(11) "comp=config"
["_fragment:protected"]=>
string(0) ""
["_scheme:protected"]=>
string(5) "https"
}
["headers:protected"]=>
array(3) {
["content-type"]=>
array(2) {
[0]=>
string(12) "Content-Type"
[1]=>
string(15) "application/xml"
}
["expect"]=>
array(2) {
[0]=>
string(6) "Expect"
[1]=>
string(0) ""
}
["x-ms-version"]=>
array(2) {
[0]=>
string(12) "x-ms-version"
[1]=>
string(10) "2009-10-01"
}
}
["method:protected"]=>
string(3) "POST"
["paramsGet:protected"]=>
array(0) {
}
["paramsPost:protected"]=>
array(0) {
}
["enctype:protected"]=>
NULL
["raw_post_data:protected"]=>
string(965) "<?xml version="1.0" encoding="utf-8"?>
<ChangeConfiguration xmlns="http://schemas.microsoft.com/windowsazure">
<Configuration>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iIHNlcnZpY2VOYW1lPSIiIG9zRmFtaWx5PSIxIiBvc1ZlcnNpb249IioiPgogIDxSb2xlIG5hbWU9IldlYlJvbGUxIj4KICAgIDxDb25maWd1cmF0aW9uU2V0dGluZ3M+CiAgICAgIDxTZXR0aW5nIG5hbWU9Ik1pY3Jvc29mdC5XaW5kb3dzQXp1cmUuUGx1Z2lucy5EaWFnbm9zdGljcy5Db25uZWN0aW9uU3RyaW5nIiB2YWx1ZT0iVXNlRGV2ZWxvcG1lbnRTdG9yYWdlPXRydWUiLz4KICAgIDwvQ29uZmlndXJhdGlvblNldHRpbmdzPgogICAgPEluc3RhbmNlcyBjb3VudD0iMiIvPgogICAgPENlcnRpZmljYXRlcy8+CiAgPC9Sb2xlPgo8L1NlcnZpY2VDb25maWd1cmF0aW9uPgo=</Configuration>
</ChangeConfiguration>"
["auth:protected"]=>
NULL
["files:protected"]=>
array(0) {
}
["cookiejar:protected"]=>
NULL
["last_request:protected"]=>
NULL
["last_response:protected"]=>
NULL
["redirectCounter:protected"]=>
int(0)
}
-----------------------
Response
-----------------------
object(Microsoft_Http_Response)#9 (5) {
["version:protected"]=>
string(3) "1.1"
["code:protected"]=>
int(400)
["message:protected"]=>
string(11) "Bad Request"
["headers:protected"]=>
array(5) {
["Content-length"]=>
string(3) "230"
["Content-type"]=>
string(30) "application/xml; charset=utf-8"
["Server"]=>
string(21) "Microsoft-HTTPAPI/2.0"
["Date"]=>
string(29) "Thu, 17 Feb 2011 07:15:36 GMT"
["Connection"]=>
string(5) "close"
}
["body:protected"]=>
string(230) "<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>InvalidXmlRequest</Code><Message>The request body’s XML was invalid or not correctly specified.</Message></Error>"
}

Resources