ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us    

Facebook   


MAIN MENU
News
Php Tips
Android Programming
Design Pattern By PHP
C# using Linq น่าใช้จริงๆ
C# Tips & Technique
C# Design Pattern
Linux Quick Tips
Java & JavaScript Tips
Database & SQL
ZengCode Framework Guide
Zeng Code Code
Programming
IPhone (Tips and Trick)

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

     Send Binary With Web Services in PHP  (2009-06-26)

อาจจะมีบางคนที่ต้องการทำ web service ซึ่งมันเป็น message oriented remote procedure call (แอบยืมภาษาเทพจาก narisa มาใช้ หุหุ)
แล้วเราจะส่งไฟล์ที่เป็น Binary ได้อย่างไร เอาหล่ะซิ่ มันมีทางออกครับ

อ่ะแล้วทำไงหล่ะ ก็ใน php มันมี function base64 (ซึ่งภาษาอื่นก็มี) เราก็แปลงไฟล์ binary ต่างๆ เหล่านั้นโดยเข้ารหัสมันด้วย
ิbase64encode มันก็จะกลายเป็นชุดอักขระชุดนึง ก็จะสามารถส่งไป webservice ได้

ส่วน application ที่เรียกใช้ webservice เมื่อได้รับก้ใช้ function  base64 decode กลับ โอ้ ง่ายไหมหนอน้องเอ๋ย

โดยมี WSDl ที่มี xml schema คล้ายนี้

<xs:element name="Person">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
                <xs:element name="age" type="xs:int"/>
                <xs:element name="photo" type="xs:base64Binary"/>
            </xs:sequence>
        </xs:complexType>
</xs:element>  element photo เราก็เข้ารหัสด้วย base64 ซะ 

 


Comment
Name
Comment
Security CodeCAPTCHA Image

easy tracking
avis car rental discount code

This page took 0.238729 seconds to load.