adobe / acc-js-sdk

A JavaScript SDK for Adobe Campaign Classic
Apache License 2.0
21 stars 22 forks source link

Workflow PostEvent method not working #105

Closed hamidouikene closed 4 months ago

hamidouikene commented 5 months ago

Expected Behaviour

PostEvent from xtk:workflow to send an event to a signal in a workflow

Actual Behaviour

The SDK throws an error because it's expecting the parameters to be inside a variables entity.

Reproduce Scenario (including but not limited to)

Just use the SDK and call PostEvent method: await NLWS.xtkWorkflow.postEvent(name, 'signal', '', variables, false);

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

Please see above

Logs taken while reproducing problem

CampaignException {
  name: 'CampaignException',
  message: "500 - Error SOAP-ENV:Server calling method 'xtk:workflow#PostEvent': SOP-330011 Error while executing the method 'PostEvent' of service 'xtk:workflow'.. Parameters must be inside a 'variables' entity (instead of 'parameters').",
  statusCode: 500,
  methodCall: {
    type: 'SOAP',
    url: 'https://sprich-mkt-stage2.campaign.adobe.com/nl/jsp/soaprouter.jsp?soapAction=xtk%3Aworkflow%23PostEvent',
    urn: 'xtk:workflow',
    methodName: 'PostEvent',
    request: {
      url: 'https://sprich-mkt-stage2.campaign.adobe.com/nl/jsp/soaprouter.jsp?soapAction=xtk%3Aworkflow%23PostEvent',
      method: 'POST',
      headers: [Object],
      data: '<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://xml.apache.org/xml-soap"><SOAP-ENV:Header><X-Security-Token/></SOAP-ENV:Header><SOAP-ENV:Body><m:PostEvent xmlns:m="urn:xtk:workflow" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><sessiontoken xsi:type="xsd:string"/><workflowId xsi:type="xsd:string">sprProofAbandonedCartEmail</workflowId><activity xsi:type="xsd:string">signal</activity><transition xsi:type="xsd:string"/><parameters xsi:type="ns:Element" SOAP-ENV:encodingStyle="http://xml.apache.org/xml-soap/literalxml"><parameters id="1000"/></parameters><complete xsi:type="xsd:boolean">false</complete></m:PostEvent></SOAP-ENV:Body></SOAP-ENV:Envelope>'
    },
    response: "<?xml version='1.0'?><SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring xsi:type='xsd:string'>SOP-330011 Error while executing the method 'PostEvent' of service 'xtk:workflow'.</faultstring><detail xsi:type='xsd:string'>Parameters must be inside a 'variables' entity (instead of 'parameters').</detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>"
  },
  errorCode: 'SOP-330011',
  faultCode: 'SOAP-ENV:Server',
  faultString: "Error while executing the method 'PostEvent' of service 'xtk:workflow'.",
  detail: "Parameters must be inside a 'variables' entity (instead of 'parameters').",
  cause: undefined
}

The SDK throws an error when I try to use PostEvent from xtk:workflow schema. The error says that Parameters must be inside a 'variables' entity (instead of 'parameters'). I took a look at the code and it looks like the XML element name is overriden for method StartWithParameters only.

// Hack for workflow API. The C++ code checks that the name of the XML element is <variables>. When
// using xml representation at the SDK level, it's ok since the SDK caller will set that. But this does
// not work when using "BadgerFish" representation where we do not know the root element name.
if (entitySchemaId == "xtk:workflow" && methodName == "StartWithParameters" && paramName == "parameters")
    docName = "variables";

Is there a reason this hack is not implemented for the other methods? PostEvent for example?

mkiki commented 5 months ago

Hi @hamidouikene, thanks for the detailed report. Indeed, this is missing. There's no particular reason for this hack not being in PostEvent, it's just a miss. I'll publish a fix ASAP.

mkiki commented 5 months ago

This should be fixed in build 1.1.47 The following methods will be fixed: StartWithParameters, PostEvent, SimulateWithParameters, SpawnWithParameters, and SpawnWithParametersEx

hamidouikene commented 5 months ago

Thank you so much @mkiki!

hamidouikene commented 5 months ago

@mkiki I can close this one if you want.

mkiki commented 4 months ago

Hi @hamidouikene , that would be great yes