Expression Editor

Home Page Forums BizTalk 2004 – BizTalk 2010 Expression Editor

Viewing 2 reply threads
  • Author
    Posts
    • #20261

      I have put an expression in a transaction and the following code is residing in the expression editor..

      string filename=”c:\\employee.xml”;
      XmlTextWriter tw=new XmlTextWriter(filename,null);//null represents
      the Encoding Type//
      tw.Formatting=Formatting.Indented;  //for xml tags to be indented//
      tw.WriteStartDocument();   //Indicates the starting of document
      (Required)//
      tw.WriteStartElement(“Employees”);            
      tw.WriteStartElement(“Employee”,”Genius”);
      tw.WriteAttributeString(“Name”,”Allan”);
      tw.WriteElementString(“Designation”,”Software Developer”);
      tw.WriteElementString(“FullName”,”Allan Donald”);
      tw.WriteEndElement();
      tw.WriteEndElement();
      tw.WriteEndDocument();            
      tw.Flush();
      tw.Close();

      but I am getting an error “identifier ‘filename’ does not exist in ‘Transaction_2’;are you missing an assembly reference?”

      Please help

      Cheers

      Sri

    • #20262

      Sri,

      You have to have an orchestration variable called filename to all you to use vars in the expression window. Furthermore, if you are trying to access it inside a scope (your ‘Transaction_2’), the variable will need to be created inside the scope, rather than the ‘outer’ orchestration.

      Because the variable is already declared in the orchestration/scope, you can then use it as:

      filename = “c:\\employee.xml”;

      However, I have to question why you are writing an Xml file from within an expression shape? Use a Send Port with the FILE adapter and get all of the sexy enterprise features that you won’t have with your block of code, such as retries, suspended messages, transactional support etc.

      If you need clarification on any of the above, drop me a line.

      Cheers, Nick.

      • #20277

        Hi Nick,

        thanks for the quick response but my requirement is as such that SAP would my Biztalk Schema Exposed as a Webservice and I need to pass this value to another webservice…I explained this to you before and you asked me to use the maping at both send and receive ports but I said I cannot as I need to have exception handling(the query was asked as an anonymous user).

        So I am trying to use Expression shape to put in the Header and footer using C# code..as such I need to something to work with the envelopes but along with the exception handlers.And secondly I need the XML string from first WS to be passed to another webservice as XML string.Hoping for an answer ASAP

        Cheers

        Sri.

         

         

        • #20279

          Sri,

          The BizTalk schema exposed as a web-service that is being consumed by SAP will appear as a typed Xml Message within your orchestration. You can map this message to the format of the request message for the next web-service in the chain, using the map to create your header and footer – there is no need to do this in XLANGs in an expression shape.

          If the web-service that you are consuming requires a string to be passed in the request message (and not a typed message), you can load the result of the map (above) into an XmlDocument object and use the .OuterXml() method to get the Xml as a string, passing this to the web-service.

          HTH, Nick.

          • #20345

             Hi Nick,

            Yes the webservice that I am consuming is taking a string in the request message.But there is a catch here that the request msg(say has 5 fileds) has to go into one field of the webservice being Consumed.Please find attached the mapper that I am trying to explain

             

            • #20346

               Sorry Nick,I am not bale to attach the mapper screen shot.

               

              Mapper

    • #20265

      The expression shape contains XLANG code, not C# code.

      You need to declare filename as an orchestration variable of type System.String, probably the same for the XmlTextWriter.

      An alternative approach is to put this code into an external C# class library and call that from the expression shape

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