我正在编写一项服务,它会自动取消留在某个队列上的 PNR。对于 OTA_CancelLLSRQ 请求,这听起来很简单,但是看来我必须单独遍历每个段,或者有没有办法可以一次取消所有段?
在应用程序中,我们定义了一个 PNR 类,该类包含我们可以通过“”调用获得的所有信息。
要取消 PNR,我目前使用以下代码:
MessageHeader msgHeader = new MessageHeader
{
ConversationId = "TestSession",
CPAId = licenseId,
Action = "OTA_CancelLLSRQ",
Service = new Service { Value = "OTA_CancelLLSRQ" },
MessageData = new MessageData
{
MessageId = "xxx",
Timestamp = DateTime.UtcNow.ToString("s") + "Z"
},
From = new From()
{
PartyId = new PartyId[]
{
new PartyId { Value = "WebServiceClient"}
}
},
To = new To()
{
PartyId = new[]
{
new PartyId { Value = "WebServiceSupplier"}
}
}
};
var segmentList = new List<OTA_CancelRQSegment>();
foreach (var segment in pnrObject.Segments)
{
var requestSegment = new OTA_CancelRQSegment
{
Number = segment.SegmentNumber.ToString()
};
segmentList.Add(requestSegment);
}
var request = new OTA_CancelRQ()
{
Version = "2.0.0",
TimeStamp = DateTime.UtcNow,
TimeStampSpecified = true,
Segment = segmentList.ToArray()
};
OTA_CancelRS response = null;
Policy.Handle<SoapException>()
.Or<WebException>()
.WaitAndRetry(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1)
})
.Execute(() =>
{
using (OTA_CancelService serviceObj = new OTA_CancelService())
{
serviceObj.MessageHeaderValue = msgHeader;
serviceObj.Security = new Security1 { BinarySecurityToken = token };
response = serviceObj.OTA_CancelRQ(request);
}
});
它编译和构建,但我还没有测试它。:-)
在文档中,我发现了以下请求:
<OTA_CancelRQ Version="2.0.0">
<Segment Type="entire"/>
</OTA_CancelRQ>
如何使用 web 服务期望的对象模型对此进行编码?