Вот структура запроса:
Код: Выделить всё
SOAP_ODE
123456
?
?
SendPinRequest.cs:
Код: Выделить всё
using System.Runtime.Serialization;
namespace OnlineDataExchange
{
[DataContract]
public class SendPinRequest
{
[DataMember(Order = 1, IsRequired = true)]
public string TransactionID { get; set; }
[DataMember(Order = 2, IsRequired = true)]
public string MSISDN { get; set; }
}
}
Код: Выделить всё
using System.ServiceModel;
using System.Threading.Tasks;
namespace OnlineDataExchange.Contracts
{
[ServiceContract]
public interface IPinService
{
[OperationContract]
Task SendPin(SendPinRequest request);
}
}
Код: Выделить всё
using OnlineDataExchange.Contracts;
using SoapCore;
namespace OnlineDataExchange.Services
{
public class PinService : IPinService
{
private readonly IConfiguration _configuration;
public PinService(IConfiguration configuration)
{
_configuration = configuration;
}
public async Task SendPin(SendPinRequest request)
{
string resp_code = "00";
???? // Here I want to retreive the username and password from the SOAP Header
if (request == null) throw new ArgumentNullException(nameof(request));
// Check MSISDN
if (resp_code == "00") resp_code = ValidationUtils.ValidateMSISDN(request.MSISDN);
// Check Password
if (resp_code == "00") resp_code = ValidationUtils.ValidatePassword(password);
// Check credentials
Authentication au = new Authentication(_configuration);
if (resp_code == "00") resp_code = au.AuthenticateUser(username, password);
return new SendPinResponse
{
TransactionID = request.TransactionID,
ResponseCode = resp_code,
ResponseText = ResponseCodes.ResponsesDictionary[resp_code],
MSISDN = request.MSISDN
};
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... nd-soap-ui