Adding an XML node
eConnect allows you to add XML nodes to the XML document schema. Custom XML nodes enable you to use new data elements in an eConnect XML document. You also use custom XML nodes to trigger the business logic in a custom SQL stored procedure.
To begin, specify a name for your XML node. The name must be unique and must match the name of a SQL stored procedure. In addition, the name of the XML node cannot end with the word Items.
Warning: In the eConnect transaction type schema documents, XML nodes that end with Items indicate the node contains one or more child nodes. If you attempt to use a single XML node with a name that ends with Items, your transaction will fail.
When eConnect processes an XML document, it uses the name of each XML node to find the SQL stored procedure that contains the business logic for that XML node. For example, a document that includes a custom XML node named <eConnectCustomProcedure> requires the target database to include a SQL stored procedure named eConnectCustomProcedure.
After you have a name for your XML node, you must specify the data elements for your XML node. The data elements contain the values for the XML document. To add data elements to an XML node, use the following guidelines:
- Define the data elements of your custom XML node. Typically, the number of data elements match the input parameters of the SQL stored procedure.
- Specify a unique name for each data element. Typically, the data element names match the names used for the input parameter of the SQL stored procedure.
- Determine the data type of each element. Use the data type and data length constraints from the input parameters of the SQL stored procedures to specify the type of data for each element.
The SQL stored procedure uses the data elements of the XML node to complete the business logic associated with that XML node.
To show a custom XML node, the following XML example defines a node named <eConnectCustomProcedure>. Notice how the XML node includes a single data element named <CUSTNMBR> that holds a customer ID value:
<eConnectCustomProcedure> <CUSTNMBR>CONTOSOL0002</CUSTNMBR> </eConnectCustomProcedure>
After you define your custom XML node, add your new XML node to an existing eConnect transaction type schema. To use your XML node, you need to include that node in an eConnect XML document.
The following XML example adds the <eConnectCustomProcedure> XML node to an eConnect XML document. Notice how the <eConnectCustomProcedure> node has been added to the <RMCustomerMasterType> transaction type.
<eConnect xmlns:dt="urn:schemas-microsoft-com:datatypes"> <RMCustomerMasterType> <eConnectProcessInfo> </eConnectProcessInfo> <eConnectCustomProcedure> <CUSTNMBR>CONTOSOL0002</CUSTNMBR> </eConnectCustomProcedure> <taUpdateCreateCustomerRcd> <CUSTNMBR>CONTOSOL0002</CUSTNMBR> <CUSTNAME>Contoso, Ltd.</CUSTNAME> <TAXSCHID>USALLEXMPT-0</TAXSCHID> <SHIPMTHD>PICKUP</SHIPMTHD> <ADDRESS1>321 Main S </ADDRESS1> <CITY>Valley City</CITY> <STATE>ND</STATE> <ZIPCODE>56789</ZIPCODE> <COUNTRY>USA</COUNTRY> <PHNUMBR1>13215550100</PHNUMBR1> <PHNUMBR2>13215550110</PHNUMBR2> <FAX>13215550120</FAX> <SALSTERR>TERRITORY 6 </SALSTERR> <SLPRSNID>SEAN C .</SLPRSNID> <SLPRSNFN>Sean</SLPRSNFN> <SPRSNSLN>Chai</SPRSNSLN> <UPSZONE>red</UPSZONE> <CNTCPRSN>Joe Healy</CNTCPRSN> <CHEKBKID>PAYROLL</CHEKBKID> <PYMTRMID>Net 30 </PYMTRMID> <COMMENT1>comment1</COMMENT1> <COMMENT2>comment2</COMMENT2> <USERDEF1>Retail</USERDEF1> <PRBTADCD>PRIMARY</PRBTADCD> <PRSTADCD>PRIMARY</PRSTADCD> <ADRSCODE>PRIMARY</ADRSCODE> <STADDRCD>PRIMARY</STADDRCD> <CRCARDID>Gold Credit </CRCARDID> <STMTNAME>Contoso, Ltd.</STMTNAME> <SHRTNAME>Contoso, Ltd.</SHRTNAME> <Revalue_Customer>1</Revalue_Customer> <Post_Results_To>0</Post_Results_To> <CRLMTAMT>90000.00</CRLMTAMT> </taUpdateCreateCustomerRcd> </RMCustomerMasterType> </eConnect>