Cancel a complete PNR - sabre

I'm writing a service which automtically cancels a PNR left on a certain queue. This sounds pretty straight forward with the OTA_CancelLLSRQ request, however it appears I have to loop through each segment individually, or is there a way I can cancell ALL segments at once?
In the application we defined a PNR class, this class contains all of the information we can obtain with the "" call.
To cancel the PNR I currently use the following code:
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);
}
});
It compiles & builds, but I haven't gotten around testing it just yet. :-)
In the documentation I found the following request:
<OTA_CancelRQ Version="2.0.0">
<Segment Type="entire"/>
</OTA_CancelRQ>
How do I encode this using the object model the webservice expects?

Steps for cancelling PNR is as follows.
STEP1: SessionCreateRQ
STEP2: TravelItineraryReadRQ
STEP3: OTA_CancelRQ
STEP4: EndTransactionRQ
STEP5: SessionCloseRQ
In case of SOAP SERVICES your request XML for STEP3 (i.e OTA_CancelRQ)will be as follows.
<OTA_CancelRQ EchoToken="String" TimeStamp="2001-12-17T09:30:47-05:00" Target="Production" Version="2003A.TsabreXML1.0.1" SequenceNmbr="1" PrimaryLangID="en-us" AltLangID="en-us" xmlns="http://webservices.sabre.com/sabreXML/2003/07" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<POS>
<Source PseudoCityCode="PCC"/>
</POS>
<TPA_Extensions>
<SegmentCancel Type="Entire">
</SegmentCancel>
</TPA_Extensions>
</OTA_CancelRQ>
I hope this will make your knowledge more clear.

You can specify "entire" type like the below to cancel the entire Itinerary of a PNR.
<OTA_CancelRQ Version="2.0.0">
<Segment Type="entire"/>
</OTA_CancelRQ>

here is the request part of my code in c#, hope this help add a refrence to proxy class for OTA_CancelRQ.
OTA_CancelRQ rq = new OTA_CancelRQ();
List<OTA_CancelRQSegment> segmentCancelList = new List<OTA_CancelRQSegment>();
OTA_CancelRQSegment segmentCancel = new OTA_CancelRQSegment();
OTA_CancelRQSegmentType segmentType = new OTA_CancelRQSegmentType();
segmentType = OTA_CancelRQSegmentType.entire;
segmentCancel.Type = segmentType;
segmentCancel.TypeSpecified = true;
segmentCancelList.Add(segmentCancel);
rq.Segment = segmentCancelList.ToArray();
Thanks.

cancelRQ.tPA_ExtensionsField = new CancelRequest.TPA_Extensions
{
segmentCancelField = new CancelRequest.TPA_Extensions.SegmentCancel
{
typeField = "Entire"
}
};

call OTA_CancelLLSRQ Perform a transaction after the original booking was completed (cancel the itinerary that was booked, in this case).

Related

Set AttributeConsumingService index?

I'am doing an connection to IDP with sustainsys SAML2 with the Saml2AuthenticationModule and Sustainsys.Saml2.HttpModule
Since I want metadata returned I need to set
AttributeConsumingService index from 0(default) to 1.
Tried to find ways to change it without success. Anyone knows how?
<AttributeConsumingService index="0" isDefault="true">
<ServiceName xml:lang="en">SP</ServiceName>
<RequestedAttribute isRequired="true" Name=...
...
You can configure the value in Startup.cs
.AddSaml2("IDP", "IDP", opt =>
{
opt.SPOptions = new Sustainsys.Saml2.Configuration.SPOptions
{
EntityId = new EntityId(ipdUrl),
ReturnUrl = new Uri(webSiteUrl),
ModulePath = string.Format("/saml2/{0}", "idp"),
AuthenticateRequestSigningBehavior = SigningBehavior.Always,
MinIncomingSigningAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
};
RequestedAttribute requestedAttributeEmail = new RequestedAttribute("email");
requestedAttributeEmail.FriendlyName = "Email";
requestedAttributeEmail.NameFormat = RequestedAttribute.AttributeNameFormatBasic;
requestedAttributeEmail.IsRequired = false;
AttributeConsumingService attributeConsumingService = new AttributeConsumingService();
attributeConsumingService.RequestedAttributes.Add(requestedAttributeEmail);
attributeConsumingService.ServiceNames.Add(new LocalizedName("Required attributes", "en"));
attributeConsumingService.IsRequired = true;
attributeConsumingService.Index = 1;
attributeConsumingService.IsDefault = true;
opt.SPOptions.AttributeConsumingServices.Add(attributeConsumingService);
});

