Created
September 30, 2011 00:40
-
-
Save wheeyls/1252350 to your computer and use it in GitHub Desktop.
BigMachines SOAP Calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* param {String} sessionId | |
* param {String} bs_id | |
* param {String} sitename | |
* param {String} action_var_name | |
* param {String [][] } attr sets of attributes to set. Format: [[docnum, varname, value], [docnum, varname, value]...] | |
* param {String} error_string | |
* | |
* return {String} the soap response | |
*/ | |
//===edit these values to match the given site=== | |
processVariableName = "quickstart_commerce_process"; | |
mainDocVariableName = "quote_process"; | |
subDocVariableName = "line_process"; | |
//===end edit section=== | |
ret = ""; | |
soapResponse = ""; | |
quote_process = ""; | |
line_process = ""; | |
file_url = "http://" + sitename + ".bigmachines.com/bmfsweb/" + sitename + "/image/SOAPTemplates/click_as_soap_call.xml"; | |
soapCall = urldatabyget(file_url, "", "Error reading file from file manager."); | |
soapCall = replace(soapCall, "SITENAME_REPLACE", sitename); | |
soapCall = replace(soapCall, "PROCESS_VAR_NAME_REPLACE", processVariableName); | |
soapCall = replace(soapCall, "MAIN_DOC_VARIABLE_REPLACE", mainDocVariableName); | |
soapCall = replace(soapCall, "SESSIONID_REPLACE", sessionId); | |
soapCall = replace(soapCall, "ACTION_NAME_REPLACE", action_var_name); | |
soapCall = replace(soapCall, "BSID_REPLACE", bs_id); | |
keys = string[]; | |
line_items = dict("string"); | |
for x in attr { | |
if(sizeofarray(x) <> 3) { | |
return "Error in form of data passed to 'click_as' function"; | |
} | |
docnum = trim(x[0]); | |
tagname = trim(x[1]); | |
value = x[2]; | |
open = "<bm:"+tagname+">"; | |
close = "</bm:"+tagname+">\n"; | |
if(docnum == "1") { | |
quote_process = quote_process + open + value + close; | |
} else { | |
//build dictionary of line items | |
line = open + value + close; | |
if(containskey(line_items, docnum) == true) { | |
curr = get(line_items, docnum); | |
put(line_items, docnum, line+curr); | |
} else { | |
append(keys, docnum); | |
put(line_items, docnum, line); | |
} | |
} | |
} | |
for key in keys { | |
open_line = "<bm:"+subDocVariableName+ " bm:data_type='3' bm:document_number='" + key + "'>\n"; | |
close_line = "</bm:"+subDocVariableName+">\n"; | |
line_process = line_process + open_line + get(line_items, key) + close_line; | |
} | |
soapCall = replace(soapCall, "QUOTE_PROCESS_REPLACE", quote_process); | |
soapCall = replace(soapCall, "SUB_DOC_REPLACE", line_process); | |
header_dict = dict("string"); | |
put(header_dict, "Content-Type", "text/xml; charset=utf-8"); | |
ret = urldatabypost("http://"+sitename+".bigmachines.com/v1_0/receiver", soapCall, error_string, header_dict); | |
return ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> | |
<soapenv:Header> | |
<bm:userInfo xmlns:bm='urn:soap.bigmachines.com' soapenv:actor='http://schemas.xmlsoap.org/soap/actor/next' soapenv:mustUnderstand='0'> | |
<bm:sessionId>SESSIONID_REPLACE</bm:sessionId> | |
</bm:userInfo> | |
<bm:category xmlns:bm='urn:soap.bigmachines.com' soapenv:actor='http://schemas.xmlsoap.org/soap/actor/next' soapenv:mustUnderstand='0'>Commerce</bm:category> | |
<bm:xsdInfo xmlns:bm='urn:soap.bigmachines.com' soapenv:actor='http://schemas.xmlsoap.org/soap/actor/next' soapenv:mustUnderstand='0'> | |
<bm:schemaLocation>http://SITENAME_REPLACE.bigmachines.com/bmfsweb/SITENAME_REPLACE/schema/v1_0/commerce/PROCESS_VAR_NAME_REPLACE.xsd</bm:schemaLocation> | |
</bm:xsdInfo> | |
</soapenv:Header> | |
<soapenv:Body> | |
<bm:updateTransaction xmlns:bm='urn:soap.bigmachines.com'> | |
<bm:transaction> | |
<bm:id>BSID_REPLACE</bm:id> | |
<bm:data_xml> | |
<bm:MAIN_DOC_VARIABLE_REPLACE bm:data_type='0' bm:document_number="1"> | |
QUOTE_PROCESS_REPLACE | |
<bm:sub_documents> | |
SUB_DOC_REPLACE | |
</bm:sub_documents> | |
</bm:MAIN_DOC_VARIABLE_REPLACE> | |
</bm:data_xml> | |
<bm:action_data> | |
<bm:action_var_name>ACTION_NAME_REPLACE</bm:action_var_name> | |
<bm:performer_comment/> | |
<bm:reason_var_name/> | |
<bm:performer_name/> | |
<bm:performer_type/> | |
<bm:performer_company_name/> | |
</bm:action_data> | |
</bm:transaction> | |
</bm:updateTransaction> | |
</soapenv:Body> | |
</soapenv:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* param {String} sessionId | |
* param {String} bs_id | |
* param {String} sitename | |
* | |
* return {XML String} the soap response | |
*/ | |
//===edit these values to match the given site=== | |
processVariableName = "quickstart_commerce_process"; | |
//===end edit section=== | |
ret = ""; | |
soapResponse = ""; | |
file_url = "http://" + sitename + ".bigmachines.com/bmfsweb/" + sitename + "/image/SOAPTemplates/get_transaction_soap_call.xml"; | |
errorString = "Error running get_transaction function."; | |
soapCall = urldatabyget(file_url, "", "Error reading file from file manager."); | |
soapCall = replace(soapCall, "SITENAME_REPLACE", sitename); | |
soapCall = replace(soapCall, "SESSIONID_REPLACE", sessionId); | |
soapCall = replace(soapCall, "BSID_REPLACE", bs_id); | |
soapCall = replace(soapCall, "PROCESS_VAR_NAME_REPLACE", processVariableName); | |
ret = urldatabypost("http://"+sitename+".bigmachines.com/v1_0/receiver", soapCall, errorString); | |
return ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<soapenv:Header> | |
<bm:userInfo xmlns:bm="urn:soap.bigmachines.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"> | |
<bm:sessionId>SESSIONID_REPLACE</bm:sessionId> | |
</bm:userInfo> | |
<bm:category xmlns:bm="urn:soap.bigmachines.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">Commerce</bm:category> | |
<bm:xsdInfo xmlns:bm="urn:soap.bigmachines.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"> | |
<bm:schemaLocation>http://SITENAME_REPLACE.bigmachines.com/bmfsweb/SITENAME_REPLACE/schema/v1_0/commerce/PROCESS_VAR_NAME_REPLACE.xsd</bm:schemaLocation> | |
</bm:xsdInfo> | |
</soapenv:Header> | |
<soapenv:Body> | |
<bm:getTransaction xmlns:bm="urn:soap.bigmachines.com"> | |
<bm:transaction> | |
<bm:id>BSID_REPLACE</bm:id> | |
</bm:transaction> | |
</bm:getTransaction> | |
</soapenv:Body> | |
</soapenv:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* param {String} username | |
* param {String} password | |
* param {String} sitename | |
* | |
* return {String} session id | |
*/ | |
ret = ""; | |
soapResponse = ""; | |
session_start_tag = "<bm:sessionId>"; | |
session_end_tag = "</bm:sessionId>"; | |
file_url = "http://" + sitename + ".bigmachines.com/bmfsweb/" + sitename + "/image/SOAPTemplates/login_as_soap_call.xml"; | |
errorString = "Error logging into "+sitename+" as "+username; | |
if(username <> "" and password <> "") { | |
soapCall = urldatabyget(file_url, "", "Error loading files from filemanager"); | |
//replace key words with parameters | |
soapCall = replace(soapCall, "USERNAME_REPLACE", username); | |
soapCall = replace(soapCall, "PASSWORD_REPLACE", password); | |
soapCall = replace(soapCall, "SITENAME_REPLACE", sitename); | |
//run call | |
headerDict = dict("string"); | |
put(headerDict, "Content-Type", "text/xml; charset=utf-8"); | |
soapResponse = urldatabypost("http://"+sitename+".bigmachines.com/v1_0/receiver", soapCall, errorString, headerDict); | |
if(find(soapResponse, "bm:success>true") > -1) { | |
startIndex = find(soapResponse, session_start_tag); | |
endIndex = find(soapResponse, session_end_tag); | |
if (startIndex >= 0 and endIndex >= 0) { | |
startIndex = startIndex + len(session_start_tag); | |
ret = substring(soapResponse, startIndex, endIndex); | |
} else { | |
ret = errorString; | |
} | |
} else { | |
ret = errorString; | |
} | |
} | |
return ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> | |
<soapenv:Header> | |
<bm:category xmlns:bm='urn:soap.bigmachines.com' soapenv:actor='http://schemas.xmlsoap.org/soap/actor/next' soapenv:mustUnderstand='0'>Security</bm:category> | |
<bm:xsdInfo xmlns:bm='urn:soap.bigmachines.com' soapenv:actor='http://schemas.xmlsoap.org/soap/actor/next' soapenv:mustUnderstand='0'> | |
<bm:schemaLocation>http://SITENAME_REPLACE.bigmachines.com/bmfsweb/SITENAME_REPLACE/schema/v1_0/security/Security.xsd</bm:schemaLocation> | |
</bm:xsdInfo> | |
</soapenv:Header> | |
<soapenv:Body> | |
<bm:login xmlns:bm='urn:soap.bigmachines.com'> | |
<bm:userInfo> | |
<bm:username><![CDATA[USERNAME_REPLACE]]></bm:username> | |
<bm:password><![CDATA[PASSWORD_REPLACE]]></bm:password> | |
</bm:userInfo> | |
</bm:login> | |
</soapenv:Body> | |
</soapenv:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* param sessionId {String} Session of User to log out | |
* param sitename {String} Site name to logout of | |
**/ | |
ret = ""; | |
err_string = "There was an error connecting to the SOAP call at site: "+sitename; | |
file_url = "http://" + sitename + ".bigmachines.com/bmfsweb/" + sitename + "/image/SOAPTemplates/logout_as_soap_call.xml"; | |
soap_call = urldatabyget(file_url, "", "Error reading file from file manager."); | |
soap_call = replace(soap_call, "SESSION_ID_REPLACE", sessionId); | |
soap_call = replace(soap_call, "SITENAME_REPLACE", sitename); | |
header_dict = dict("string"); | |
put(header_dict, "Content-Type", "text/xml; charset=utf-8"); | |
ret = urldatabypost("http://"+sitename+".bigmachines.com/v1_0/receiver", soap_call, err_string, header_dict); | |
return ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> | |
<soapenv:Header> | |
<bm:userInfo xmlns:bm="urn:soap.bigmachines.com"> | |
<bm:sessionId>SESSION_ID_REPLACE</bm:sessionId> | |
</bm:userInfo> | |
<bm:category xmlns:bm="urn:soap.bigmachines.com">Security</bm:category> | |
<bm:xsdInfo xmlns:bm="urn:soap.bigmachines.com"> | |
<bm:schemaLocation>https://SITENAME_REPLACE.bigmachines.com/bmfsweb/SITENAME_REPLACE/schema/v1_0/security/Security.xsd</bm:schemaLocation> | |
</bm:xsdInfo> | |
</soapenv:Header> | |
<soapenv:Body> | |
<bm:logout xmlns:bm="urn:soap.bigmachines.com"/> | |
</soapenv:Body> | |
</soapenv:Envelope> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment