Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SOAP, PHP and IIS 1

Status
Not open for further replies.

Trevahaha

Programmer
Nov 21, 2002
129
US
I've enabled SOAP for PHP and have successfully used the client side of PHP SOAP. I'm trying to get basic "stockquote server" example to work. When I try to do make a SOAP server I get the following error:
Code:
The specified CGI application misbehaved by not returning a complete set of HTTP headers.  The headers it did return are:<p><p><pre>X-Powered-By: PHP/5.0.0
Content-Length: 522</pre>


I'm running PHP on IIS and I'm not sure how to get the headers corrected. Any help would be appreciated.

Thanks!
 
Well how would I do that?

My client script is this:
Code:
<?php
	$client = new SoapClient("[URL unfurl="true"]http://xxxxxx/StockQuote/stockquote.wsdl",array("trace"=>1,[/URL] "exceptions"=>0));
	$client->getQuote("ibm");
	print "<pre>\n";
	print "Request :\n" . htmlspecialchars($client->__getLastRequest()) . "\n";
	print "Response:\n" . htmlspecialchars($client->__getLastResponse()) . "\n";
	print "</pre>";
?>

I'm new to SOAP and especially PHP & SOAP... is there something in the WSDL file? the server.php file? :(
 
sorry.. here's also the other stuff:

server1.php
Code:
<?php
class QuoteService {
	private $quotes = array("ibm"=>98.42);

	public function getQuote($symbol){
		if (isset($this->quotes[$symbol])){
			return $this->quotes[$symbol];
		}else{
			throw new SoapFault("Server","Unknown Symbol '$symbol'.");
		}
	}

}

$server = new SoapServer("stockquote.wsdl");
$server->setClass("QuoteService");
$server->handle();
?>

stockquote.wsdl
Code:
<?xml version="1.0" encoding="UTF-8" ?> 
<definitions name='StockQuote' 
  targetNamespace='[URL unfurl="true"]http://xxxxx/StockQuote'[/URL] 
  xmlns:tns=' [URL unfurl="true"]http://xxxxx/StockQuote'[/URL] 
  xmlns:soap='[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/soap/'[/URL] 
  xmlns:xsd='[URL unfurl="true"]http://www.w3.org/2001/XMLSchema'[/URL] 
  xmlns:soapenc='[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/'[/URL] 
  xmlns:wsdl='[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/'[/URL] 
  xmlns='[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/'>[/URL] 

<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> 

<binding name='StockQuoteBinding' type='tns:StockQuotePortType'> 
  <soap:binding style='rpc' 
    transport='[URL unfurl="true"]http://schemas.xmlsoap.org/soap/http'/>[/URL] 
  <operation name='getQuote'> 
    <soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/> 
    <input> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/'/>[/URL] 
    </input> 
    <output> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/'/>[/URL] 
    </output> 
  </operation> 
</binding> 

<service name='StockQuoteService'> 
  <port name='StockQuotePort' binding='StockQuoteBinding'> 
    <soap:address location='[URL unfurl="true"]http://xxxxx/StockQuote/server1.php'/>[/URL] 
  </port> 
</service> 
</definitions>

the "xxxxx" are to replace the server URL :) (just for privacy)
 
More discovery...

Could it be related to the libxml2.dll?

I noticed if I remove this completely.. I get the same error. Could it not be generating XML correctly?
 
OK I got it to work.. and for future people with this problem.. it seems you have to insert the line:
Code:
printf("HTTP/1.0 200 OK\n");
[code]
simply putting Header("Status: 200") or even header("HTTP/1.0 200 OK") does not work.
 
Actually... Let me clarify that.

printf("");

-- or else it's not a valid XML file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top