Performance issue

From: Date: Tue, 26 Nov 2002 22:26:09 +0000
Subject: Performance issue
Groups: php.soap 
Request: Send a blank email to php-soap+get-315@lists.php.net to get a copy of this message
I wrote a simple PHP/SOAP application and send SOAP messages to my Web Service. I see my web-service accept the message, process it and respond. This all happens in less than a second, but for some reason my php soap client takes another 60 seconds to parse through the message. Even if just use fpassthru($socket) it still takes about the same amount of time. Anyone know what could cause the delay? I've included my complete code for my client app. Thanks for any input/feedback. Paul Faulkner <TITLE>Testing SOAP and PHP</TITLE> <?php /* XML functions */ function CreateParser() { $xmlParser = xml_parser_create(); if ( $xmlParser == false ) { die( 'Cannot create an XML parser handle.' ); } return $xmlParser; } function SetOptions( $xmlParser ) { xml_parser_set_option( $xmlParser, XML_OPTION_CASE_FOLDING, false ); } function SetHandlers( $xmlParser ) { xml_set_element_handler( $xmlParser, 'HandleBeginTag', 'HandleEndTag' ); xml_set_character_data_handler( $xmlParser, 'HandleCharacterData' ); } function OpenFile( $fileName ) { if ( !( $fp = fopen( $fileName, 'r' ) ) ) { die( 'Cannot open the XML file: ' . $fileName ); } return $fp; } function Parse( $xmlParser, $fp ) { $parsedOkay = xml_parse( $xmlParser, $fp); if ( !$parsedOkay && xml_get_error_code( $xmlParser ) != XML_ERROR_NONE ) { die( 'XmlParse error: ' . xml_error_string( xml_get_error_code( $xmlParser ) ) . ' at line ' . xml_get_current_line_number( $xmlParser ) ); } /* while ( $data = fread( $fp, 4096 ) ) { $parsedOkay = xml_parse( $xmlParser, $data, feof( $fp ) ); if ( !$parsedOkay && xml_get_error_code( $xmlParser ) != XML_ERROR_NONE ) { die( 'XmlParse error: ' . xml_error_string( xml_get_error_code( $xmlParser ) ) . ' at line ' . xml_get_current_line_number( $xmlParser ) ); } } */ } function FreeParser( $xmlParser ) { $freedOkay = xml_parser_free( $xmlParser ); if( !$freedOkay ) { die( 'You did not pass a proper XML Parser to this function.' ); } } function HandleBeginTag($parser, $name, $attribs) { $GLOBALS['currentTag'] = $name; switch($name) { case "Response": /*print ("I am at <Response>");*/ break; default: /*print ("At $name tag");*/ } } function HandleEndTag($parser, $name) { } function HandleCharacterData( $parser, $data ) { global $currentTag; switch( $currentTag ) { case 'Response': appendToGlobal( $currentTag, $data ); break; } } function AppendToGlobal( $variableName, $value ) { global ${$variableName}; ${$variableName} .= $value; ${$variableName} = trim(${$variableName}); echo "dummy=xyz&message=". ${$variableName}; } /* MAIN APPLICATION */ $xmlParser = CreateParser(); SetOptions( $xmlParser ); SetHandlers( $xmlParser ); $soapmessage = <<<MYSOAPMESSAGE <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <REGISTRYMSG><FIELD1>abcde</FIELD1></REGISTRYMSG> </ns1:getTemp> </SOAP-ENV:Body> </SOAP-ENV:Envelope> MYSOAPMESSAGE; /* Strip escape slashes to handle magic_quotes_gpc condition */ $holdsoap=stripslashes($soapmessage); $messagesize=strlen($holdsoap); /* Create HTTP header */ $query="POST ". "/jaxm-serverapp/receiver". " HTTP/1.1\r\n". "Host: ". $_GET['servicehost']. ":". $_GET['serviceport']. "\r\n". "Content-Type: text/xml; charset=UTF-8". " \r\n". "Content-Length:$messagesize\r\n". "SOAPAction:". "\r\n". "\r\n"; /* Open a tcp/ip port */ $fp=fsockopen($_GET['servicehost'],$_GET['serviceport']); if(!$fp) { print "Unable to connect to web service !"; } else { /* Inject the header and the soap message which was supplied by the form */ fputs($fp,$query,strlen($query)); fputs($fp,$query,"<?xml version='1.0'?>"); fputs($fp,$holdsoap,$messagesize); } /* Print out SOAP server Response to a web form */ /*print "<html><body>"; print "<br>"; print $query; print "<br>"; print "my soap message"; print "<br>"; print $soapmessage; print "<form>"; print "SOAP Response Message<br/><textarea name='resultmessage' rows='30' nowrap cols='80'>"; */ $idx = 0; $result = ""; $resultPartial = " "; while(!feof($fp)) { $resultLine = fgets($fp, 128); if ($resultPartial != "<?xml") { $resultPartial = substr($resultLine, 0, 5); } if ($resultPartial == "<?xml") { $result .= $resultLine; } } /* print "Checking Result Array"; if (isset($result)) { print $result; } else { print "NOT SET"; } print "==================="; */ /*echo fpassthru($fp);*/ /* $http_response = fpassthru($fp); print $http_response; if (isset($http_response)) { list($http_headers, $http_content) = explode("\r\n\r\n",$http_response); } else { print "NOT SET"; } print "---"; print $http_content; print "---"; */ Parse( $xmlParser, $result ); FreeParser( $xmlParser ); /* print "</textarea></form></body></html>"; */ /*echo "firstName=abc&message=$temp";*/ ?>

« previous php.soap (#315) next »