public virtual T Request <T>(IRequest <T> request) { using (var svc = GetService()) { processEventResult response = svc.processEvent( // Add in the authentication info new authenticationToken() { userName = this.ThirdPartySourceId.ToString(), password = this.Password }, this.ThirdPartySourceId, // Which dealership to target request.DealerEndpointId, // Which transaction to run request.TransactionType, // The data to be processed request.Payload, // Payload versioning information PAYLOAD_VERSION ); // In debug, let's write out all of the XML to files. #if DEBUG using (var w = new StreamWriter(String.Format("{0}.xml", Guid.NewGuid()))) { w.Write(response.response); } #endif // Check the response for errors and handle them as necessary. CheckErrors(response); // Process the response. return(request.ProcessResponse(response.response)); } }
internal virtual void CheckErrors(processEventResult result) { /* * <ns2:processEventResult> * <!-- Response Payload --> * <response>Request unauthorized</response> * <!-- Was the event rejected due to a business validation problem? --> * <businessError>true</businessError> * <!-- Was the event rejected due to a system problem? --> * <systemError>false</systemError> * <!-- Should this event be reposted? --> * <retryable>false</retryable> * <!-- What was the specific problem with the event? SUCCESS if none. --> * <statusCode>PERMISSION_DENIED</statusCode> * </ns2:processEventResult> */ // Check the status codes. if (result.statusCode == processEventStatusCode.ENDPOINT_FAILURE) { } // Check for a system error. if (result.systemError) { } // Check for a business error. if (result.businessError) { } if (result.retryable) { // Re-send it. } // Otherwise the request was successful, move on. }