프로젝트에 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내 서비스 참조 설정 :이이
비누 코드를 필요한 경우?
/// <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();
}
}
솔루션 설치 :
TFS, git 또는 svn과 같은 sourcontrol이 있습니까? 또는 두 앱 중 원본 소스 코드 사본을 가져 왔습니까? – Kyle
@Kyle 미안 왜 이것이 중요한지 모르십니까? 하지만 SOAP을 직접 만들었습니다. 첫 번째 게시물의 "솔루션 설정". – Androme
SOAP 서비스 프록시가 참조를 마지막으로 업데이트 할 때 "SoapDocumentMethod.SoapParameterStyle"을 Bare에서 Wrapped로 전환했습니다. –