For some reason, I keep forgetting this...BizTalk R2 EDI schemas are kept in an executable ZIP file (EXE extension) at C:\Program Files\Microsoft BizTalk Server 2006\XSD_Schema\EDIMicrosoftEdiXSDTemplates.exe.
By the way, the new BizTalk EDI support in R2 is way better than in previous versions. They have schemas for every X12 EDI document I could want, plus lots more. There's also support for EDIFACT, which I haven't had the privilege of using yet...
Setting up the EDI transactions is also much easier. Actually, there are some transactions that I never was able to set up using the old EDI system.
To compare the old EDI system to the new, it took me less than 1/2 the time to set up a real life outbound 810 transaction. Not bad.
A place for me to store and share some notes about technical stuff I'm working with at the moment.
The views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.
Thursday, February 01, 2007
Tuesday, January 30, 2007
Note About BizTalk xpath Function
I just wanted to archive some sample code here...I've used the xpath function in BizTalk orchestrations fairly often, but it always takes me a couple of tries to get it right.
Here's a snippet that I have used successfully to assign a value to a field in an EDI 810 document:
Here's another that I have used to extract the value from the same field in an EDI 810 document (there's a difference in the xpath expression, here I'm using the XPath string() function):
I have seen examples that look like the following, but when I try them the string value is just null:
Here's a snippet that I have used successfully to assign a value to a field in an EDI 810 document:
n104Path = "/*[local-name()='X12_00401_810']" +
"/*[local-name()='N1Loop1'][3]" +
"/*[local-name()='N1']/*[local-name()='N104']";
xpath(Edi810, n104Path) = Response.myField;
Here's another that I have used to extract the value from the same field in an EDI 810 document (there's a difference in the xpath expression, here I'm using the XPath string() function):
// check n104 element (under "ship to")
n104Path = "string(/*[local-name()='X12_00401_810']" +
"/*[local-name()='N1Loop1'][3]" +
"/*[local-name()='N1']/*[local-name()='N104'])";
n104String = (System.String)xpath(Edi810,n104Path);
n104String = n104String.Trim();
I have seen examples that look like the following, but when I try them the string value is just null:
n104Path = "/*[local-name()='X12_00401_810']" +
"/*[local-name()='N1Loop1'][3]" +
"/*[local-name()='N1']/*[local-name()='N104']/text()";
Saturday, September 09, 2006
I found 2 links that I want to keep here, for my future reference. If someone else uses them, I ask that they deposit $10,000 in my swiss bank account...(doesn't hurt to ask, right)?
The first one, from David Hurtado's blog, shows how to promote context properties within an orchestration. It also has a link to Jon Flander's blog to show how to do this in a pipeline component (which I believe you could now use inside an orchestration with BizTalk 2006).
The second link is to Jan Eliasen's blog. I've been tearing my hair out because for most of DTD's that I get from customers, when I import them into Visual Studio and use the schema editor, all of the nodes show up at the top level. Jan showed me how to get the schema to show up in VS in a clean, heirarchical way.
The first one, from David Hurtado's blog, shows how to promote context properties within an orchestration. It also has a link to Jon Flander's blog to show how to do this in a pipeline component (which I believe you could now use inside an orchestration with BizTalk 2006).
The second link is to Jan Eliasen's blog. I've been tearing my hair out because for most of DTD's that I get from customers, when I import them into Visual Studio and use the schema editor, all of the nodes show up at the top level. Jan showed me how to get the schema to show up in VS in a clean, heirarchical way.
Friday, March 03, 2006
BizTalk Pipelines Factoid
I'm sitting in the BizTalk 2006 Deep Dive training in Redmond right now, and the instructor told me some stuff that I don't remember seeing elsewhere. So I'm going to document this for myself and others.
The provided XMLTransmit pipeline will ensure that an incoming document is well formed XML, but it won't validate the document against a schema. In order to validate against a schema, you need to create a pipeline and do one of two things:
Note that if you use the XML validator component as desribed above, you don't have to specify a schema. However, if you do specify a schema (or schemas) in this component, the pipeline will then validate only against that specific schema (or schemas).
If you do choose to use a port to validate according to a schema, BizTalk 2006 will make it easier. In BTS 2006, pipelines support parameters, and you can override the schema(s) that are used.
BTW, I'm using the word "factoid" in the title because I figure if functoid is a word, than factoid must also be.
The provided XMLTransmit pipeline will ensure that an incoming document is well formed XML, but it won't validate the document against a schema. In order to validate against a schema, you need to create a pipeline and do one of two things:
- Drop an XML disassembler component into the pipeline, set the "Validate document structure" property to false, and then drop an XML validator component as well. This will validate the XML document against any schema that is deployed to your host.
- Drop only an XML disassembler into the pipeline, set the "Validate document structure" property to true, and then add one or more schemas to the "Document schemas" property.
Note that if you use the XML validator component as desribed above, you don't have to specify a schema. However, if you do specify a schema (or schemas) in this component, the pipeline will then validate only against that specific schema (or schemas).
If you do choose to use a port to validate according to a schema, BizTalk 2006 will make it easier. In BTS 2006, pipelines support parameters, and you can override the schema(s) that are used.
BTW, I'm using the word "factoid" in the title because I figure if functoid is a word, than factoid must also be.
Saturday, February 11, 2006
BizTalk Mapper - Looping Tricks
This post is intended to demonstrate 2 ways of using the looping functoid. One is pretty obvious, and the other shows a use for the looping functoid that requires a bit of help from a logical functoid.
Along the way I'll also show how a value mapping functoid works.
I have created 2 schemas intended to represent the status of a previously sent purchase order. POS.xsd is the output from a Line of Business (LOB) application, and PO_Status is intended to be sent to the customer. The LineItem node in POS.xsd and the Product node in POStatus.xsd both repeat 1 to unbounded times. Here's how the map looks:

The red functoid is a String Concatenate functoid, which has 3 inputs - ShipperName, a constant " - ", and ServiceLevel. The DateShipped element is mapped straight across, or "as is".
The turquoise functoids are Greater Than (GT) functoids. The first input you can see on the screen for the upper GT functoid is the QuantityOrdered element, and the second input is "0". This functoid will return true if the value in QuantityOrdered is more than 0. The output of this functoid is mapped into 2 Value Mapping (VM) functoids. A value mapping functoid will return it's second input only if the value of the first input is 0. So the uppermost VM functoid will return its second input (the string "Ordered", which you can't see) if the value in QuantityOrdered is > 0, and that is mapped into GlobalQuantityTypeCode. The second VM functoid will return its second input (QuantityOrdered) if QuantityOrdered is > 0, and that value is mapped into ProductQuantity.
And Here's a sample of the input XML:
Notice in the Visual Studio output window above that there is an error. This occurred when I tried to test the map you see above. The warning immediately below the error reads in full: "The destination node "GlobalOrderQuantityTypeCode" has multiple inputs but none of its ancestors is connected to a looping functoid."
This error can be easily remedied by adding a looping functoid, which can be found in the Toolbox under Advanced Functoids:

In the image above, you can see that I have added a purple functoid (the Looping functoid) that connects the LineItem node in the source schema with the Product node in the destination schema. But there's still an error. What I've done in effect is to tell BizTalk, for every LineItem in node in a source document, create a Product node in the output document. But I'm going to have to also account for the fact that within 1 Product node in the output, there are possibly multiple OrderStatusQuantity nodes.
Here's another attempt:

I have put another Looping functoid on the map, and connected the QuantityOrdered and QuantityShipped node outputs to it. What does this do? Essentially, it says that whenever you have an input node, create another OrderStatusQuantity node. Well if I'm so clever, why am I still getting an error? Because other functoids that I've explained above say to only create the nodes under OrderStatusQuantity node if the source value is greater than 0. QuantityShipped in the 3rd LineItem in the sample XML is 0, so I'm essentially telling BizTalk to create an OrderStatusQuantity node, but don't create its children. Since the children are required in the schema, I get an error.
Let's try one more time:

Finally! If you look closely at the map, you can see that I've drawn lines from the GT functoids to the OrderStatusQuantity node. This shows a very useful property of logical functoids. If you map the output of a logical functoid to a node, it will act to suppress the production of that node when the output of the logical functoid is false. So the OrderStatusQuantity node will be created if and only if the QuantityOrdered or the QuantityShipped field contains a value greater than 0.
Here's the XML output. Note that in the last Product node, there is only one OrderStatusQuantity:
Along the way I'll also show how a value mapping functoid works.
I have created 2 schemas intended to represent the status of a previously sent purchase order. POS.xsd is the output from a Line of Business (LOB) application, and PO_Status is intended to be sent to the customer. The LineItem node in POS.xsd and the Product node in POStatus.xsd both repeat 1 to unbounded times. Here's how the map looks:

