Service Virtualization

Expand all | Collapse all

Matching process for large XML payloads with most tags being optional

  • 1.  Matching process for large XML payloads with most tags being optional

    Posted Oct 11, 2017 12:04 AM

    I'm manually creating an MQ-based virtual service for simulating field service calls.

    Our XML requests have a handful of tags that are required for matching the request to response (primarily WorkRequestType and MeterType) and upwards of 50-75 additional fields. In trying to build these images, I'm running into difficulties using Signature matching, as some arbitrary customer data lines include "AddressLine2" or "DoingBusinessAs", as well as a variety of other optional data fields. 

     

    Ultimately, I want to be able to include ALL possible fields, and if they exist in the actual request, great. If they don't, also great, since I only need a handful of fields to match on.  What I don't want to do is create a separate request for each variant.  If there are 5 commonly variant tags, I'd have to create 2^5 = 32 variants for each of the 6 work order types.

     

    I'm trying to use a match script, but I'm not sure the logic is being called correctly. If I recall correctly, the match script should override the default matching logic (exact, signature, operation), correct? 

     

    My beanshell match script:

    boolean operationsMatch = incomingRequest.getOperation().equals(sourceRequest.getOperation());

    if (operationsMatch) {
    String requestWRT = incomingRequest.getArguments().get("OrderData_WorkReqTypeCode");
    String requestMeterMfg = sourceRequest.getArguments().get("ServiceData_Meter_MeterManufacturer");

    if(requestWRT.equals("CONNECT METER") && requestMeterMfg.equals("ITR")) {
    // true means these arguments match
    return true;
    }
    }
    // false means no match
    return false;

    All the different work orders have the same Operation: "OpsWorkRequest"

     

    Is there anything else I should be looking for?

     

    Apologies in advance for vagueness, it's been a long day.

     

    Thanks for any help!



  • 2.  Re: Matching process for large XML payloads with most tags being optional
    Best Answer

    Broadcom Employee
    Posted Oct 11, 2017 09:55 AM

    Hi,

     

    You can create the VS using Request Data Manager DPH and keep the mandatory arguments in it. This way it will ignore the optional arguments. Documentation is available at Request Data Manager Data Protocol - DevTest Solutions - 10.1 - CA Technologies Documentation 

     

    You can also use Match Script to ignore the optional arguments or accept any other arguments. Depending on Match script returns True or False that response is returned.

     

    Yes, the match script should override the default matching logic (exact, signature, operation).

     

    Thanks,

    Prema