Article:
  Developing Web Services Using PHP
Subject:   saop example issue
Date:   2010-01-06 03:43:15
From:   johnyp@
here is the error i got can you please help me out to solved this issue.
i am just a new to webservices
Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in E:\www\webroot\webservices\soap-client.php:4 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'urn:localhost-c...', 1, 0) #1 [internal function]: SoapClient->__call('getCatalogEntry', Array) #2 E:\www\webroot\webservices\soap-client.php(4): SoapClient->getCatalogEntry('catalog1') #3 {main} thrown in E:\www\webroot\webservices\soap-client.php on line 4


here is my catalog.wsdl file


<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='Catalog'
targetNamespace='http://example.org/catalog'
xmlns:tns='http://example.org/catalog'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>


<message name='getCatalogRequest'>
<part name='catalogId' type='xsd:string'/>
</message>
<message name='getCatalogResponse'>
<part name='Result' type='xsd:string'/>
</message>


<portType name='CatalogPortType'>
<operation name='getCatalogEntry'>
<input message='tns:getCatalogRequest'/>
<output message='tns:getCatalogResponse'/>
</operation>
</portType>


<binding name='CatalogBinding' type='tns:CatalogPortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getCatalogEntry'>
<soap:operation soapAction='urn:localhost-catalog#getCatalogEntry'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>


<service name='CatalogService'>
<port name='CatalogPort' binding='CatalogBinding'>
<soap:address location='http://localwebservices/soap-server.php'/>
</port>
</service>
</definitions>



soap-server.php file


<?php
function getCatalogEntry($catalogId) {
if($catalogId=='catalog1')


return "<HTML>
<HEAD>
<TITLE>Catalog</TITLE>
</HEAD
<BODY>


<table border>
<tr><th>CatalogId</th>
<th>Journal</th><th>Section
</th><th>Edition</th><th>
Title</th><th>Author</th>
</tr><tr><td>catalog1</td>
<td>IBM developerWorks</td><td>
XML</td><td>October 2005</td>
<td>JAXP validation</td>
<td>Brett McLaughlin</td></tr>
</table>
</BODY>
</HTML>";


elseif ($catalogId='catalog2')


return "<HTML>
<HEAD>
<TITLE>Catalog</TITLE>
</HEAD
<BODY>


<table border>


<tr><th>CatalogId</th><th>
Journal</th><th>Section</th>
<th>Edition</th><th>Title
</th><th>Author
</th></tr><tr><td>catalog1
</td><td>IBM developerWorks</td>
<td>XML</td><td>July 2006</td>
<td>The Java XPath API
</td><td>Elliotte Harold</td>
</tr>
</table>
</BODY>
</HTML>";
}


ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("catalog.wsdl");
$server->addFunction("getCatalogEntry");
$server->handle();
?>


soap-client.php file


<?php
$client = new SoapClient("catalog.wsdl");
$catalogId='catalog1';
$response = $client->getCatalogEntry($catalogId);
echo $response;
?>

Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • saop example issue
    2010-01-06 18:38:41  Deepak Vohra | [View]

    Please refer
    http://bugs.php.net/bug.php?id=37054
    http://bugs.php.net/bug.php?id=31078

    Please let me know if you still get an error.