StructureFareRulesRQ Parse Failure - Visual Studio Web Reference Naming Convention Error? - c#

I'm trying to call the StructureFareRulesRQ API from Sabre but its seems as though this API is different than the rest of the Sabre APIs. After adding the wsdl file to my project, I am expecting the Web Service call method to be named something like StructureFareRulesRQService but that doesn't exist. Instead I get StructureFareRulesRQ as the actual service and StructureFareRulesRQ1 as the wrapper class for the XML message. As the wrapper class has the wrong name, when it gets serialized, it creates a bogus XML message (see below).
I know I can probably dig through the reference.cs file and do a find/replace, but I'm concerned that doing that will require me to do the same thing whenever a new version comes online. Has anyone else run into this, or am I going nuts?
Example XML Payload which returns a "Error ErrorCode="009400" ErrorMessage="PARSE FAILURE - INVALID REQUEST" response from Sabre:
<?xml version="1.0" encoding="utf-16"?>
<StructureFareRulesRQ1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<PriceRequestInformation CurrencyCode="USD" BuyingDate="2019-05-21T13:46:00" xmlns="http://webservices.sabre.com/sabreXML/2003/07">
<PassengerTypes>
<PassengerType Code="ADT" />
</PassengerTypes>
<ReturnAllData />
</PriceRequestInformation>
<AirItinerary xmlns="http://webservices.sabre.com/sabreXML/2003/07">
<OriginDestinationOptions>
<OriginDestinationOption>
<FlightSegment SegmentType="A" DepartureDate="2019-08-17T17:35:00" BookingDate="2019-05-21T13:46:00" RealReservationStatus="SS">
<DepartureAirport LocationCode="ORD" />
<ArrivalAirport LocationCode="HEL" />
<MarketingAirline Code="AY" />
<OperatingAirline Code="AY" />
</FlightSegment>
<PaxTypeInformation FareBasisCode="IFLE2US2" PassengerType="ADT" FareComponentNumber="0" />
</OriginDestinationOption>
<OriginDestinationOption>
<FlightSegment SegmentType="A" DepartureDate="2019-08-18T13:25:00" BookingDate="2019-05-21T13:46:00" RealReservationStatus="SS">
<DepartureAirport LocationCode="HEL" />
<ArrivalAirport LocationCode="SVO" />
<MarketingAirline Code="AY" />
<OperatingAirline Code="SU" />
</FlightSegment>
<PaxTypeInformation FareBasisCode="IFLE2US2" PassengerType="ADT" FareComponentNumber="0" />
</OriginDestinationOption>
<OriginDestinationOption>
<FlightSegment SegmentType="A" DepartureDate="2019-08-29T10:40:00" BookingDate="2019-05-21T13:46:00" RealReservationStatus="SS">
<DepartureAirport LocationCode="SVO" />
<ArrivalAirport LocationCode="HEL" />
<MarketingAirline Code="AY" />
<OperatingAirline Code="SU" />
</FlightSegment>
<PaxTypeInformation FareBasisCode="IFLE2US2" PassengerType="ADT" FareComponentNumber="0" />
</OriginDestinationOption>
<OriginDestinationOption>
<FlightSegment SegmentType="A" DepartureDate="2019-08-29T13:55:00" BookingDate="2019-05-21T13:46:00" RealReservationStatus="SS">
<DepartureAirport LocationCode="HEL" />
<ArrivalAirport LocationCode="ORD" />
<MarketingAirline Code="AY" />
<OperatingAirline Code="AY" />
</FlightSegment>
<PaxTypeInformation FareBasisCode="IFLE2US2" PassengerType="ADT" FareComponentNumber="0" />
</OriginDestinationOption>
</OriginDestinationOptions>
</AirItinerary>
</StructureFareRulesRQ1>

Hello i think StructureFareRulesRQ1 must be StructureFareRulesRQ.
https://beta.developer.sabre.com/docs/soap_apis/air/utility/get_structured_fare_rules

Related

How to transform XML configuration pre-build?

