Php Asp Net Interoperability Rc Jao


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Show URL Rewrite (for mod_rewrite) Show WinCache Show Database Manager extension Show running wordpress – permalinks set on web.config
  • PHP Opcode Cache PHP is a script processing engine that reads an input stream of data that contains text and/or PHP instructions and produces another stream of data, most commonly in the HTML format. This means that on a Web server, the PHP engine reads, parses, compiles, and executes a PHP script each time that it is requested by a Web client. The reading, parsing, and compilation operations put additional load on the Web server’s CPU and file system and thus affect the overall performance of a PHP Web application. The PHP bytecode (opcode) cache is used to store the compiled script bytecode in shared memory so that it can be reused by the PHP engine for subsequent executions of the same script. File Cache Even with the PHP bytecode cache enabled, the PHP engine has to accesses the script files on a file system. When PHP scripts are stored on a remote universal naming convention (UNC) file share, the file operations introduce a significant performance overhead. The Windows Cache Extension for PHP includes a file cache that is used to store the content of the PHP script files in shared memory, which reduces the amount of file system operations performed by PHP engine. Relative File Path Cache PHP scripts very often include or operate with files by using relative file paths. Every relative file path has to be converted to an absolute file path by the PHP engine. When a PHP application uses many PHP files and accesses them by relative paths, the operation of resolving relative paths to absolute paths may have a negative impact on the application’s performance. The Windows Cache Extension for PHP provides a relative file path cache, which is used to store the mappings between relative and absolute file paths, thereby reducing the number of relative path resolutions that the PHP engine has to perform.
  • Consuming without WSDL and with WSDL
  • definitions The definitions element must be the root element of all WSDL documents. It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here. types The types element describes all the data types used between the client and server. WSDL is not tied exclusively to a specific typing system, but it uses the W3C XML Schema specification as its default choice. If the service uses only XML Schema built-in simple types, such as strings and integers, the types element is not required. A full discussion of the types element and XML Schema is deferred to the end of the chapter. message The message element describes a one-way message, whether it is a single message request or a single message response. It defines the name of the message and contains zero or more message part elements, which can refer to message parameters or message return values. portType The portType element combines multiple message elements to form a complete one-way or round-trip operation. For example, a portType can combine one request and one response message into a single request/response operation, most commonly used in SOAP services. Note that a portType can (and frequently does) define multiple operations. binding The binding element describes the concrete specifics of how the service will be implemented on the wire. WSDL includes built-in extensions for defining SOAP services, and SOAP-specific information therefore goes here. service The service element defines the address for invoking the specified service. Most commonly, this includes a URL for invoking the SOAP service.
  • Php Asp Net Interoperability Rc Jao

    1. 1. Rodney C. Jao Microsoft MVP for Device Application Development
    2. 2. Agenda <ul><li>PHP in IIS7 </li></ul><ul><li>PHP-ASP.NET Interoperability using SOAP </li></ul>
    3. 3. Why this session? <ul><li>A large number of PHP based business applications are running on Windows Servers </li></ul><ul><li>Discuss the recent developments on running PHP applications on Windows Server </li></ul><ul><li>Leverage existing code investments in PHP and ASP.NET via interoperability </li></ul><ul><li>Take advantage of SOAP to extend web applications and integrate regardless of language and platform. </li></ul>
    4. 4. PHP in Windows Server <ul><li>PHP runs on Windows Server via Microsoft Internet Information Server </li></ul><ul><ul><li>IIS 7 in Windows Server 2008 SP2 </li></ul></ul><ul><ul><li>IIS 7.5 in Windows Server 2008 R2 </li></ul></ul><ul><li>Execution Models </li></ul><ul><ul><li>Traditional model is based on instantiating PHP for every session (CGI) </li></ul></ul><ul><ul><li>Later released an ISAPI version for faster execution. </li></ul></ul>
    5. 5. <ul><li>ISAPI </li></ul><ul><li>CGI </li></ul>IIS Execution Models for PHP IIS PHP PHP PHP PHP PHP executes as an external process. Stable however there’s a challenge in performance. IIS PHP as In-process. Speeds up performance but issues on non thread safe extensions. ISAPI
    6. 6. IIS Execution Models Extension to CGI allowing reuse of a process. Advantages Easy to Configure Faster than CGI More stable than PHP on ISAPI Can run non- thread-safe versions of PHP Invokes a process for each request. Advantages Easy to Configure Stable Execution Disadvantages Slow due to I/O Overhead of Process Creation Loaded as extension in process. Advantages Better Performance Disadvantages Many PHP Applications are not Thread-Safe
    7. 7. Introduction: FastCGI <ul><li>FastCGI is an enhancement to the CGI model </li></ul><ul><ul><li>High performance PHP applications on Windows Server </li></ul></ul><ul><ul><li>Reusable pool of processes </li></ul></ul><ul><ul><li>No startup and shutdown for each PHP session </li></ul></ul><ul><ul><li>Stable execution of non thread safe PHP extensions </li></ul></ul><ul><li>Available for IIS 6 (Windows Server 2003), IIS 7 (Windows Server 2008 SP2), and IIS 7.5 (Windows Server 2008 R2) </li></ul>
    8. 8. Setting up PHP and FastCGI <ul><li>Enable FastCGI in IIS </li></ul><ul><ul><li>Do Windows Update – for latest fix and patches </li></ul></ul><ul><li>Download the latest edition of PHP </li></ul><ul><ul><li>Unzip to desired destination folder </li></ul></ul><ul><li>Open PHP.INI </li></ul><ul><ul><li>fastcgi.impersonate = 1 </li></ul></ul><ul><ul><li>cgi.fix_pathinfo=1 </li></ul></ul><ul><ul><li>cgi.force_redirect = 0 </li></ul></ul><ul><ul><li>extension_dir </li></ul></ul><ul><ul><li>Uncomment extensions (php_soap.dll) </li></ul></ul>
    9. 9. Setting up PHP and FastCGI <ul><li>Configure IIS to handle PHP </li></ul><ul><ul><li>IIS Manager – Handler Mappings </li></ul></ul><ul><li>Set PHP Process Recycling behavior </li></ul><ul><ul><li>PHP_FCGI_MAX_REQUESTS </li></ul></ul>
    10. 10. DEMO <ul><li>Setting up PHP and FastCGI in IIS7 </li></ul>
    11. 11. Microsoft Web Platform Installer <ul><li>Downloads and configures your web server, database, and tools needed to develop and run web applications. </li></ul>
    12. 12. DEMO <ul><li>Web Platform Installer </li></ul>
    13. 13. WinCache <ul><li>PHP accelerator to speed up PHP applications in Windows – without code rewrite </li></ul><ul><ul><li>PHP Opcode Cache </li></ul></ul><ul><ul><li>File Cache </li></ul></ul><ul><ul><li>Relative File Path Cache </li></ul></ul>
    14. 14. PHP-ASP.NET Interoperability <ul><li>Why SOAP? </li></ul><ul><ul><li>Simple Object Access Protocol </li></ul></ul><ul><ul><li>SOAP is a standard </li></ul></ul><ul><ul><li>Based on XML </li></ul></ul><ul><ul><li>Exists on almost every platform </li></ul></ul><ul><ul><li>Flexible </li></ul></ul><ul><ul><li>Firewall friendly </li></ul></ul><ul><li>Invoking methods via xml messages </li></ul><ul><li>Pass / return data (integers, decimal, string, classes, objects, images, etc) via xml </li></ul><ul><li>Enabler for Service Oriented Architecture </li></ul>
    15. 15. How SOAP works Client Server Determine Service Method call (xml) Server response (xml)
    16. 16. SOAP <ul><li>Components </li></ul><ul><ul><li>WSDL – Web Service Definition Language (also called a contract) </li></ul></ul><ul><ul><ul><li>Describes the server data, methods, and ports </li></ul></ul></ul><ul><ul><li>SOAP Data </li></ul></ul><ul><ul><li>SOAP Methods </li></ul></ul>
    17. 17. DEMO <ul><li>WSDL and Web Service in ASP.NET </li></ul>
    18. 18. SOAP in PHP <ul><li>As PHP extension </li></ul><ul><ul><li>Writen in C </li></ul></ul><ul><ul><li>[PHP_SOAP] </li></ul></ul><ul><ul><li>extension=php_soap.dll </li></ul></ul><ul><li>Using API’s written in PHP </li></ul><ul><ul><li>PEAR::SOAP ( </li></ul></ul><ul><ul><li>NuSOAP ( </li></ul></ul><ul><ul><li>eZ SOAP ( </li></ul></ul>
    19. 19. Consuming Web Services in PHP <ul><li>Use SoapClient </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>$client = new soapclient(&quot;http://myserver/service.svc?wsdl&quot;); </li></ul></ul><ul><ul><li>$ret = $client-> HelloWorld (); </li></ul></ul><ul><ul><li>echo &quot;from ws = &quot; . $ret-> HelloWorldResult ; </li></ul></ul><ul><ul><li>?> </li></ul></ul><ul><li>XML messages are hidden </li></ul><ul><li>Call SOAP methods as if they are PHP functions </li></ul>
    20. 20. DEMO <ul><li>Consuming Web Services in PHP </li></ul>
    21. 21. WSDL Caching <ul><li>Improving SOAP call performance </li></ul><ul><ul><li>[soap] soap.wsdl_cache_enabled = &quot;1&quot; ; enables or disables WSDL caching feature soap.wsdl_cache_dir = &quot;/tmp&quot; ; sets the directory name where SOAP extension will put cache files soap.wsdl_cache_ttl = &quot;86400&quot; ; (time to live) sets the number of second while cached file will be used ; instead of original one </li></ul></ul>
    22. 22. Creating SOAP Services in PHP <ul><li>Create your SOAP service WSDL </li></ul><ul><li>Define your SOAP data and methods </li></ul><ul><ul><li><?php </li></ul></ul><ul><ul><li>function add(int $x, int $y) { </li></ul></ul><ul><ul><li>return $x+$y; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>ini_set(&quot;soap.wsdl_cache_enabled&quot;, &quot;0&quot;); // disabling WSDL cache </li></ul></ul><ul><ul><li>$server = new SoapServer(&quot;myservice.wsdl&quot;); </li></ul></ul><ul><ul><li>$server->addFunction(&quot;add&quot;); </li></ul></ul><ul><ul><li>$server->handle(); </li></ul></ul><ul><ul><li>?> </li></ul></ul><ul><li>Replace addFunction() with setClass() to expose classes </li></ul>
    23. 23. Writing WSDL <ul><li>Sections </li></ul><ul><ul><li>Definition </li></ul></ul><ul><ul><li>Message </li></ul></ul><ul><ul><li>Port type </li></ul></ul><ul><ul><li>Binding </li></ul></ul><?xml version ='1.0' encoding ='UTF-8' ?> < definition s name='StockQuote' targetNamespace='' /'> < message name='getQuoteRequest'> <part name='symbol' type='xsd:string'/> </message> < message name='getQuoteResponse'> <part name='Result' type='xsd:float'/> </message> < portType name='StockQuotePortType'> <operation name='getQuote'> <input message='tns:getQuoteRequest'/> <output message='tns:getQuoteResponse'/> </operation> </portType> < bindin g name='StockQuoteBinding' type='tns:StockQuotePortType'> <soap:binding style='rpc' transport=''/> <operation name='getQuote'> <soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/> <input> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle=''/> </input> <output> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle=''/> </output> </operation> </binding> <service name='StockQuoteService'> <port name='StockQuotePort' binding='StockQuoteBinding'> <soap:address location='http://[insert real path here]/server1.php'/> </port> </service> </definitions>
    24. 24. DEMO <ul><li>Consuming PHP SOAP Service in ASP.NET </li></ul>
    25. 25. What Next? <ul><li>Download Microsoft Web Platform Installer </li></ul><ul><li>Run PHP Applications in FastCGI + WinCache </li></ul><ul><li>Run your production PHP web applications in Windows Server </li></ul><ul><li>Integrate and interoperate existing systems using SOAP </li></ul>
    26. 26. Resources <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li>BizSpark and Website Spark </li></ul><ul><li> </li></ul>