Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Looping Message in Orchestration BTS 2006
- This topic has 6 replies, 1 voice, and was last updated 9 years, 5 months ago by
community-content.
-
AuthorPosts
-
-
September 22, 2006 at 7:19 AM #15806
Hello,
I'm sorry to asking this question, but I'm running out of time and haven't
found a talk which solved my missunderstanding (yes, Im a newbie..).
Given a invoice message containing at least one material item I want
to loop through the material items in order to do some checking on each
position of the material items. How would I do this in BizTalk? I use the loop shape, ok, but how do I define a counter variable, increment it and
check, if I'm at the end. And how do I reference the values for each material item? I attached a part of the invoice schema (sorry for the german naming
and posting the whole xsd).
Every hint (especially to small tutorials I haven't found until now) would be really appreciated.Thanks a lot in advance, Hansi
targetNamespace="http://tempuri.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Ens_Messagebody" />
– <xs:complexType name="Ens_Request">
– <xs:complexContent mixed="false">
<xs:extension base="tns:Ens_Messagebody" />
</xs:complexContent>
</xs:complexType>
– <xs:complexType name="Dienstleistungsposition">
– <xs:complexContent mixed="false">
– <xs:extension base="tns:Ens_Request">
– <xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Beschreibung" type="xs:string"
/>
<xs:element minOccurs="0" maxOccurs="1" name="Besteller" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Email" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Preis" type="xs:double" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
– <xs:complexType name="Rechnung">
– <xs:complexContent mixed="false">
– <xs:extension base="tns:Ens_Request">
– <xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Anschrift" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Ort" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="PLZ" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Konto" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="BLZ" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Bank" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Rechnungsnummer"
type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Rechnungsdatum"
type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Rechnungstyp" type="xs:string"
/>
<xs:element minOccurs="0" maxOccurs="1" name="BestellNr" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Materialpositionen"
type="tns:ArrayOfMaterialposition" />
<xs:element minOccurs="0" maxOccurs="1" name="Dienstleistungspositionen"
type="tns:ArrayOfDienstleistungsposition" />
<xs:element minOccurs="0" maxOccurs="1" name="Nettobetrag" type="xs:double"
/>
<xs:element minOccurs="0" maxOccurs="1" name="Umsatzsteuer" type="xs:double"
/>
<xs:element minOccurs="0" maxOccurs="1" name="Bruttobetrag" type="xs:double"
/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
– <xs:complexType name="ArrayOfMaterialposition">
– <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Materialposition"
nillable="true" type="tns:Materialposition" />
</xs:sequence>
</xs:complexType>
– <xs:complexType name="Materialposition">
– <xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="MaterialNr" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Materialbezeichnung"
type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="LieferscheinNr"
type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="Preis" type="xs:double" />
<xs:element minOccurs="1" maxOccurs="1" name="Anzahl" type="xs:long" />
</xs:sequence>
</xs:complexType>
– <xs:complexType name="ArrayOfDienstleistungsposition">
– <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="Dienstleistungsposition" nillable="true"
type="tns:Dienstleistungsposition" />
</xs:sequence>
</xs:complexType>
– <xs:element name="Rechnung" nillable="true" type="tns:Rechnung">
– <xs:annotation>
– <xs:appinfo>
– <b:properties xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
<b:property distinguished="true" xpath="/*[local-name()='Rechnung' and
namespace-uri()='http://tempuri.org'%5D/*%5Blocal-name()='Rechnungstyp' and
namespace-uri()='http://tempuri.org']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
-
September 23, 2006 at 9:10 AM #15816
You'd basically use xpath while looping thru the message to extract the data you wish to use. You can also do xpath streaming using the the XPathReader object. Read more here http://martijnh.blogspot.com/2006/03/xpathmutatorstream.html.
Also look at this sample for looping thru messages and extracting out data.
-
September 24, 2006 at 6:59 AM #15820
Hello Bryan,
thanks a lot for your reply. The examples where exactly what I needed. Now I'm trying to set some values from one message to another one (last one being a web-reference).
Unfortunately I always getting this error:'xPath(Requst, sXPathOut)': an xpath expression must be of the form 'xpath(message-part, string-ref)' or 'xpath(string-ref)'
The expression I'm using:
sXPath = System.String.Format("/*[local-name()='Rechnung' and namespace-uri()='http://tempuri.org'%5D/*%5Blocal-name()='Materialpositionen' and namespace-uri()='http://tempuri.org'%5D/*%5Blocal-name()='Materialposition' and namespace-uri()='http://tempuri.org'%5D%5B{0}]/*[local-name()='MaterialNr' and namespace-uri()='http://tempuri.org'%5D",zaehler);
sXPathOut = System.String.Format("//*[local-name()='MaterialNr' and namespace-uri()='http://tempuri.org'%5D");
xpath(RequestPruefeWareneingang,sXPathOut) = xpath(RequestRechnung, "string(sXPath)");I'm not sure what's the story about the xpath-String function for sXPath. Error comes up in the last line by "xpath(", RequestPruefeWareneingang being the Web-Message. The expression shape is in a "construct message"-shape, which should construct this message.
Thank's a lot in advance,
Hansi -
September 24, 2006 at 7:15 AM #15821
First read, than right – sorry, forget about my last post. I'm using a multipart message, RequestPruefeWareneingang.Lieferposition (last one being the part) in the xpath-function seems to work (at least I don't get any error in the expression editor).
As I haven't tested the whole orchestration until now is there anything I should take care of using multipart messages (= web referenced messages)?
Thanks being patient with a newbie,
Hansi
-
September 24, 2006 at 10:31 AM #15822
But of course – the next error. Please can somebody explain me how to
initialize messages..
I use a construct shape in a loop where I construct the Message "Request"
(properties of construct shape = Request). I then have constructed the
message Request and can use it, no??
After the construct shape I use an expression like:sXPath = System.String.Format("/*[local-name()='Mat' and
namespace-uri()='http://tempuri.org'%5D%5B{0}]/*[local-name()='price' and
namespace-uri()='http://tempuri.org']",counter);xpath(Request.Price,"//*[local-name()='Price' and
namespace-uri()='http://tempuri.org']") = xpath(Bill, "string(sXPath)");First term is getting one position of the bill ([{0}] is evaluated to
counter, if I understand this right..) Second term should give the Message part Request.Price
the value of the billed price for one position. So why isn't the Message part not being "initialized
in construct message"??Thanks once again,
Hansi-
September 24, 2006 at 4:30 PM #15823
Hansi,
I'd look at this post for ideas on how to create a message within an orch.
http://www.objectsharp.com/Blogs/matt/archive/2004/11/09/1009.aspx
-
September 25, 2006 at 5:53 PM #15837
Thanks Bryan, slowly (as I am) I get an idea of how messages are being constructed.
Still don't know if my approach I'm using at the moment is right but I will come back.
Hansi
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.