I've got a solution:
Solution1
--ConfigProject
----AppManifest.xml
----ServiceManifest.xml
--Project1
--Project2
ServiceManifest.xml looks like this:
<ServiceManifest>
...............
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" />
</Endpoints>
</Resources>
</ServiceManifest>
Without relying on c# code, is there a pre-build step that I can add that will transform the Resources section in the ServiceManifest file, based on a setting in the AppManifest.xml file?
You could describe your service manifest as following:
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="Stateless1Pkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<ResourceOverrides>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Port="[Port]" Protocol="[Protocol]" Type="[Type]" />
<Endpoint Name="ServiceEndpoint1" Port="[Port1]" Protocol="[Protocol1] "/>
</Endpoints>
</ResourceOverrides>
<Policies>
<EndpointBindingPolicy CertificateRef="TestCert1" EndpointRef="ServiceEndpoint"/>
</Policies>
</ServiceManifestImport>
Now you can apply the parameters in your ApplicationManifest. If you want you can add them a default value.
<Parameters>
<Parameter Name="Port" DefaultValue="" />
<Parameter Name="Protocol" DefaultValue="" />
<Parameter Name="Type" DefaultValue="" />
<Parameter Name="Port1" DefaultValue="" />
<Parameter Name="Protocol1" DefaultValue="" />
</Parameters>
You can override these parameters with an own customized ApplicationParameters file (like Local1.1Node.xml and Local.5Node.xml). Another alternative would be to insert the parameters per powershell during publishing:
PS C:\> New-ServiceFabricApplication -ApplicationName fabric:/myapp -ApplicationTypeName "AppType" -ApplicationTypeVersion "1.0.0" -ApplicationParameter #{Port='1001'; Protocol='https'; Type='Input'; Port1='2001'; Protocol='http'}
For further details:
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-service-manifest-resources

WCF - OData: How to access an operation

I am using a child class of the System.Data.Services.Client.DataServiceContext gerated by the "adding a Service Reference" in VisualStudio to access data via an OData service. The definition in the $metadata.xml of the service includes a custom operation:
<schema Namespace="dotNetBF.OData" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="OData" m:IsDefaultEntityContainer="true">
<EntitySet Name="SewageArea" EntityType="GeoMan.SealingRegister.SewageArea" />
<EntitySet Name="LandParcel" EntityType="GeoMan.SealingRegister.LandParcel" />
...
<AssociationSet Name="GeoMan_SealingRegister_SewageArea_LandParcel_GeoMan_SealingRegister_LandParcel_LandParcelPartnerSet" Association="GeoMan.SealingRegister.GeoMan_SealingRegister_SewageArea_LandParcel_GeoMan_SealingRegister_LandParcel_LandParcelPartner">
<End Role="LandParcelPartner" EntitySet="SewageArea" />
<End Role="LandParcel" EntitySet="LandParcel" />
</AssociationSet>
...
<FunctionImport Name="LandParcelByRegistrationYear" EntitySet="LandParcel" ReturnType="Collection(GeoMan.SealingRegister.LandParcel)">
<Parameter Name="registrationYear" Mode="In" Type="Edm.String" />
</FunctionImport>
</EntityContainer>
</Schema>
How can I access the defined function LandParcelByRegistrationYear through the DataServiceDeviceContext, commit a value for parameter registrationYearand consume the result.
I already imported the $metadata.xml but cannot find a method given the name of the operation.

Azure Hosted Service Bus : "The X.509 certificate CN=servicebus.windows.net is not in the trusted people store."

