Hey Folks,
I am trying to validate Json schema using in built service
It’s not working, I have been at this for more than 12hrs staright trying to sort out the mapping but same error.
Here is the mappings
For conform field I am passing in the schema that will validate the Json request coming in:
{
“$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”: “[1]{9}$”
}
},
“required”: [
“phonenumber”
]
},
“header”: {
“type”: “object”,
“additionalProperties”: false,
“properties”: {
“Id”: {
“type”: “string”,
“pattern”: “^\d{10}$”
}
},
“required”: [
“Id”
]
}
}
}
Here is the Json request that will be passed into inbound field:
{
"header":{
"Id":"1234567890"
},
"body":{
"phonenumber":"123456789"
}
}
Here is the constant error:
com.wm.app.b2b.server.ServiceException: JSON schema validation failed: {
“$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”: “[2]{9}$”
}
},
“required”: [
“phonenumber”
]
},
“header”: {
“type”: “object”,
“additionalProperties”: false,
“properties”: {
“Id”: {
“type”: “string”,
“pattern”: “^\d{10}$”
}
},
“required”: [
“Id”
]
}
}
}
is not a valid JSON document type.
com.wm.app.b2b.server.ServiceException: JSON schema validation failed: {
“$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”: “[3]{9}$”
}
},
“required”: [
“phonenumber”
]
},
“header”: {
“type”: “object”,
“additionalProperties”: false,
“properties”: {
“Id”: {
“type”: “string”,
“pattern”: “^\d{10}$”
}
},
“required”: [
“Id”
]
}
}
}
is not a valid JSON document type.
at pub.jsonschema.getSchemaPathFromNode(jsonschema.java:120)
at pub.jsonschema.validate(jsonschema.java:97)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:411)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:739)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:61)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:250)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:56)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:178)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:334)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:41)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:401)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:611)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:423)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:381)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:253)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:236)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:267)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:668)
at com.wm.lang.flow.FlowState.step(FlowState.java:534)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:501)
at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1150)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:739)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:61)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:250)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:56)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:178)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:334)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:41)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:401)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:611)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:423)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:381)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:253)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:127)
at com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:163)
at com.wm.app.b2b.server.HTTPDispatch.handleRequest(HTTPDispatch.java:223)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:430)
at com.wm.util.pool.PooledThread.run(PooledThread.java:134)
at java.lang.Thread.run(Thread.java:748)
Please help folks. It is becoming tiresome.
I am not sure where to pass the schema and where to pass the request that I need to validate against schema.
Thanks