How to add conferenceDataVersion to Event using C# using parameters or other way

I am trying to use this but after insert event, the property ConferenceData is null
var pm = new Dictionary<string, string>
{
{"conferenceDataVersion", "1"}
};
calenderEvent.ConferenceData.Parameters = new ConferenceParameters(); calenderEvent.ConferenceData.Parameters.AddOnParameters = new ConferenceParametersAddOnParameters(); calenderEvent.ConferenceData.Parameters.AddOnParameters.Parameters = pm;
You don't need to use the Parameters property in order to set ConferenceDataVersion.
If you just want to add a conference to the Event, you can set the ConferenceDataVersion as a parameter of your request before executing it.
You also have to make sure that the request body has the appropriate conference data properties (requestId, conferenceSolutionKey, etc.).
For example:
Event newEvent = new Event()
{
ConferenceData = new ConferenceData()
{
CreateRequest = new CreateConferenceRequest()
{
ConferenceSolutionKey = new ConferenceSolutionKey()
{
Type = "hangoutsMeet" // Change according to your preferences
},
RequestId = "XXXXX" // Unique request ID
}
},
// ... Rest of event properties (start, end, attendees, name, etc.)
};
EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
request.ConferenceDataVersion = 1; // Set conference data version
Event createdEvent = request.Execute();

Getting "The service method is not found error" in Bing Maps

We are using geocoding service to get geocodeAddress (latitude/longitude) but we are getting the "The service method is not found" error. Below are my code.
public static double[] GeocodeAddress(string address, string virtualearthKey)
{
net.virtualearth.dev.GeocodeRequest geocodeRequest = new net.virtualearth.dev.GeocodeRequest
{
// Set the credentials using a valid Bing Maps key
Credentials = new net.virtualearth.dev.Credentials { ApplicationId = virtualearthKey },
// Set the full address query
Query = address
};
// Set the options to only return high confidence results
net.virtualearth.dev.ConfidenceFilter[] filters = new net.virtualearth.dev.ConfidenceFilter[1];
filters[0] = new net.virtualearth.dev.ConfidenceFilter
{
MinimumConfidence = net.virtualearth.dev.Confidence.High
};
// Add the filters to the options
net.virtualearth.dev.GeocodeOptions geocodeOptions = new net.virtualearth.dev.GeocodeOptions { Filters = filters };
geocodeRequest.Options = geocodeOptions;
// Make the geocode request
net.virtualearth.dev.GeocodeService geocodeService = new net.virtualearth.dev.GeocodeService();
net.virtualearth.dev.GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
if (geocodeResponse.Results.Length > 0)
{
return new[] { geocodeResponse.Results[0].Locations[0].Latitude, geocodeResponse.Results[0].Locations[0].Longitude };
}
return new double[] { };
} // GeocodeAddress
Key is used for URL for bing map geocode service in we.config
<add key="net.virtualearth.dev.GeocodeService" value="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc" />
Looks like you are trying to use the old Virtual Earth SOAP Services which were deprecated and shut down last year. These were replaced by the Bing Maps REST services 7 or 8 years ago. Since you are working in .NET, take a look at the Bing Maps .NET REST Toolkit. It makes it easy to use the REST services in .NET. There is a NuGet package available as well. You can find details here: https://github.com/Microsoft/BingMapsRESTToolkit
Once you have the NuGet package added to your project, you can geocode like this:
//Create a request.
var request = new GeocodeRequest()
{
Query = "New York, NY",
IncludeIso2 = true,
IncludeNeighborhood = true,
MaxResults = 25,
BingMapsKey = "YOUR_BING_MAPS_KEY"
};
//Execute the request.
var response = await request.Execute();
if(response != null &&
response.ResourceSets != null &&
response.ResourceSets.Length > 0 &&
response.ResourceSets[0].Resources != null &&
response.ResourceSets[0].Resources.Length > 0)
{
var result = response.ResourceSets[0].Resources[0] as BingMapsRESTToolkit.Location;
//Do something with the result.
}