The red functoid is a String Concatenate functoid, which has 3 inputs - ShipperName, a constant " - ", and ServiceLevel. The DateShipped element is mapped straight across, or "as is".
The turquoise functoids are Greater Than (GT) functoids. The first input you can see on the screen for the upper GT functoid is the QuantityOrdered element, and the second input is "0". This functoid will return true if the value in QuantityOrdered is more than 0. The output of this functoid is mapped into 2 Value Mapping (VM) functoids. A value mapping functoid will return it's second input only if the value of the first input is 0. So the uppermost VM functoid will return its second input (the string "Ordered", which you can't see) if the value in QuantityOrdered is > 0, and that is mapped into GlobalQuantityTypeCode. The second VM functoid will return its second input (QuantityOrdered) if QuantityOrdered is > 0, and that value is mapped into ProductQuantity.
And Here's a sample of the input XML:
<ns0:PurchaseOrderStatus xmlns:ns0="http://Test.POS">
<ShipperName>UPS</ShipperName>
<ServiceLevel>2nd Day</ServiceLevel>
<DateShipped>05/17/2005</DateShipped>
<LineItem>
<ItemNumber>X-12</ItemNumber>
<QuantityOrdered>10</QuantityOrdered>
<QuantityShipped>5</QuantityShipped>
<QuantityBackordered>5</QuantityBackordered>
<QuantityCancelled>0</QuantityCancelled>
</LineItem>
<LineItem>
<ItemNumber>A-24-P</ItemNumber>
<QuantityOrdered>200</QuantityOrdered>
<QuantityShipped>200</QuantityShipped>
<QuantityBackordered>0</QuantityBackordered>
<QuantityCancelled>0</QuantityCancelled>
</LineItem>
<LineItem>
<ItemNumber>T-707F</ItemNumber>
<QuantityOrdered>12</QuantityOrdered>
<QuantityShipped>0</QuantityShipped>
<QuantityBackordered>6</QuantityBackordered>
<QuantityCancelled>6</QuantityCancelled>
</LineItem>
</ns0:PurchaseOrderStatus>
Notice in the Visual Studio output window above that there is an error. This occurred when I tried to test the map you see above. The warning immediately below the error reads in full: "The destination node "GlobalOrderQuantityTypeCode" has multiple inputs but none of its ancestors is connected to a looping functoid."
This error can be easily remedied by adding a looping functoid, which can be found in the Toolbox under Advanced Functoids:

In the image above, you can see that I have added a purple functoid (the Looping functoid) that connects the LineItem node in the source schema with the Product node in the destination schema. But there's still an error. What I've done in effect is to tell BizTalk, for every LineItem in node in a source document, create a Product node in the output document. But I'm going to have to also account for the fact that within 1 Product node in the output, there are possibly multiple OrderStatusQuantity nodes.
Here's another attempt:

I have put another Looping functoid on the map, and connected the QuantityOrdered and QuantityShipped node outputs to it. What does this do? Essentially, it says that whenever you have an input node, create another OrderStatusQuantity node. Well if I'm so clever, why am I still getting an error? Because other functoids that I've explained above say to only create the nodes under OrderStatusQuantity node if the source value is greater than 0. QuantityShipped in the 3rd LineItem in the sample XML is 0, so I'm essentially telling BizTalk to create an OrderStatusQuantity node, but don't create its children. Since the children are required in the schema, I get an error.
Let's try one more time:

