svcutil.exe client code question – trying to assign objects to collection.

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › svcutil.exe client code question – trying to assign objects to collection.

Viewing 1 reply thread
  • Author
    Posts
    • #23432

      I have exposed a BT orchestration as a WCF Service and I have run svcutil.exe to create the client code.  Here is a snippet of the my code and the generated client code  (I have removed decorations etc) …

      My test code …

      Console.WriteLine(“Enter value to be sent to the BizTalk orchestration exposed as a WCF service:”);
      string name = Console.ReadLine();
      MaterialEstimateAuthorization_OrchMaterialEstimate_Port_1Client client = new MaterialEstimateAuthorization_OrchMaterialEstimate_Port_1Client();
      materialEstimate matEstimate = new materialEstimate();matEstimate.workOrderID = “456”;
      materialEstimateLocationMaterialContent matContent = new materialEstimateLocationMaterialContent();
      matContent.assemblyUnit =
      “1”;
      matContent.LID =
      “2”;
      matContent.quantity = 3;
      matContent.siteID =
      “4”;
      matContent.status =
      “A”;

      matEstimate.LocationMaterialContent[0] = matContent; 

      //or

      matEstimate.LocationMaterialContent.setValue(matContent,0); 

      // How do I assign the instantiated objects of materialEstimateLocationMaterialContent to the collection 
      // materialEstimateLocationMaterialContent[] collection which is member of the instantiated materialEstimate object?  I keep getting a null 
      // reference error stating that  “Object reference not set to an instance of an object”.  Any help would be greatly appreaciated, thanks.
       
      RootOutMaterialEstimate outDoc;
      outDoc = client.Operation_1(matEstimate);
      Console.WriteLine(“Value returned from the WCF service:”);
      Console.WriteLine(outDoc.Resp);
      client.Close();

      Code generated from svcutil.exe ….

      public partial class materialEstimate
      {
          private string workOrderIDField;
          private materialEstimateLocationMaterialContent[] locationMaterialContentField;
          public string workOrderID
          {
              get
              {
                  return this.workOrderIDField;
              }
              set
              {
                  this.workOrderIDField = value;
              }
          }
         
          public materialEstimateLocationMaterialContent[] LocationMaterialContent
          {
              get
              {
                  return this.locationMaterialContentField;
              }
              set
              {
                  this.locationMaterialContentField = value;
              }
          }
      }

      public partial class materialEstimateLocationMaterialContent
      {
         
          private string lIDField;
          private string siteIDField;
          private byte quantityField;
          private string statusField;
          private string assemblyUnitField;

          public string LID
          {
              get
              {
                  return this.lIDField;
              }
              set
              {
                  this.lIDField = value;
              }
          }
         
          /// <remarks/>
          [System.Xml.Serialization.XmlElementAttribute(Order=1)]
          public string siteID
          {
              get
              {
                  return this.siteIDField;
              }
              set
              {
                  this.siteIDField = value;
              }
          }
         
          /// <remarks/>
          [System.Xml.Serialization.XmlElementAttribute(Order=2)]
          public byte quantity
          {
              get
              {
                  return this.quantityField;
              }
              set
              {
                  this.quantityField = value;
              }
          }
         
          /// <remarks/>
          [System.Xml.Serialization.XmlElementAttribute(Order=3)]
          public string status
          {
              get
              {
                  return this.statusField;
              }
              set
              {
                  this.statusField = value;
              }
          }
         
          /// <remarks/>
          public string assemblyUnit
          {
              get
              {
                  return this.assemblyUnitField;
              }
              set
              {
                  this.assemblyUnitField = value;
              }
          }
      }

      }

    • #23435

      Greg Forsythe from social.microsoft.com answered my question …

      matEstimate.LocationMaterialContent =

      new materialEstimateLocationMaterialContent[100];

      matEstimate.LocationMaterialContent[0] = matContent;

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