Using Azure SDK 2.3 on my vs2013 development VM I can consume Service Bus queues hosted in Azure painlessly. However, on Windows Server 2008 R2 Standard SP1, it looks like Windows can not trust the involved certificates and an exception is thrown.
The line that throws :
// Send the message
await queueclient.SendAsync(message);
Exception message :
The X.509 certificate CN=servicebus.windows.net is not in the trusted
people store. The X.509 certificate CN=servicebus.windows.net chain
building failed. The certificate that was used has a trust chain that
cannot be verified. Replace the certificate or change the
certificateValidationMode. A certificate chain could not be built to a
trusted root authority.
The CAPI2 logs (attached below) pointed to a trust issue so I compared certificates installed on both machines. The following certificates are absent on the server :
Intermediate Certification Authorities > Microsoft Internet Authority
(Issued by Baltimore CyberTrust Root)
Intermediate Certification Authorities > MSIT Machine Auth CA 2
(Issued by Microsoft Internet Authority)
The questions :
Where does the certificates come from?
Why are they missing from the server?
How to fix this issue?
Possible trails (updated) :
Install Azure SDK 2.3 for Visual Studio 2013 on the server
Install all Windows Updates on the server
I tried :
<appSettings>
<add key="Microsoft.ServiceBus.X509RevocationMode" value="NoCheck"/>
</appSettings>
CAPI2 Verify Chain Policy event :
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-CAPI2" Guid="{5bbca4a8-b209-48dc-a8c7-b23d3e5216fb}" />
<EventID>30</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>30</Task>
<Opcode>0</Opcode>
<Keywords>0x4000000000000001</Keywords>
<TimeCreated SystemTime="2014-06-11T19:57:38.998656000Z" />
<EventRecordID>5642</EventRecordID>
<Correlation />
<Execution ProcessID="5280" ThreadID="8472" />
<Channel>Microsoft-Windows-CAPI2/Operational</Channel>
<Computer>ne-r026-310cn</Computer>
<Security UserID="S-1-5-82-1758914132-2364927631-3137608320-3227192193-3717738432" />
</System>
<UserData>
<CertVerifyCertificateChainPolicy>
<Policy type="CERT_CHAIN_POLICY_BASE" constant="1" />
<Certificate fileRef="3E560462C61B45BE1A59F1286B34A065A878AFA0.cer" subjectName="servicebus.windows.net" />
<CertificateChain chainRef="{19B5F58A-FA37-4213-A888-C81C340D019C}" />
<Flags value="1000" CERT_CHAIN_POLICY_IGNORE_PEER_TRUST_FLAG="true" />
<Status chainIndex="0" elementIndex="-1" />
<EventAuxInfo ProcessName="w3wp.exe" />
<CorrelationAuxInfo TaskId="{F8DE43DD-9E68-461E-8A2B-17215BA87E0C}" SeqNumber="1" />
<Result value="800B010A">A certificate chain could not be built to a trusted root authority.</Result>
</CertVerifyCertificateChainPolicy>
</UserData>
</Event>
CAPI2 Build Chain event :
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-CAPI2" Guid="{5bbca4a8-b209-48dc-a8c7-b23d3e5216fb}" />
<EventID>11</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>11</Task>
<Opcode>2</Opcode>
<Keywords>0x4000000000000003</Keywords>
<TimeCreated SystemTime="2014-06-11T19:57:38.998656000Z" />
<EventRecordID>5641</EventRecordID>
<Correlation />
<Execution ProcessID="5280" ThreadID="8472" />
<Channel>Microsoft-Windows-CAPI2/Operational</Channel>
<Computer>ne-r026-310cn</Computer>
<Security UserID="S-1-5-82-1758914132-2364927631-3137608320-3227192193-3717738432" />
</System>
<UserData>
<CertGetCertificateChain>
<Certificate fileRef="3E560462C61B45BE1A59F1286B34A065A878AFA0.cer" subjectName="servicebus.windows.net" />
<ValidationTime>2014-06-11T19:57:38.998Z</ValidationTime>
<AdditionalStore />
<ExtendedKeyUsage />
<Flags value="0" />
<ChainEngineInfo context="machine" />
<AdditionalInfo>
<NetworkConnectivityStatus value="1" _SENSAPI_NETWORK_ALIVE_LAN="true" />
</AdditionalInfo>
<CertificateChain chainRef="{19B5F58A-FA37-4213-A888-C81C340D019C}">
<TrustStatus>
<ErrorStatus value="10000" CERT_TRUST_IS_PARTIAL_CHAIN="true" />
<InfoStatus value="0" />
</TrustStatus>
<ChainElement>
<Certificate fileRef="3E560462C61B45BE1A59F1286B34A065A878AFA0.cer" subjectName="servicebus.windows.net" />
<SignatureAlgorithm oid="1.2.840.113549.1.1.5" hashName="SHA1" publicKeyName="RSA" />
<PublicKeyAlgorithm oid="1.2.840.113549.1.1.1" publicKeyName="RSA" publicKeyLength="2048" />
<TrustStatus>
<ErrorStatus value="0" />
<InfoStatus value="2" CERT_TRUST_HAS_KEY_MATCH_ISSUER="true" />
</TrustStatus>
<ApplicationUsage>
<Usage oid="1.3.6.1.5.5.7.3.2" name="Client Authentication" />
<Usage oid="1.3.6.1.5.5.7.3.1" name="Server Authentication" />
</ApplicationUsage>
<IssuanceUsage />
</ChainElement>
</CertificateChain>
<EventAuxInfo ProcessName="w3wp.exe" />
<CorrelationAuxInfo TaskId="{9077AB4E-95E3-449B-AF2F-0BF42E92E6B7}" SeqNumber="11" />
<Result value="800B010A">A certificate chain could not be built to a trusted root authority.</Result>
</CertGetCertificateChain>
</UserData>
</Event>
CAPI2 X509 Objects event :
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-CAPI2" Guid="{5bbca4a8-b209-48dc-a8c7-b23d3e5216fb}" />
<EventID>90</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>90</Task>
<Opcode>0</Opcode>
<Keywords>0x4000000000000200</Keywords>
<TimeCreated SystemTime="2014-06-11T19:57:38.998656000Z" />
<EventRecordID>5640</EventRecordID>
<Correlation />
<Execution ProcessID="5280" ThreadID="8472" />
<Channel>Microsoft-Windows-CAPI2/Operational</Channel>
<Computer>ne-r026-310cn</Computer>
<Security UserID="S-1-5-82-1758914132-2364927631-3137608320-3227192193-3717738432" />
</System>
<UserData>
<X509Objects>
<Certificate fileRef="3E560462C61B45BE1A59F1286B34A065A878AFA0.cer" subjectName="servicebus.windows.net">
<Subject>
<CN>servicebus.windows.net</CN>
</Subject>
<SubjectKeyID computed="false" hash="BD41618C22D8DBEE9D172C12A2C549D61711ED75" />
<SignatureAlgorithm oid="1.2.840.113549.1.1.5" hashName="SHA1" publicKeyName="RSA" />
<PublicKeyAlgorithm oid="1.2.840.113549.1.1.1" publicKeyName="RSA" publicKeyLength="2048" />
<Issuer>
<CN>MSIT Machine Auth CA 2</CN>
<DC>redmond</DC>
<DC>corp</DC>
<DC>microsoft</DC>
<DC>com</DC>
</Issuer>
<SerialNumber>70DB015B000100008C58</SerialNumber>
<NotBefore>2013-07-27T03:31:06Z</NotBefore>
<NotAfter>2015-07-27T03:31:06Z</NotAfter>
<Extensions>
<KeyUsage value="B0" CERT_DIGITAL_SIGNATURE_KEY_USAGE="true" CERT_KEY_ENCIPHERMENT_KEY_USAGE="true" CERT_DATA_ENCIPHERMENT_KEY_USAGE="true" />
<ExtendedKeyUsage>
<Usage oid="1.3.6.1.5.5.7.3.2" name="Client Authentication" />
<Usage oid="1.3.6.1.5.5.7.3.1" name="Server Authentication" />
</ExtendedKeyUsage>
<SubjectAltName>
<DNSName>*.servicebus.windows.net</DNSName>
<DNSName>servicebus.windows.net</DNSName>
</SubjectAltName>
<AuthorityKeyIdentifier>
<KeyID hash="EBDB115EF8099ED8D6629CFD629DE3844A28E127" />
</AuthorityKeyIdentifier>
</Extensions>
</Certificate>
<EventAuxInfo ProcessName="w3wp.exe" />
<CorrelationAuxInfo TaskId="{9077AB4E-95E3-449B-AF2F-0BF42E92E6B7}" SeqNumber="10" />
</X509Objects>
</UserData>
</Event>
The missing certificates were responsible for the exception.
I haven't been able to find the certificates online and I'm still unsure of how EXACTLY they managed to install themselves BUT I think I have an idea..
How we managed to obtain the certificates?
We isolated the Service Bus messaging code into a console application and executed it with admin rights on the production server. The certificates installed themselves automatically in the process.
Perhaps our application pool, running under ApplicationPoolIdentity with limited permissions was not allowing Windows to download or install the certificates.
This link seems to offer related information : http://netsekure.org/2011/04/automatic-ca-root-certificate-updates-on-windows/
Update : You can download the certificate chain here.
To eliminate certificate trust issues from Service Bus for Windows Server, use the following:
Create a list of the certificates you trust:
var trustedCertificates = new HashSet<string>(new[]
{
"1245…",
"4567…,
"8102…"
}, StringComparer.OrdinalIgnoreCase);
Trust those:
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
{
if (errors == SslPolicyErrors.None)
{
return true;
}
var hashString = certificate.GetCertHashString();
var isTrusted = trustedCertificates.Contains(hashString);
if (!isTrusted)
{
telemetryClient.TrackTrace($"Untrusted: {hashString} Errors: {errors} Cert: {certificate.ToString()}", SeverityLevel.Warning);
}
return isTrusted;
};
Calm Service Bus down too:
private static void SetCertificateValidator()
{
var retriableCertificateValidatorType = Type.GetType("Microsoft.ServiceBus.Channels.Security.RetriableCertificateValidator, Microsoft.ServiceBus", true, false);
var instanceProperty = retriableCertificateValidatorType.GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic);
var instance = instanceProperty.GetValue(null);
var peerOrChainTrustNoCheck = retriableCertificateValidatorType.GetField("peerOrChainTrustNoCheck", BindingFlags.Instance | BindingFlags.NonPublic);
peerOrChainTrustNoCheck?.SetValue(instance, new EmptyOpX509CertificateValidator());
}
private sealed class EmptyOpX509CertificateValidator : X509CertificateValidator
{
public override void Validate(X509Certificate2 certificate)
{
}
}

