Generating Parts on-the-fly (buy side) – SOAP via BML

24 02 2011

The flexibility for business to develop SKUs or Custom codes (for parts) is needed in many of the supply-demand scenarios. Most of the enterprises come up with such requirement where the Business, to be precise, the Sales would want to call for a new part (a SKU or an Item Code) which they never made, to be developed for a specific customer. This is a possibility for them as the Business is clear of the specifications and technology the SKU/Item should be made of. Most of the supply-demand automation platforms like BigMachines do not come up with the infrastructure to do this. Thanks to the open ends of these platforms powered by SOAP etc, these interesting requirements can be solved.

In BMI’s perspective, I need to be able to create parts being on the configurator on the buy side. One possible solution for this is SOAP via BML.

BML understands a function called urldatabypost(). Basically the BML engine reads the file uploaded available at at URL and attempts to parse it. As long as the file is in a language which is understandable by BM, it works.

So the solution for this case is, i generate a dynamic SOAP request using the BM Webservices, add some keys to it (keys add dynamics to the request. In our case, we need the Part Number to be dynamic, so it could be a key) and add the SOAP XML as a file to the BM File Manager. Then i call this file using urldatabypost() and replace the keys with a BM function which generates a part number pattern.

Sample:
// Clearances
cdataStart = "<![CDATA[";cdataEnd = "]]>";
// Call the SOAP file saved in File Manager
mySOAPURL = "https://customersite.bigmachines.com/bmfsweb/devge/image/SOAP/addgenericpart.xml"; //File Location
myPartFile = urldatabypost(mySOAPURL,"",""); // This calls the file
// Replace keys a.k.a Holder Text with the dynamic data
// _BM_USER_SESSION_ID a system attribute in configuration (an equivalent is available in commerce)
myPartFile = replace(myPartFile,"SESSION_ID", cdataStart +_BM_USER_SESSION_ID + cdataEnd);
// transactionID is a user defined configurable attribute
myPartFile = replace(myPartFile,"GENERIC", cdataStart +partListStr[i]+ cdataEnd);
// partListStr was a string which captures the length of the parts array
soapURL = "https://customersite.bigmachines.com/v1_0/receiver"; // location to send the soap call (receiver url)
soapResponse= urldatabypost(soapURL, myPartFile ,""); // sends the soap call and returns response to variable.