Looping Message in Orchestration BTS 2006

Home Page Forums BizTalk 2004 – BizTalk 2010 Looping Message in Orchestration BTS 2006

Viewing 1 reply thread
  • Author
    Posts
    • #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>

    • #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.

       http://www.biztalkgurus.com/blogs/biztalk/archive/2005/07/12/XPath-Debatching-and-Envelope-Debatching-Biztalk-Lab.aspx

       

       

      • #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&#039; and namespace-uri()='http://tempuri.org'%5D/*%5Blocal-name()='Materialposition&#039; and namespace-uri()='http://tempuri.org'%5D%5B{0}]/*[local-name()='MaterialNr' and namespace-uri()='http://tempuri.org'%5D&quot;,zaehler);
        sXPathOut = System.String.Format("//*[local-name()='MaterialNr' and namespace-uri()='http://tempuri.org'%5D&quot;);
        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

      • #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
         

         

         

      • #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

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.