This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ZoomFSRoyalMail.RoyalMail.shippingAPIPortTypeClient getRMServiceClient() | |
{ | |
CLRObject clientType; | |
RoyalMail.shippingAPIPortTypeClient serviceClient; | |
RoyalMail.EndPointBehaviour endPointBehaviour; | |
System.ServiceModel.EndpointAddress endpointAddress; | |
System.ServiceModel.Description.ServiceEndpoint endPoint; | |
System.ServiceModel.Description.ContractDescription contract; | |
System.ServiceModel.Description.OperationDescriptionCollection operations; | |
System.ServiceModel.Description.OperationDescription operationDescription; | |
System.Collections.IEnumerator enumerator; | |
System.Exception ex; | |
System.Uri uri; | |
ClrObject endPointBehavioursCollection = | |
new ClrObject("System.Collections.Generic.KeyedByTypeCollection`1[System.ServiceModel.Description.IEndpointBehavior]"); | |
ClrObject operationBehaviourCollection = | |
new ClrObject("System.Collections.Generic.KeyedByTypeCollection`1[System.ServiceModel.Description.IOperationBehavior]"); | |
try | |
{ | |
if (!this.parmRMTTUrl()) | |
throw error (strFmt("Royal Mail API URL is missing for Royal Mail Shipping API")); | |
uri = new System.Uri(this.parmRMTTUrl()); | |
endpointAddress = new System.ServiceModel.EndpointAddress( | |
uri, | |
System.ServiceModel.EndpointIdentity::CreateDnsIdentity(this.parmDNSIdentity()), | |
new System.ServiceModel.Channels.AddressHeaderCollection()); | |
clientType = CLRInterop::getType("RoyalMail.shippingAPIPortTypeClient"); | |
serviceClient = AifUtil::createServiceClient(clientType); | |
endPoint = serviceClient.get_Endpoint(); | |
endPoint.set_Address(endpointAddress); | |
endPointBehavioursCollection = endPoint.get_EndpointBehaviors(); | |
endPointBehaviour = new RoyalMail.EndPointBehaviour(); | |
endPointBehaviour.SetCredentials(this.parmRMTTClientID(),this.parmRMTTSecret()); | |
endPointBehavioursCollection.Add(endPointBehaviour); | |
contract = endpoint.get_Contract(); | |
operations = contract.get_Operations(); | |
enumerator = operations.GetEnumerator(); | |
while(enumerator.MoveNext()) | |
{ | |
operationDescription = enumerator.get_Current(); | |
operationBehaviourCollection = operationDescription.get_Behaviors(); | |
operationBehaviourCollection.Add(new RoyalMail.RoyalMailOperationBehavior()); | |
} | |
} | |
catch(Exception::CLRError) | |
{ | |
error(AifUtil::getClrErrorMessage()); | |
} | |
return serviceClient; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment