locked
BizTalk2013 R2 - JSON Encoder "Object reference not set to an instance of an object" RRS feed

  • Question

  • Hi All,

    I am trying to convert an xml to JSON format.  Using the sample here, I created a Send pipeline component and dropped the out-of-the-box JSON Encoder into the Encode section.  I tested this pipeline by:

    1. Create a receive port and a receive location using the File Adapter and the PassThruReceive

    2. Create a send port that receives a message from the above receive port via the File Adapter and my custom JSON send pipeline.

    3. Submit an XML file

    For some reasons BizTalks errors out with below text.

    "Source: "JSON encoder" Send Port: "SendPort1"Object reference not set to an instance of an object".

    Has anyone experienced this?  Thanks.

    Tuesday, February 10, 2015 3:25 AM

All replies

  • Can you confirm that the XML hitting your JSON encoder is valid XML? Are you able to open the source in an Internet Explorer? Also can you post your sample XML here?

    Morten la Cour

    P.S.

    I see now there is a stupid encoding error in the XML sample in my blog:

    Replace:

    <Order xmlns=”http://blogdemo.com/schemas/v10″&gt;

    With:

    <Order xmlns=”http://blogdemo.com/schemas/v10″>

    Morten la Cour
    • Edited by la Cour Tuesday, February 10, 2015 8:21 AM
    Tuesday, February 10, 2015 8:18 AM
  • Hi,

    Try specifying the Root Node and Root Node Namespace in the properties of the JSON decoder.

    Regards,

    Tamil

    Tuesday, February 10, 2015 11:09 AM
  • Hi la Cour Vertica, the XML is valid and I'm able to load the xml in IE. Below is the content of my test xml file.

    <ns0:EnrollmentApplicationEvent xmlns:ns0="http://www.abc.edu/CRM/EnrollmentApplicationEvent/20130803" xmlns:ns4="http://www.abc.edu/CRM/Address/20130614" xmlns:ns3="http://www.abc.edu/CRM/EmailAddress/20130614" xmlns:ns1="http://www.abc.edu/CRM/Enrollment/20130614" xmlns:ns2="http://www.abc.edu/CRM/Phone/20130614">
     <ns0:ApplicationEventId>cbffd2ca-b52e-4c89-84eb-45460104fb04</ns0:ApplicationEventId>
     <ns0:ProcessEventInfo>
      <ProcessData xmlns="http://www.abc.edu/CRM/EnrollmentApplicationEvent/20130803">
       <Enrollment xmlns:b="http://www.abc.edu/ApplicationEvents/Schemas/ApplicationEvent/20101012" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.abc.edu/CRM/Enrollment/20130614">
        <Addresses xmlns:a="http://www.abc.edu/CRM/Address/20130614">
         <a:Address>
          <a:Address1>Testing</a:Address1>
          <a:Address2 i:nil="true"/>
          <a:City i:nil="true"/>
          <a:Country i:nil="true"/>
          <a:County i:nil="true"/>
          <a:Latitude>0</a:Latitude>
          <a:Longitude i:nil="true"/>
          <a:PostalCode i:nil="true"/>
          <a:State i:nil="true"/>
          <a:StateOrProvinceName i:nil="true"/>
          <a:CensusTract>0</a:CensusTract>
          <a:CensusBlock>0</a:CensusBlock>
          <a:FIPS>0</a:FIPS>
         </a:Address>
        </Addresses>
        <Agency>false</Agency>
        <BirthDate>1900-08-12</BirthDate>
        <Campus>0</Campus>
        <EmailAddresses xmlns:a="http://www.abc.edu/CRM/EmailAddress/20130614">
         <a:EmailAddress>
          <a:Address>billg@microsoft.com</a:Address>
          <a:Type i:nil="true"/>
         </a:EmailAddress>
        </EmailAddresses>
        <FirstName>Bill</FirstName>
        <FriendlyLeadId>8144007</FriendlyLeadId>
        <Gender>Male</Gender>
        <HasFelonyConviction>false</HasFelonyConviction>
        <HighSchoolGradMonth>8</HighSchoolGradMonth>
        <HighSchoolGradType i:nil="true"/>
        <HighSchoolGradYear>2013</HighSchoolGradYear>
        <HighSchoolName>18 - 20 Program</HighSchoolName>
        <HighSchoolState>WA</HighSchoolState>
        <HouseType>CHS</HouseType>
        <IsUsCitizen i:nil="true"/>
        <IsVeteran>false</IsVeteran>
        <LabFee>75.0000</LabFee>
        <LaptopFee>0</LaptopFee>
        <LastModified>0001-01-01T00:00:00</LastModified>
        <LastName>Gates</LastName>
        <ManufacturerProgramOfInterests xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
        <MeterFee>0</MeterFee>
        <MiddleName i:nil="true"/>
        <MilitaryBaseName>1  111th  Aviation Support</MilitaryBaseName>
        <MilitaryBaseState>FL</MilitaryBaseState>
        <MilitaryReleaseMonth i:nil="true"/>
        <MilitaryReleaseYear i:nil="true"/>
        <NameSuffix i:nil="true"/>
        <NameTitle i:nil="true"/>
        <OpportunityId>35939eec-4cf6-e211-8e71-78e3b50829fd</OpportunityId>
        <PhoneNumbers xmlns:a="http://www.abc.edu/CRM/Phone/20130614">
         <a:Phone>
          <a:Extension i:nil="true"/>
          <a:Number>555.555.5555</a:Number>
          <a:Type>C</a:Type>
         </a:Phone>
         <a:Phone>
          <a:Extension i:nil="true"/>
          <a:Number>333.333.3333</a:Number>
          <a:Type>H</a:Type>
         </a:Phone>
         <a:Phone>
          <a:Extension i:nil="true"/>
          <a:Number>000.000.0000</a:Number>
          <a:Type>W</a:Type>
         </a:Phone>
         <a:Phone>
          <a:Extension i:nil="true"/>
          <a:Number>444.444.4444</a:Number>
          <a:Type>F</a:Type>
         </a:Phone>
        </PhoneNumbers>
        <PreferedFirstName>BillG</PreferedFirstName>
        <PreferredMethodOfContact i:nil="true"/>
        <Program i:nil="true"/>
        <RegistrationFee>25.0000</RegistrationFee>
        <RepCode>8090</RepCode>
        <SessionCode>0</SessionCode>
        <Ssn i:nil="true"/>
        <StartDate>2013-05-06T06:00:00</StartDate>
        <StrfFee>0.0000000000</StrfFee>
        <Tuition>5200.0000</Tuition>
       </Enrollment>
      </ProcessData>
     </ns0:ProcessEventInfo>
    </ns0:EnrollmentApplicationEvent>


    • Edited by AnSDE007 Tuesday, February 10, 2015 5:08 PM
    Tuesday, February 10, 2015 4:48 PM
  • Hi Daniel - I did not see Root Node and Root Node Namespace listed.  Below are the properties that are listed for JSON encoder component.

    • Assembly
    • Description
    • Managed
    • Path
    • Remove Outer Envelope
    • Type

    • Edited by AnSDE007 Tuesday, February 10, 2015 4:50 PM
    Tuesday, February 10, 2015 4:50 PM
  • Hi, I'm encountering the same problem, did you ever find a resolution to this. I've tried the same basic setup and get the same error. I'm using Itineraries, so not sure if that's causing an additional error or not.
    Thursday, November 5, 2015 2:16 AM
  • Nolan - No, I did not find a resolution.  Luckily it was just a POC (Proof of Concept).
    Thursday, November 5, 2015 3:34 PM
  • Hi,

    JSON encoder dont have RootNode & Namespace Properties. I'm also facing the same problem.Please reply if you find solution for above problem

    • Proposed as answer by Sandesh Sahane Friday, December 18, 2015 10:57 AM
    • Unproposed as answer by Sandesh Sahane Monday, December 21, 2015 11:43 AM
    Tuesday, December 8, 2015 5:43 PM
  • Hi , 
    Convert your xml to JSON format, for that you will have to create JSON schema.Try using link for conversion: http://codebeautify.org/xmltojson 

    -Create .Json file from above link & while creating JSON schema from biztalk uses this file.It will create JSON schema for your xml.
    -Now do transformation from your xml->JSON schema & send transformed output to  send port which uses custom JSON send pipeline.

    My observation is,if you are sending special namespaces in xml,for JSON encoder it's hard to understand the namespaces you are sending and could not convert it to JSON format.
    If you have plain xml without any namespace u can easily convert it to JSON format without using JSON schema but if you have namespaces for your xml you will have to use JSON schema.

    Regards,
    Sandesh
    Monday, December 21, 2015 11:42 AM