ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us    

Facebook   


MAIN MENU
เขียนโปรแกรมบน iPhone ด้วย MonoTouch
News
Php Tips
Ubuntu
Spring+Strut+Hibernate
Android Programming
Design Pattern By PHP
C# Design Pattern
Linux Quick Tips
C# Tips & Technique
C# using Linq น่าใช้จริงๆ
Java & JavaScript Tips
MAVEN
Database & SQL
ZengCode Framework Guide
Mac OSx
Zeng Code Code
Programming
IPhone (Tips and Trick)

Download เอกสารที่น่าสนใจ

     C# consume Oil Price จาก PTT โดยไม่ผ่าน WS Proxy ครับ  (2010-02-26)

ไม่มีการ Add Web Refference (Web Service Proxy) จะใช้ HttpRequest และ HttpResponse นะครับ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Xml;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //com.pttplc.www.PTTInfo a = new WindowsFormsApplication1.com.pttplc.www.PTTInfo();
            //MessageBox.Show(a.GetOilPrice("thai",25,02,2553));
        }

        private void button2_Click(object sender, EventArgs e)
        {
           // String strSoapMessage = "<?xml version='1.0' encoding='utf-8'?><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><HelloWorld xmlns='http://tempuri.org/' /></soap:Body></soap:Envelope>";
            String strSoapMessage = "<?xml version='1.0' encoding='utf-8'?><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><GetOilPrice xmlns='http://www.pttplc.com/ptt_webservice/'><Language>string</Language><DD>26</DD><MM>02</MM><YYYY>2553</YYYY></GetOilPrice></soap:Body></soap:Envelope>";

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://www.pttplc.com/pttinfo.asmx");
            webRequest.Headers.Add("SOAPAction", "http://www.pttplc.com/ptt_webservice/GetOilPrice");
            webRequest.ContentType = "text/xml;charset=\"utf-8\"";
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";
            StreamWriter stm = new StreamWriter(webRequest.GetRequestStream(), Encoding.UTF8);
            stm.Write(strSoapMessage);
            stm.Flush();
            stm.Close();
            IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
            //รอจนกว่าจะตอบกลับ
            asyncResult.AsyncWaitHandle.WaitOne();
            // get the response
            string soapResult;
            using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
            using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
            {
                soapResult = rd.ReadToEnd();
            }

            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(soapResult);

            XmlNodeList Result = xDoc.GetElementsByTagName("GetOilPriceResult");
            MessageBox.Show("Result: " + Result[0].InnerText);

            webBrowser1.DocumentText = soapResult;
            richTextBox1.Text = soapResult;
        }
    }
}

 


Comment

michael kors outlet  (19 พฤษภาคม 2555)   
IP : 175.44.12.79

Have you brought michael kors outlet Michael kors watch michael kors outlet online before? How do michael kors outlet store you know michael kors bags outle that? Now I michael kors tote bags will talk michael kors handbags outlet something about michael kors factory outlet Michael Kors. Michael michael kors factory outlet online Kors is an michael kors diaper bags American Top michael kors outlet nj fashion designer. Kors Celine bags was born Celine outlet Karl Anderson Jr. in Celine bags outlet Long Island New Celine luggages York the Celine bags luggages son of Joan Celine tote bags Anderson Kors Celine Bags 2012 Krystosek a Celine outlet online former model.



Chaas  (18 เมษายน 2554)   
IP : 186.5.36.210
AKAIK you've got the asnewr in one!


Mr.ZengCode  (02 มีนาคม 2553)   
IP : 58.137.188.243

     ไอ้แบบนี้ก็ใช้ได้ครับ ทดสอบแล้ว

 public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }


        private void button1_Click(object sender, EventArgs e)
        {

            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);

          ..........................................................

      }

 



Mr.ZengCode  (02 มีนาคม 2553)   
IP : 58.137.188.243

//หากเรียก web service ที่ deploy บน SSL ก็แทรกคำสั่งนี้ไปนะครับ  เป็นการให้ application ของเรายอมรับ cer โดยอัตโนมัติ เพราะว่ามันไม่มี popup ให้เรายอมรับเหมือนเราเปิด browser อ่ะครับ หลังจากคำสั่งนี้แล้วจะเรียก web หรือ webservice ก็สุดแต่ใจจะไขว่คว้าเลยครับ


            ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);



Mr.ZengCode  (26 กุมภาพันธ์ 2553)   
IP : 203.144.180.65

 แทรก inline ในไฟล์ .aspx //MyDll = Dll ที่อยู่ใน Bin

<%
   string pageVariable1 = "Hello I love you";
   Response.Write(pageVariable1);
   MyDll.HelloWorld mydll = new MyDll.HelloWorld();
   Response.Write("<br>" + mydll.Say());
 %>


Name
Comment
Security CodeCAPTCHA Image

web hit counter

This page took 0.039113 seconds to load.