Evernote findNotes by sourceURL

I'm trying to search notes by the attribute sourceURL but it seems API is stripping away the protocol and the result is no results. Here is the code
var notesTransport = new Thrift.Transport(
Eventnote.Auth.oauth.getParameter(Eventnote.Auth.note_store_url_param));
var notesProtocol = new Thrift.Protocol(notesTransport);
var noteStore = new NoteStoreClient(notesProtocol, notesProtocol);
if (!noteStore) {
Eventnote.Logger.error("[EVERDU] Connection failure during getting note store");
return;
}
var filter = new NoteFilter();
filter.words = "sourceURL:" + url + "*";
try {
var results = noteStore.findNotes(Eventnote.Auth.get_auth_token(), filter,
0, 100);
...
The reasults objects looks like this
{
"startIndex":0,
"totalNotes":0,
"notes":[
],
"stoppedWords":null,
"searchedWords":[
"//github.com/sameersbn/docker-gitlab*"
],
"updateCount":18461
}
Is there something I am missing?
Not sure if that counts as a bug on Evernote's end or not, butyou can add double quotes around your url to make it work.
filter.words = "sourceURL:\"" + url + "*\"";

updating state and attribute values using plugin

I am trying to update both the state and value of an attribute for an entity by writing plugin for CRM 2013. I did try to set the state of an activity using setStateRequest but I am not sure if we can update attribute value as well. I've registered the plugin on Merge message to change the state of an activity. How can I update an attribute value along with state change? Here is my code so far for state ch
protected void ExecutePreCaseMerge(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
// TODO: Implement your custom Plug-in business logic.
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
//The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("SubordinateId") &&
context.InputParameters["SubordinateId"] is Guid)
{
try
{
Guid subordinateId = (Guid)context.InputParameters["SubordinateId"];
var fetch = #"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='task'>
<attribute name='new_issuephase' />
<filter type='and'>
<filter type='and'>
<condition attribute='regardingobjectid' operator='eq' uitype='incident' value='" + subordinateId + #"' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
</filter>
</entity>
</fetch>";
EntityCollection ec = service.RetrieveMultiple(new FetchExpression(fetch));
if (ec.Entities.Count > 0)
{
// Create an ExecuteMultipleRequest object.
ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
{
// Assign settings that define execution behavior: continue on error, return responses.
Settings = new ExecuteMultipleSettings()
{
ContinueOnError = false,
ReturnResponses = true
},
// Create an empty organization request collection.
Requests = new OrganizationRequestCollection()
};
foreach (var item in ec.Entities)
{
SetStateRequest setStateRequest = new SetStateRequest();
setStateRequest.EntityMoniker = new EntityReference("task", item.Id);
setStateRequest.State = new OptionSetValue(2);
setStateRequest.Status = new OptionSetValue(6);
requestWithResults.Requests.Add(setStateRequest);
}
ExecuteMultipleResponse responseWithResults =
(ExecuteMultipleResponse)service.Execute(requestWithResults);
}
}
ange.
Thanks for any help!
You must do the update as a separate request but you can execute it together with the SetStateRequests inside the same ExecuteMultipleRequest:
foreach (var item in ec.Entities)
{
SetStateRequest setStateRequest = new SetStateRequest();
setStateRequest.EntityMoniker = new EntityReference("task", item.Id);
setStateRequest.State = new OptionSetValue(2);
setStateRequest.Status = new OptionSetValue(6);
requestWithResults.Requests.Add(setStateRequest);
//New Code
item.Attributes["attributetobeupdated"] = "Updated Value";
UpdateRequest request = new UpdateRequest() { Target = item };
requestWithResults.Requests.Add(request);
}
ExecuteMultipleResponse responseWithResults =
(ExecuteMultipleResponse)service.Execute(requestWithResults);
Note that if any of the requests fail the ExecuteMultipleRequest will not throw an error but will return the details of the individual failures within the ExecuteMultipleResponse. It seems that a common reason for this operation failing is that by default SQL server queries are configured to time out after 30 seconds. More info here:
http://manyrootsofallevilrants.blogspot.in/2012/09/ms-crm-2011-timeout-settings-and-limits.html

Resources