Exemplo n.º 1
0
        public string Get(string id)
        {
            try
            {
                string url = "https://b2g-disc.ppsr.gov.au/PpsrB2GService/2016/05/CollateralRegistrationSearch.svc/soap11";
                string urlMTOM = "https://b2g-disc.ppsr.gov.au/PpsrB2GService/2016/05/CollateralRegistrationSearch.svc/soap11mtom";
                string username = "******", password = "******";

                SearchBySerialNumberResponseMessage      message = null;
                RequestSearchCertificateResponseMessage  dsd = null;
                RetrieveSearchCertificateResponseMessage ee = null;

                var operationClient  = PPSRService.CreatePPSRClient(url, username, password, UrlType.normal);
                var operationChannel = operationClient.ChannelFactory.CreateChannel();
                using (new OperationContextScope((IClientChannel)operationChannel))
                {
                    message = operationChannel.SearchBySerialNumber(new SearchBySerialNumberRequestMessage
                    {
                        TargetEnvironment           = development,
                        SearchBySerialNumberRequest = new SearchBySerialNumberRequestType
                        {
                            CustomersRequestMessageId = Guid.NewGuid().ToString(),
                            SearchCriteria            = new SearchBySerialNumberSearchCriteria
                            {
                                IncludeCurrent   = true,
                                SerialNumberType = SerialNumberSearchCriteriaType.VIN,
                                SerialNumber     = id//"JT752EP9100474959"//"JS1SP46A000504266"
                            }
                        }
                    });


                    // return JsonConvert.SerializeObject(message);
                }

                using (new OperationContextScope((IClientChannel)operationChannel))
                {
                    dsd = operationChannel.RequestSearchCertificate(new RequestSearchCertificateRequestMessage
                    {
                        TargetEnvironment = development,
                        RequestSearchCertificateRequest = new RequestSearchCertificateRequestType
                        {
                            CustomersRequestMessageId = Guid.NewGuid().ToString(),
                            SearchNumber       = message.SearchBySerialNumberResponse.SearchSummary.SearchNumber,
                            RegistrationNumber = message.SearchBySerialNumberResponse.SearchResult.ResultDetails.Last().RegistrationDetail.RegistrationNumber,
                            ChangeNumber       = message.SearchBySerialNumberResponse.SearchResult.ResultDetails.Last().RegistrationDetail.ChangeNumber
                        }
                    });


                    //sb.AppendLine(JsonConvert.SerializeObject(dsd));
                    //sb.AppendLine();
                    return(JsonConvert.SerializeObject(dsd));
                }
            }
            catch (Exception ex)
            {
                return($"MESSAGE: {ex?.Message}  STACETRACE: {ex?.StackTrace}  SOURCE: {ex?.Source}  INNER EXCEPTION: {ex?.InnerException?.ToString()}");
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult Download(string searchCertificateNumber)
        {
            try
            {
                string urlMTOM = "https://b2g-disc.ppsr.gov.au/PpsrB2GService/2016/05/CollateralRegistrationSearch.svc/soap11mtom";
                string username = "******", password = "******";

                RetrieveSearchCertificateResponseMessage ee = null;

                //Create a new Client with new URL which uses MTOM
                var operationClient1  = PPSRService.CreatePPSRClient1(urlMTOM, username, password);
                var operationChannel1 = operationClient1.ChannelFactory.CreateChannel();
                using (new OperationContextScope((IClientChannel)operationChannel1))
                {
                    ee = operationChannel1.RetrieveSearchCertificate(new RetrieveSearchCertificateRequestMessage
                    {
                        TargetEnvironment = development,
                        RetrieveSearchCertificateRequest = new RetrieveSearchCertificateRequestType
                        {
                            CustomersRequestMessageId = Guid.NewGuid().ToString(),
                            SearchCertificateNumber   = searchCertificateNumber,
                        }
                    });
                }

                var res = ee?.RetrieveSearchCertificateResponse;

                if (res?.SearchCertificateFile != null)
                {
                    HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StreamContent(new MemoryStream(res.SearchCertificateFile)),
                    };

                    result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                    {
                        FileName = res.SearchCertificateFileName ?? "Test.pdf"
                    };

                    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

                    return(ResponseMessage(result));
                }

                return(Ok(res));
            }
            catch (Exception ex)
            {
                throw;
            }
        }