Proper XML Response ( PHP Web Service )

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Proper XML Response ( PHP Web Service )

Post by dimitris »

I created a web service which returns a success answer to the client:

Code: Select all

$xmlText='<?xml version="1.0" encoding="utf-16"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><LoginResponse><Message>Success</Message></LoginResponse></soap:Body></soap:Envelope>';
 
    
    header("Content-Length:".strlen($xmlText));
    header("Cache-Control:private, max-age=0");
    header("Content-Type:text/xml; charset=utf-8");
    $time = time() - 60;
    header("Date:".gmdate('D, d M Y H:i:s', $time).' GMT');
    header("X-Powered-By:PHP");
    echo $xmlText;
The problems is that the clients seems unable to get the message! When i run the page from a browser it seems as a correct xml response but when i tried wireshark it displayed that there is no HTTP/xml protocol for transmission...It sends a Frame with my headers (HTTP protocol - HTTP 1.1 200 OK) and then it sends another frame with the actual xml message (HTTP Protocol - Continuation or non-HTTP traffic)

any ideas how to send the xml response to the client it reaches me correctly?
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Re: Proper XML Response ( PHP Web Service )

Post by dimitris »

I noticed that every php example for printing xml on a page using headers is quite different from native xml files e.g. sample.xml

Using Network Analyzer Wireshark i captured:

Get create.response.php
Protocol Info
HTTP HTTP/1.1 200 OK
HTTP Continuation or non-HTTP traffic

Get sample.xml
HTTP/XML HTTP/1.1 200 OK

Any ideas? I want to have the same results as a normal xml file!
Post Reply