Service Virtualization

  • 1.  Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 08, 2016 02:08 AM

    Example:

    If have an element called "First Name" which should be equal to "jem", it should  show some response. If I want to sent first name as blank value, I am not able to handle it.



  • 2.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 08, 2016 04:02 AM

    If you are sending no value for a field then it should send response from meta because it matches only signature.

    There are multiple ways to handle this:

    1. Send response from meta response.

    2. Mark comparison operator as "anything" for optional fields.

    3. remove the optional field from the arguments tab.

    4. Add one more transaction for same operation where optional field is not present in argument tab.

    5. Change the match style to "Signature".

     

    Please provide detail if you have any specific requirement for same.

     

    Thanks,

    monika mehta



  • 3.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 09, 2016 01:03 PM

    Hello

     

    Sorry to be rude but a couple of those ways are absolutely wrong. First of all you should never Change the match style!

     

    Next, when working with optional elements you have to differ if this is an optional element that is only nullable or like in soap not in the request. That distinction makes a big difference.

     

    If we are talking about an element that is always present but sometimes only blank, you want to handle those with behavioral scenarios. Example:

     

    • Create 2 specific transactions
    • One transaction that will create a response
      • Argument: first name
      • Comparison Operator: =
      • Value: jem
    • Second transaction which shall result in an error response
      • Argument: first name
      • Comparison Operator: regex
      • Value: ^$

     

    What you don't want to do is:

    2. Mark comparison operator as "anything" for optional fields.

    3. remove the optional field from the arguments tab.

     

    Since those suggestions would not result in the behavior you want as you need to match on that specific element.

     

    If it is an element that can be present in the request or not (meaning it is either there or not there at all, like in soap), that would be a bit more complicated. If that is the case let me know and I will write you a solution to that too.



  • 4.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 10, 2016 11:16 PM

    Hi Hoang,

     

    I do agree there are few ways which are not acceptable. I just listed how this thing can be achieved, and the selection of solution is purely on the basis of requirement.

     

    It wasn't rude. Don't worry!!

     

    Thanks.



  • 5.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 11, 2016 08:49 AM

    I have a similar topic. how do deal with apis with large numbers of array elements containing structures with variable arrays (of structures), with optional fields

    but have not found an acceptable method of dealing with this in the product.

     

    I ended up writing our own handler and matcher service, for REST & JSON. It is 100% generic, and we have implemented about 15 services so far. 1 text file (vsi transaction like) and one spreadsheet (vsi message content like)

    using the JSON Schema to validate the message for required/optionals/data types before doing any content matching really helps. then I implemented wildcarding to allow for any data at any level (field, structure, array).

     

    we are stuck however on our first SOAP service which has all these same problems. (and I haven't learned the xml/xpath capabilities like I did for json)



  • 6.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 19, 2016 03:30 AM

    Thank you  very much Richter for the detailed explanation and this is the exact answer I was looking for. Thanks a lot !!



  • 7.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Nov 22, 2016 07:32 AM

    Hi Richter,

     

    First of all thanks for the detailed explanation.

     

    Am having requirement as per below scenario:

    "If it is an element that can be present in the request or not (meaning it is either there or not there at all, like in soap), VS should send the response by ignoring the optional fields"

     

    Request you to provide me the resolution how can i handle it in my VSI.

     

    Thanks in advance

     

    Regards,

    Aravind



  • 8.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Nov 22, 2016 08:09 AM

    sadly you must make a new pattern for the message without the element, then setup the rest according to your needs. 

    the matching will ALWAYS use the actual elements in the message as present or not (signature match is the minimum). 



  • 9.  Re: Can someone please let me know, how to handle optional elements in VSI.

    Posted Jan 19, 2016 03:29 AM

    Thank you Monika for the quick reply and it was helpful.