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.


#TechXchangePresenter
 View Only
  • 1.  Pub.schema:validate using document type

    Posted Wed May 26, 2010 02:07 AM

    I’m trying to validate a document using pub.schema:validate. Here is a representative doc type definition (named ABC):

    ID (string - required, no null)
    Name (string - optional)
    Summary (document list - required, no null)
    …Product (string - required, no null)
    …Type (string - required, no null)
    Stage (string - required, no null)

    Document var xyz has these fields present:

    ID - 123
    Name - foo
    Stage - bar

    Calling pub.schema:validate with these inputs:

    object - xyz
    conformsTo - ABC (IS doc type, not a schema)
    maxErrors - -1
    failIfInvalid - true

    I expect the call to fail since xyz does not have the required doc list “Summary” present, but it does not. It fails as expected if “Stage” is omitted.

    I’m missing something simple, I’m sure. Does anyone have an idea of what I’m overlooking?


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


  • 2.  RE: Pub.schema:validate using document type

    Posted Wed May 26, 2010 11:36 PM

    I think you must inspect the conformsTo value you are setting, this value affects the result:

    Hope this give you a hint :smiley:


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


  • 3.  RE: Pub.schema:validate using document type

    Posted Wed February 10, 2021 03:01 AM

    Hi Reamon,

    How are you creating IS Doc type to pass it into conformsTo field?
    conformsTo is a String field, How can I pass a Doc type to string field.

    Here is my json schema:

    {
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$ref": "#/definitions/Welcome",
    "definitions": {
    "Welcome": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
    "header": {
    "$ref": "#/definitions/header"
    },
    "body": {
    "$ref": "#/definitions/body"
    }
    },
    "required": [
    "body",
    "header"
    ],
    "title": "Welcome"
    },
    "body": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
    "phonenumber": {
    "type": "string",
    "pattern": "^[\\d]{9}$"
    }
    },
    "required": [
    "phonenumber"
    ]
    },
    "header": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
    "Id": {
    "type": "string",
    "pattern": "^\\d{10}$"
    }
    },
    "required": [
    "Id"
    ]
    
    }
    }
    }
    

    when I pass in the schema directly into conformTo field, it throws this error
    com.wm.app.b2b.server.ServiceException: JSON schema validation failed:{} is not a valid JSON document type.
    Please let me know.

    Thanks


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


  • 4.  RE: Pub.schema:validate using document type

    Posted Wed February 10, 2021 11:35 AM

    Pass in the name of the IS document type, not the JSON schema string. In Designer, create a “JSON Document Type”. You may need to adjust your JSON schema. When I tried to do this using the JSON above, it fails due to multiple issues.

    Once the doc type is created, call pub.json.schema:validate to validate JSON content (string, bytes, stream, IS document) against the JSON document type. Pass the document type name that you created, not the JSON schema string.

    Side note: I would encourage that you NOT perform document validation “in the middle.” Typically it is preferable to have the end points do that, if needed, because they know what they really need/care about which can change over time. What usually happens is middleware flags a document as invalid, then the end point application team says “oh, ignore that.” :slight_smile:

    HTH.


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


  • 5.  RE: Pub.schema:validate using document type

    Posted Wed February 10, 2021 02:39 PM

    You the man boss. Worked smoothly.
    Appreciate your help very much.
    Thanks alot.


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