How do I add a namespace to only ref elements in C#?

I have an XElement which contains the content that I want. However, I want to add a namespace prefix to only the ref elements. Is this possible in C#?
For example, the original XML looks like this:
<Root>
<Element1 />
<Element2 />
<Element3>
<Element3_Child1 />
<Element3_Child2 />
</Element3>
<Element4 />
<Element5>
<Element5_Child1>
<Element5_Child1_Child51 />
</Element5_Child1>
</Element5>
</Root>
I want to add a namespace prefix, so that the XML looks as below
<Root>
<Element1 />
<Element2 />
<ns:Element3>
<Element3_Child1 />
<Element3_Child2 />
</Element3>
<Element4 />
<ns:Element5>
<ns:Element5_Child1>
<Element5_Child1_Child51 />
</Element5_Child1>
</Element5>
</Root>
You can do as stated here : http://www.w3schools.com/xml/xml_namespaces.asp
<root
xmlns:foo="http://www.example.org/foo"
xmlns:bar="http://www.example.org/bar">
However, I'm pretty sure you'll need a valid URI and that you can't "fake" one. Otherwise, the namespace will be invalid. But you can test and let us know.

How to write mappings for a stored procedure

There is an excellent post on how to map return values for a stored procedure call here:
http://elegantcode.com/2008/11/23/populating-entities-from-stored-procedures-with-nhibernate/
The mapping in this example has been done through hbm files.
I am trying to use the latest version of Nhibernate (3.2) where we can do mapping through code. I really want to find out the C# code that would create a mapping like below:
<sql-query name="GetProductsByCategoryId">
<return class="Product">
<return-property column="ProductID" name="Id" />
<return-property column="ProductName" name="Name" />
<return-property column="SupplierID" name="Supplier" />
<return-property column="CategoryID" name="Category" />
<return-property column="QuantityPerUnit" name="QuantityPerUnit" />
<return-property column="UnitPrice" name="UnitPrice" />
<return-property column="UnitsInStock" name="UnitsInStock" />
<return-property column="UnitsOnOrder" name="UnitsOnOrder" />
<return-property column="ReorderLevel" name="ReorderLevel" />
<return-property column="Discontinued" name="Discontinued" />
</return>
exec dbo.GetProductsByCategoryId :CategoryId
</sql-query>
To be honest I never tried it, by you should take a look to the extension method AddNamedQuery(..): you call it from you Configuration instance (NHibernate.Cfg namespace)).
Some examples on the NHibernate test project.
By the way, you can mix the new 3.2 mapping-by-code and xml one.
Start to look at this question;

Categories

Resources