title: SOAP Service as Service reference in .net
body: <p>I have 2 SOAP Service References in my project, and it have been working nicely for a while, but today i did an "Update Service Refrence" on both my services as i had done an update to them.
  But now the datastructure of the methods have change alot, and i can not figure out how to change it back.</p>
  
  <p>On of my methods "bookFlight" for an example take the argument BookModel.</p>
  
  <pre><code>public class BookModel
  {
      /// &lt;summary&gt;
      /// Id
      /// &lt;/summary&gt;
      public int Id { get; set; }
      /// &lt;summary&gt;
      /// Credit card informaiton
      /// &lt;/summary&gt;
      public CreditCardInfoModel CreditCard { get; set; }
  }
  </code></pre>
  
  <p>Before i simply had to do the following to call the SOAP methoid</p>
  
  <pre><code>mySoapClient.bookFlight(new BookModel() { ... });
  </code></pre>
  
  <p>But after i have updated my service do i now have to call it like the following:</p>
  
  <pre><code>mySoapClient.bookFlight(new bookFlightRequest()
  {
      Body = new bookFlightRequestBody(new BookModel()
      {
          ...
      })
  });
  </code></pre>
  
  <p>What can i do to get it back to the orginal data structue from the first example?</p>
  
  <p>The soap can be found here: <a href="http://02267.dtu.sogaard.us/LameDuck.asmx" rel="nofollow noreferrer">http://02267.dtu.sogaard.us/LameDuck.asmx</a></p>
  
  <p>My Service Reference Settings: <img src="https://i.stack.imgur.com/K6nIJ.png" alt="enter image description here"></p>
  
  <p>The SOAP code if that is needed?</p>
  
  <pre><code>/// &lt;summary&gt;
      /// Summary description for LameDuck
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://02267.dtu.sogaard.us/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      // [System.Web.Script.Services.ScriptService]
      public class LameDuck : System.Web.Services.WebService
      {
          private Context context;
          private BankPortTypeClient bankService;
          private int groupNumber;
          private accountType account;
  
          public LameDuck()
          {
              context = new Context();
              bankService = new BankPortTypeClient();
              groupNumber = int.Parse(WebConfigurationManager.AppSettings["GroupNumber"]);
              account = new accountType()
              {
                  number = "50208812",
                  name = "LameDuck"
              };
          }
  
          /// &lt;summary&gt;
          /// Book a flight
          /// &lt;/summary&gt;
          /// &lt;param name="model"&gt;Booking data&lt;/param&gt;
          /// &lt;exception cref="FlightNotFoundException"&gt;If the flight was not found&lt;/exception&gt;
          /// &lt;exception cref="CreditCardValidationFailedException"&gt;Credit card validation failed&lt;/exception&gt;
          /// &lt;exception cref="CreditCardChargeFailedException"&gt;Charging the credit card failed&lt;/exception&gt;
          /// &lt;returns&gt;True or exception&lt;/returns&gt;
          [WebMethod]
          public bool bookFlight(BookModel model)
          {
              var flight = context.Flights.Where(x =&gt; x.Id == model.Id).FirstOrDefault();
              if (flight == null)
                  throw new FlightNotFoundException(model.Id.ToString());
  
              if (!bankService.validateCreditCard(groupNumber, new creditCardInfoType()
                                  {
                                      name = model.CreditCard.Name,
                                      number = model.CreditCard.Number,
                                      expirationDate = new expirationDateType()
                                      {
                                          year = model.CreditCard.ExpirationDate.Year,
                                          month = model.CreditCard.ExpirationDate.Month
                                      }
                                  }, flight.Price))
                  throw new CreditCardValidationFailedException();
  
              if (!bankService.chargeCreditCard(groupNumber, new creditCardInfoType()
                                  {
                                      name = model.CreditCard.Name,
                                      number = model.CreditCard.Number,
                                      expirationDate = new expirationDateType()
                                      {
                                          year = model.CreditCard.ExpirationDate.Year,
                                          month = model.CreditCard.ExpirationDate.Month
                                      }
                                  }, flight.Price, account))
                  throw new CreditCardChargeFailedException();
  
              return true;
          }
  
          /// &lt;summary&gt;
          /// Search for flights
          /// &lt;/summary&gt;
          /// &lt;param name="model"&gt;Search data&lt;/param&gt;
          /// &lt;returns&gt;List of flights, may be empty&lt;/returns&gt;
          [WebMethod]
          public List&lt;Flight&gt; getFlights(SearchFlightModel model)
          {
              var select = context.Flights.Select(x =&gt; x);
  
              if (model.DestinationLocation != null)
                  select = select.Where(x =&gt; x.Info.DestinationLocation == model.DestinationLocation);
              if (model.DepartureLocation != null)
                  select = select.Where(x =&gt; x.Info.DepartureLocation == model.DepartureLocation);
              if (model.Date != null)
                  select = select.Where(x =&gt; x.Info.DepartueTime.Date == model.Date.Date);
  
              return select.ToList();
          }
  
          /// &lt;summary&gt;
          /// Cancel a flight
          /// &lt;/summary&gt;
          /// &lt;param name="model"&gt;Cancel data&lt;/param&gt;
          /// &lt;exception cref="FlightNotFoundException"&gt;If the flight was not found&lt;/exception&gt;
          /// &lt;exception cref="UnableToRefundException"&gt;If unable to refund the flight to the credit card&lt;/exception&gt;
          /// &lt;returns&gt;True or exception&lt;/returns&gt;
          [WebMethod]
          public bool cancelFlight(CancelModel model)
          {
              var flight = context.Flights.Where(x =&gt; x.Id == model.Id).FirstOrDefault();
              if (flight == null)
                  throw new FlightNotFoundException(model.Id.ToString());
  
              if (!bankService.refundCreditCard(groupNumber, new creditCardInfoType()
                                  {
                                      name = model.CreditCard.Name,
                                      number = model.CreditCard.Number,
                                      expirationDate = new expirationDateType()
                                      {
                                          year = model.CreditCard.ExpirationDate.Year,
                                          month = model.CreditCard.ExpirationDate.Month
                                      }
                                  }, flight.Price, account))
                  throw new UnableToRefundException();
  
              return true;
          }
  
          /// &lt;summary&gt;
          /// Get a flight by id
          /// &lt;/summary&gt;
          /// &lt;param name="id"&gt;flight id&lt;/param&gt;
          /// &lt;exception cref="FlightNotFoundException"&gt;If the flight was not found&lt;/exception&gt;
          /// &lt;returns&gt;The flight&lt;/returns&gt;
          [WebMethod]
          public Flight getFlight(int id)
          {
              var flight = context.Flights.Where(x =&gt; x.Id == id).FirstOrDefault();
              if (flight == null)
                  throw new FlightNotFoundException(id.ToString());
              return flight;
          }
  
          /// &lt;summary&gt;
          /// Reset the database
          /// 
          /// This is only to be used for testing
          /// &lt;/summary&gt;
          [WebMethod]
          public void ResetDatabase()
          {
              // Remove all flights
              foreach (var flight in context.Flights)
                  context.Flights.Remove(flight);
              context.SaveChanges();
  
              // Add Flights
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 350,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "DTU",
                      DestinationLocation = "Spain",
                      DepartueTime = DateTime.UtcNow.AddDays(1),
                      ArrivalTime = DateTime.UtcNow.AddDays(1).AddHours(2),
                      Carrier = "Carrier 1"
                  }
              });
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 350,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "Spain",
                      DestinationLocation = "DTU",
                      DepartueTime = DateTime.UtcNow.AddDays(2),
                      ArrivalTime = DateTime.UtcNow.AddDays(2).AddHours(2),
                      Carrier = "Carrier 1"
                  }
              });
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 450,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "DTU",
                      DestinationLocation = "Italy",
                      DepartueTime = DateTime.UtcNow.AddDays(1),
                      ArrivalTime = DateTime.UtcNow.AddDays(1).AddHours(2),
                      Carrier = "Carrier 1"
                  }
              });
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 450,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "Italy",
                      DestinationLocation = "DTU",
                      DepartueTime = DateTime.UtcNow.AddDays(1),
                      ArrivalTime = DateTime.UtcNow.AddDays(1).AddHours(2),
                      Carrier = "Carrier 1"
                  }
              });
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 650,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "DTU",
                      DestinationLocation = "Turkey",
                      DepartueTime = DateTime.UtcNow.AddDays(1),
                      ArrivalTime = DateTime.UtcNow.AddDays(1).AddHours(2),
                      Carrier = "Carrier 2"
                  }
              });
              context.Flights.Add(new Flight()
              {
                  Airline = "DTU Airlines",
                  Price = 650,
                  Info = new FlightInfo()
                  {
                      DepartureLocation = "Turkey",
                      DestinationLocation = "DTU",
                      DepartueTime = DateTime.UtcNow.AddDays(1),
                      ArrivalTime = DateTime.UtcNow.AddDays(1).AddHours(2),
                      Carrier = "Carrier 2"
                  }
              });
              context.SaveChanges();
          }
      }
  </code></pre>
  
  <p>Solution setup:
  <img src="https://i.stack.imgur.com/WHJIw.png" alt="enter image description here"></p>