serenity-is / Serenity

Business Apps Made Simple with Asp.Net Core MVC / TypeScript
https://serenity.is
MIT License
2.61k stars 802 forks source link

Supplier update with asmx web service #5138

Closed serkansonmez closed 4 years ago

serkansonmez commented 4 years ago

I have an XML-based web service that brings some information by ID number. http://genweb.gencer.com:9009/TigerWebService/TigerWebService.asmx?op=TcKimlikNoSorgula

  1. First of all, my goal is to bring the information over the service when the TNB button is pressed, but I have not been successful with the code below.

supplierDialog.ts

` constructor() { super();

        this.dialogTitle = "Vergi Kimlik Numarasından data getirmek";

        $('<a class="inplace-button inplace-action3"><b><i class="fa fa-magic text-red"></i></b></a>')
            .attr("title", "TNB'den Veri Getir")
            .insertAfter(this.form.TaxNr.element)
            .click(e => {
                var SoapMessage2 =   this.form.TaxNr.value ;
                var SoapMessage = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">   <soap:Body>     <TcKimlikNoSorgula xmlns="http://tempuri.org/">       <pTcKimlikNo>' + this.form.TaxNr.value  + '</pTcKimlikNo>     </TcKimlikNoSorgula>   </soap:Body> </soap:Envelope>';  
                Q.notifySuccess(SoapMessage);

                $.ajax({
                    url: "http://genweb.gencer.com:9009/TigerWebService/TigerWebService.asmx?op=TcKimlikNoSorgula",
                    type: "POST",
                    dataType: "xml",
                    data: SoapMessage,
                    error: function (xml2) { alert("No data found." + xml2); },
                    success: function (xml) {
                        alert("it works");

                    },
                    contentType: "text/xml; charset=utf-8"
                });  

            });

    }`

image

  1. When the first item did not work, I tried to bring the data in the registration phase to bring the data in the registration phase, it brings the records from the web service but does not write it in the table. Note: There is no problem when you transfer a fixed value to the variables without calling the service.

`SupplierRepository.cs private class MySaveHandler : SaveRequestHandler {

        protected override async void BeforeSave()
        {
            base.BeforeSave();             
            try
            {
                TnbRepository tnbRepository = new TnbRepository("http://genweb.gencer.com:9009/TigerWebService/TigerWebService.asmx", 100);
                var result = await tnbRepository.TcKimlikNoSorgula(Row.TaxNr);
                base.Row.Address = result.IkametgahAdresi.MahalleSemt + " " + result.IkametgahAdresi.CaddeSokak + " " + result.IkametgahAdresi.DaireNO + " " + result.IkametgahAdresi.KapiNO + " " + result.IkametgahAdresi.IlceAdi + " " + result.IkametgahAdresi.IlAdi + " ";
                base.Row.TaxOffice = result.VergiDairesiAdi;

                //base.Row.Country = "Türkiye";
                //base.Row.Address = "address";
                //base.Row.TaxOffice = "result.VergiDairesiAdi";

            }
            catch (Exception ex)
            {
                throw new Exception("Hata : " + ex.Message);
            }
        }
    }`

` public class TnbRepository { // private readonly ICalculatorChannel proxy; private readonly TigerWebService.TigerWebServiceSoapChannel proxy; ///

/// Initializes a new instance of the class. /// /// Endpoint address. /// The timeout. public TnbRepository(string endpointAddress, double timeout) { BasicHttpBinding binding = new BasicHttpBinding { SendTimeout = TimeSpan.FromSeconds(timeout), MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue, AllowCookies = true,

            ReaderQuotas = XmlDictionaryReaderQuotas.Max
        };
        binding.Security.Mode = BasicHttpSecurityMode.None;

        EndpointAddress address = new EndpointAddress(endpointAddress);
        ChannelFactory<TigerWebServiceSoapChannel> factory = new ChannelFactory<TigerWebServiceSoapChannel>(binding, address);
        this.proxy = factory.CreateChannel();

    }
    /// <summary>
    /// Adds asynchronously.
    /// </summary>

    public async Task<MerkezBilgiSorguSonuc> TcKimlikNoSorgula(string  pTCNo)
    {
        return await this.proxy.TcKimlikNoSorgulaAsync(pTCNo).ConfigureAwait(false);

    }`

Greetings. Serkan Sönmez

VictorTomaili commented 4 years ago

Closed due inactivity

Also check the issue guidelines. If you still need help, you can ask this on stackoverflow with our new tag. https://stackoverflow.com/tags/serenity-platform