Quantcast
Channel: BTSoru.com - Bilisim ve Yazilim Teknolojileri Soru/Cevap Platformu - latest questions
Viewing all articles
Browse latest Browse all 4270

Geonetwork Metadata insert işlemi sırasında oluşan unauthorize hatasının sebebi nedir?

$
0
0

Merhaba arkadaşlar, proje bitirme tarihleri gelirken neredeyse hiç bilgi sahibi olmadığımız bir konu olan geonetwork'ün içinde bulduk kendimizi. Yaptığım araştırmaya göre cookie login yaptıran bir sistemi var.Bende ilk olarak sisteme olgin oluyorum burda sıkıntı yok. gelen jsession id'sini headere yükleyip insert moduna geçiyorum fakat burda habire unauthorize hatası alıyorum bilgisi olan varsa yardım edebilirmi. Küçük bir kod bloğu alt tarafta

 public string SendXmlToGeoNetwork(string xml, string ServerUrl)
        {
            if (Login())
            {
                string answer = postRequest(xml, ServerUrl);
                return answer;
            }
            return "";
        } 
 public bool Login() {

        string LoginText = "<request><username>admin</username><password>admin</password></request>";
        string LoginUrl = ConfigurationManager.AppSettings["geoNetworklocal"].ToString() + "srv/en/xml.user.login";
        try
        {

            string answer = postRequest(LoginText, LoginUrl);
            if (answer.Contains("<ok"))
                return true;
            return false;
        }
        catch {
            return false;
        }

    }

 HttpWebRequest webRequest;
    HttpWebResponse webResponse;
    private string header;
     private string postRequest(String RequestXML, string ServerURL)
    {

        int timeout = 90000;
        int connectionLimit = 10;
        string responseXML = string.Empty;
        try
        {
            webRequest = (HttpWebRequest)WebRequest.Create(ServerURL);

            if (!string.IsNullOrEmpty(header))
            {
                webRequest.Headers.Add("Set-Cookie", header);
            }

            webRequest.Credentials = new NetworkCredential("admin", "admin");
            webRequest.Timeout = timeout;
            webRequest.KeepAlive = true;
            webRequest.ServicePoint.ConnectionLimit = connectionLimit;
            webRequest.ProtocolVersion = HttpVersion.Version10;
            webRequest.Method = "POST";
            webRequest.ContentType = "application/xml";
            byte[] byteArray = Encoding.UTF8.GetBytes(RequestXML);
            Stream strm = webRequest.GetRequestStream();
            strm.Write(byteArray, 0, byteArray.Length);
            strm.Close();
            webResponse = (HttpWebResponse)webRequest.GetResponse();
            header= webResponse.Headers["Set-Cookie"].ToString();
            Encoding enc = Encoding.GetEncoding("utf-8");
            StreamReader reader = new StreamReader(webResponse.GetResponseStream(), enc);
            responseXML = reader.ReadToEnd();
            reader.Close();
            webResponse.Close();

        }
        catch (Exception ex)
        {
            throw (ex);
        }
        return responseXML;
    }

şimdiden teşekkür ederim.


Viewing all articles
Browse latest Browse all 4270

Trending Articles


Göz perdesi kaldırma zikri Sonuç alınmıştır.


Havasta Açık Kapalı Günler


rızık ve geçim derdi için ya vehhab vefki


İsmi Azam Vefki


Gaibten nafaka tertipleri


Mülk süresi 14. Ayet ve ya habir esması


Muhabbet Ve Cimaya Kuvvet


“ Yâ Evvel Yâ Âhir Yâ Zahir Yâ Bâtın “


SCCM 2012 Client Installation issue


Kağıtları Altına Çevirmek


Musallat için


sihir ve cinin zararlarını gidermek


"Yâ Melik!" Esmasının Havâs ve Esrârı


Sıkıntıyı gideren Ismi Celil duası


Davet-i tahatili Kübra


Çok Kuvvetli Söz Geçirme Duası


İrsali hatif


İnna fetahna leke fethan mubina (Fetih Suresi 1.ayet)


Kalp gözünü açmak için kolay yollar


Ya Rakib Esmasının Mucizeleri