IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Webmethods: Validating Document structure?

  • 1.  Webmethods: Validating Document structure?

    Posted Mon November 15, 2021 11:56 PM

    Hello, I’d like to know how to validate documents. For instance, I have this document type (based on JSON) where an example of an accepted input is like:

    { "people": [
    {"firstName":"Joe","lastName":"Jacky","age":21},
    {"firstName":"Dana","lastName":"Salis","age":20}
    ]
    }
    

    Now, during the flow service, I want to make sure that the inserted input follows exactly like such format. So if even so much the name of the elements are different, then it catches an error. Therefore, if the input is like this:

    { "peoples": [
    {"firstName":"Joe","lastName":"Jacky","age":21},
    {"firstName":"Dana","lastName":"Salis","age":20}
    ]
    }
    

    Then it throws an error because it doesn’t have an element called ‘peoples’.

    How do I put such validation? Because the last I tried that, the designer just accepted as it is and didn’t throw an error.

    Thanks.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Webmethods: Validating Document structure?

    Posted Tue November 16, 2021 12:40 AM

    @kristian.wijaya1234

    1. Create JSON documentType against your json Schema. Designer — Right click – Create JSON Document Type ( Not regular document Type )

      image

      You can create json Schema in any online or json tool using your json input string which you want to validate.

    2. Execute pub.json.schema:validate - Pass json string and json document type name

      if your input json string is against your json documentType then isValid will be false and error.message will hint you the errored one.

    I hope this helps you.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Webmethods: Validating Document structure?

    Posted Tue November 16, 2021 01:36 AM

    @DINESH_J Can you tell me about how to put in the conformsTo part? I get the idea that you’re directing to the JSON Document Type you just made, but I’m not sure how to locate that package-wise.

    I get the idea that you use this:

    testRESTPackage (Package) → people (JSON Document Type)

    Is that correct or wrong?

    Then, what if the location is this, how do I change that to conformsTo?

    testRESTPackage (Package) → documents (folder) → people (JSON Document Type)

    Thanks.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 4.  RE: Webmethods: Validating Document structure?

    Posted Tue November 16, 2021 01:47 AM

    @kristain , In webMethods if we are referring against any elements at runtime it should be always fully Qualified Name . The fully qualified service name is comprised of two parts: a folder identifier and the service name

    testRESTPackage(Folder name )–> People (element name).

    so just right click and copy the name from designer of your JSON documentType and provided as confirmTo of validate service


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services