2013-11-23 2 views
0

프로젝트에 SOAP 서비스 참조가 2 개 있습니다. 잠시 동안 제대로 작동했지만 오늘은 내 서비스에서 "업데이트 서비스 참조"를 수행했습니다. 그들에게 업데이 트하십시오. 하지만 이제는 메소드의 데이터 구조가 많이 변경되었으므로 변경 방법을 알 수 없습니다..net 서비스에서 SOAP 서비스로 참조하십시오.

"bookFlight"에 대한 예제에서는 BookModel 인수를 사용합니다. 내가 간단하게는 SOAP를 호출 다음해야 할 일을했을 전에

public class BookModel 
{ 
    /// <summary> 
    /// Id 
    /// </summary> 
    public int Id { get; set; } 
    /// <summary> 
    /// Credit card informaiton 
    /// </summary> 
    public CreditCardInfoModel CreditCard { get; set; } 
} 

mySoapClient.bookFlight(new BookModel() { ... }); 

을 methoid하지만 난 내 서비스를 업데이트 한 후 나는 이제 다음과 같이 호출해야합니까 :

mySoapClient.bookFlight(new bookFlightRequest() 
{ 
    Body = new bookFlightRequestBody(new BookModel() 
    { 
     ... 
    }) 
}); 

첫 번째 예제의 원래 데이터 구조로 되돌리려면 어떻게해야합니까?

비누

는 여기에서 찾을 수 있습니다 : http://02267.dtu.sogaard.us/LameDuck.asmx

내 서비스 참조 설정 :이이 enter image description here

비누 코드를 필요한 경우?

/// <summary> 
    /// Summary description for LameDuck 
    /// </summary> 
    [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" 
      }; 
     } 

     /// <summary> 
     /// Book a flight 
     /// </summary> 
     /// <param name="model">Booking data</param> 
     /// <exception cref="FlightNotFoundException">If the flight was not found</exception> 
     /// <exception cref="CreditCardValidationFailedException">Credit card validation failed</exception> 
     /// <exception cref="CreditCardChargeFailedException">Charging the credit card failed</exception> 
     /// <returns>True or exception</returns> 
     [WebMethod] 
     public bool bookFlight(BookModel model) 
     { 
      var flight = context.Flights.Where(x => 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; 
     } 

     /// <summary> 
     /// Search for flights 
     /// </summary> 
     /// <param name="model">Search data</param> 
     /// <returns>List of flights, may be empty</returns> 
     [WebMethod] 
     public List<Flight> getFlights(SearchFlightModel model) 
     { 
      var select = context.Flights.Select(x => x); 

      if (model.DestinationLocation != null) 
       select = select.Where(x => x.Info.DestinationLocation == model.DestinationLocation); 
      if (model.DepartureLocation != null) 
       select = select.Where(x => x.Info.DepartureLocation == model.DepartureLocation); 
      if (model.Date != null) 
       select = select.Where(x => x.Info.DepartueTime.Date == model.Date.Date); 

      return select.ToList(); 
     } 

     /// <summary> 
     /// Cancel a flight 
     /// </summary> 
     /// <param name="model">Cancel data</param> 
     /// <exception cref="FlightNotFoundException">If the flight was not found</exception> 
     /// <exception cref="UnableToRefundException">If unable to refund the flight to the credit card</exception> 
     /// <returns>True or exception</returns> 
     [WebMethod] 
     public bool cancelFlight(CancelModel model) 
     { 
      var flight = context.Flights.Where(x => 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; 
     } 

     /// <summary> 
     /// Get a flight by id 
     /// </summary> 
     /// <param name="id">flight id</param> 
     /// <exception cref="FlightNotFoundException">If the flight was not found</exception> 
     /// <returns>The flight</returns> 
     [WebMethod] 
     public Flight getFlight(int id) 
     { 
      var flight = context.Flights.Where(x => x.Id == id).FirstOrDefault(); 
      if (flight == null) 
       throw new FlightNotFoundException(id.ToString()); 
      return flight; 
     } 

     /// <summary> 
     /// Reset the database 
     /// 
     /// This is only to be used for testing 
     /// </summary> 
     [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(); 
     } 
    } 

솔루션 설치 : enter image description here

+0

TFS, git 또는 svn과 같은 sourcontrol이 있습니까? 또는 두 앱 중 원본 소스 코드 사본을 가져 왔습니까? – Kyle

+0

@Kyle 미안 왜 이것이 중요한지 모르십니까? 하지만 SOAP을 직접 만들었습니다. 첫 번째 게시물의 "솔루션 설정". – Androme

+0

SOAP 서비스 프록시가 참조를 마지막으로 업데이트 할 때 "SoapDocumentMethod.SoapParameterStyle"을 Bare에서 Wrapped로 전환했습니다. –

답변

0

이 .asmx는 (은 Microsoft 기술 스택에) 기존 웹 서비스입니다. Visual Studio를 통해 레거시 웹 서비스에 서비스 참조를 추가 할 때 서비스 참조 설정 대화 상자에서 "고급"단추를 클릭 한 다음 "웹 참조 추가 ..."단추를 클릭하여 추가 할 수 있습니다. 이 갑자기 필요한 이유

enter image description here

enter image description here

는 잘 모르겠지만, 내 머리 위로 떨어져 몇 가지 후드 아래에있는 프록시를 생성하는 코드가 가장 가능성이 높다고 있습니다 .ASMX와 WCF는 다릅니다. 또 다른 옵션은 바인딩을 변경 한 경우입니다 (사용자 지정 바인딩을 사용하지 않는 한 basicHttpBinding이 .ASMX - SOAP 1.1을 지원하는 유일한 방법이라고 생각합니다).

관련 문제