Finally! If you look closely at the map, you can see that I've drawn lines from the GT functoids to the OrderStatusQuantity node. This shows a very useful property of logical functoids. If you map the output of a logical functoid to a node, it will act to suppress the production of that node when the output of the logical functoid is false. So the OrderStatusQuantity node will be created if and only if the QuantityOrdered or the QuantityShipped field contains a value greater than 0.
Here's the XML output. Note that in the last Product node, there is only one OrderStatusQuantity:
<ns0:PO_Status xmlns:ns0="http://Test.POStatusOut">
<ShipDate>05/17/2005</ShipDate>
<ShippedVia>UPS - 2nd Day</ShippedVia>
<Product>
<ProductIdentifier>X-12</ProductIdentifier>
<OrderStatusQuantity>
<GlobalOrderQuantityTypeCode>Ordered</GlobalOrderQuantityTypeCode>
<ProductQuantity>10</ProductQuantity>
</OrderStatusQuantity>
<OrderStatusQuantity>
<GlobalOrderQuantityTypeCode>Shipped</GlobalOrderQuantityTypeCode>
<ProductQuantity>5</ProductQuantity>
</OrderStatusQuantity>
</Product>
<Product>
<ProductIdentifier>A-24-P</ProductIdentifier>
<OrderStatusQuantity>
<GlobalOrderQuantityTypeCode>Ordered</GlobalOrderQuantityTypeCode>
<ProductQuantity>200</ProductQuantity>
</OrderStatusQuantity>
<OrderStatusQuantity>
<GlobalOrderQuantityTypeCode>Shipped</GlobalOrderQuantityTypeCode>
<ProductQuantity>200</ProductQuantity>
</OrderStatusQuantity>
</Product>
<Product>
<ProductIdentifier>T-707F</ProductIdentifier>
<OrderStatusQuantity>
<GlobalOrderQuantityTypeCode>Ordered</GlobalOrderQuantityTypeCode>
<ProductQuantity>12</ProductQuantity>
</OrderStatusQuantity>
</Product>
</nso:PO_Status>
Saturday, February 04, 2006
What's My Blog?
I've been reflecting on "what my blog is about". I used to reflect on my life in the same way, but never came to a definite conclusion. So I'm narrowing the focus of my question to just the blog.
:-)
My intention is to write about some technical items that should be easy, but weren't necessarily (at least to me). A lot of what I write might look like it's for beginners, but if it took more than a little research to find it, I think it's worth writing down.
Hopefully you'll either agree, or read someone else's blog.
;-)
:-)
My intention is to write about some technical items that should be easy, but weren't necessarily (at least to me). A lot of what I write might look like it's for beginners, but if it took more than a little research to find it, I think it's worth writing down.
Hopefully you'll either agree, or read someone else's blog.
;-)
Thursday, February 02, 2006
BizTalk 2006 SMTP Adapter
I found a couple of great articles on using the SMTP adapter on Richard Seroter's blog here, and Tomas Restrepo's blog here. What follows are a couple of things that I had to find elsewhere.
For the following examples, I assume you've already created 2 multipart messages EmailIn and EmailOut, each with a body part and an attachment part called Remainder. EmailIn has been used to receive an email using the POP3 adapter (see my previous post), and EmailOut is for sending an email out via SMTP. I also assume that you've at least partly built the EmailOut message, see the 2 links above if you don't know how.
To set the filename for the attachment:
EmailOut.Remainder(MIME.FileName) = "MySpecialTitle.XML";
To set the subject of the outgoing email from the incoming email:
EmailOut(SMTP.Subject) = EmailIn(POP3.Subject);
By the way, these need to be done in a constructor for EmailOut.
To send your email to an address that is to be configured at run-time, assuming that you've managed to get the correct address into the variable emailAddress:
For the following examples, I assume you've already created 2 multipart messages EmailIn and EmailOut, each with a body part and an attachment part called Remainder. EmailIn has been used to receive an email using the POP3 adapter (see my previous post), and EmailOut is for sending an email out via SMTP. I also assume that you've at least partly built the EmailOut message, see the 2 links above if you don't know how.
To set the filename for the attachment:
EmailOut.Remainder(MIME.FileName) = "MySpecialTitle.XML";
To set the subject of the outgoing email from the incoming email:
EmailOut(SMTP.Subject) = EmailIn(POP3.Subject);
By the way, these need to be done in a constructor for EmailOut.
To send your email to an address that is to be configured at run-time, assuming that you've managed to get the correct address into the variable emailAddress:
- Creating a dyamic port
- Create an expression shape
- Enter code that looks like this in the expression shape:
DynamicPort(Microsoft.XLANGs.BaseTypes.Address) = "mailto:" + emailAddress;
It took me a while to figure out how this could work, my guess is that the "mailto:" prefix somehow indicates to BizTalk that it should use SMTP for that port, just as http tells your browser to use port 80.
Hopefully you can extrapolate other things that you might need from the links and these examples.
Subscribe to:
Posts (Atom)