This post was originally published here
I was creating a demo using the Logic App Adapter for BizTalk 2016.
I was sending a message from the Logic App to BizTalk.
I used the JSON Schema wizard and used the default setting. Root
, for the Root element.
When testing I received the following error.
There was a failure executing the receive pipeline: "CRMDemo.ReceivePipeline1, CRMDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=17c282d81ae800e3" Source: "XML validator" Receive Port: "CRMReceivePort" URI: "/GetCRMAccount/Service1.svc" Reason: The XML Validator failed to validate. Details: The element 'Root' in namespace 'http://CRMDemo.JSONSchema1' has invalid child element 'id'. List of possible elements expected: 'body'..
I looked at the message body from suspended message
{"id":"94bf6bf8-4a96-e611-80ea-c4346bdc7221","name":"Silly Goose two","phone":"748-852-1256"}
There wasn’t a body
node. 💡
I then checked the source from the Logic App
{ "Send_message": { "inputs": { "body": { "id": "@{triggerBody()?['accountid']}", "name": "@{triggerBody()?['name']}", "phone": "@{triggerBody()?['telephone1']}" }, "host": { "api": { "runtimeUrl": "https://logic-apis-northcentralus.azure-apim.net/apim/biztalk" }, "connection": { "name": "@parameters('$connections')['biztalk_1']['connectionId']" } }, "method": "post", "path": "/Send", "queries": { "receiveLocationAddress": "http://40.86.103.129/GetCRMAccount/Service1.svc" } }, "runAfter": {}, "type": "ApiConnection" } }
My BizTalk Schema is shown below.
<?xml version="1.0" encoding="utf-16"?> <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://CRMDemo.JSONSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Root"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="id" type="xs:string" /> <xs:element minOccurs="0" name="name" type="xs:string" /> <xs:element minOccurs="0" name="phone" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Was it a bug or did I do something wrong?
Finally it came to me. 😳
I needed use the body
node as the name of the Root element in my schema. That solved the problem.