How to call a helper methods in Message Assignment shape with .net classes generated from web services. RRS feed

  • Question

  • First, I'm new to biztalk (we are still evaluating it).

    Here is the scenario:

    We have a legacy asmx web services which look like :

    using System.Web.Services;
    namespace WebServices
      [WebService (Namespace = "http://tempuri.org/")]
      [WebServiceBinding (ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem (false)]
      public class TextFormater : System.Web.Services.WebService
       public string Format (string prefix, string schools)
         return prefix + ":" + schools;

    I want to invoke it from a request like this :

    <ns0:Format xmlns:ns0="http://Biztalk.Request">
     <Prefix>Those schools : </Prefix>
      <School Id="1" Name="School name from 1" />
      <School Id="15" Name="Bermon High School" />

    I want to concat the prefix with all schools names, seperated by a ", ", to return a response like this:

    <ns0:FormatedSchool xmlns:ns0="http://Biztalk.Response">
     <Text>Those schools : School name from 1, Bermon High School</Text>

    So, in my biztalk project, I created :

    • Request.xsd
    • Response.xsd
    • SchoolFormaterOrchestration.odx
    • Added an Web References to my web service (Add Service Reference > Advanced > Add Web Reference)

    I didn't use any map since the web services only have primitive types, so I don't have and xsd for the web services generated. So I use Message Assignment shape to invoke the web service port (based on the generated Web Port Type).

    Getting the value back from the web service is pretty straight forward, in my assignment shape I have :

    xmlDocumentBuffer.LoadXml (@"<ns0:FormatedSchool xmlns:ns0=""http://Biztalk.Response"">
    msgCustomerResponse = xmlDocumentBuffer;
    msgCustomerResponse.Text = msgWsResponse.FormatResult;

    (xmlDocumentBuffer is a XmlDocument variable defined in the orchestration)

    But, to make the message to invoke the webservice, I have some troubles. I tryied to do something like this in an message assignement shape :

    msgWsRequest.schools = helper.ConcatSchools (msgCustomerRequest.Schools);

    where helper is a variable in the orchestration of this .Net class defined in a helper project :

    namespace Helpers
      public class MyHelper
       public string ConcatSchools (object schools)
         throw new NotImplementedException ("Should concat schools");

    But i just can't see how to receive the school part in my helper concat values. I get this exception in my message assignment shape when trying to invoke the helper method:

    argument '1': cannot convert from 'Biztalk.Request.Schools' to 'System.Object'

    So, what is the way to receive message part parameters in helper methods from biztalk?

    Thursday, February 17, 2011 4:50 PM


  • You main problem is your web service only accepts two strings prefix and schools, so you need to concatenate you schools string in your orchestration or change your web service:

       public string Format (string prefix, string[] schools)
         return string.Concat(prefix, string.Concat(schools));

    Thursday, February 17, 2011 10:09 PM