Link to home
Start Free TrialLog in
Avatar of hallikpapa
hallikpapa

asked on

SOAP-ERROR: Parsing WSDL

I am trying to setup a soap web service, but am getting errors both from the client, and from the WSDL. The server, client, & wsdl file are all posted below.

Here is the errors I get in the web browser, I am assuming it just can't parse the WSDL file (which has a warning). Please note, when I go to the http://localhost/test.wsdl in my browser, it finds it.


Warning: SoapClient::SoapClient() [soapclient.soapclient]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/site/web/client.php on line 2

Warning: SoapClient::SoapClient(http://localhost/test.wsdl) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/site/client.php on line 2

Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://localhost/test.wsdl" in /var/www/site/web/client.php on line 2

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/test.wsdl' in /var/www/site/web/client.php on line 2


And on the "binding name =" line in my wsdl, here is the warning I get in Eclipse:

WS-I: (BP2406) The use attribute of a soapbind:body, soapbind:fault, soapbind:header and soapbind:headerfault does not have value of "literal".


Client
~~~~~~~~
<?php
$soap = new SoapClient("http://localhost/test.wsdl", array('exceptions' => 0));
try
{
echo $soap->getUsers(1);
 
}
catch (SoapFault $exception) 
{
echo 'EXCEPTION='.$exception; 
} 
 
 
 
?>
~~~~~~~~~~~~~~~
Server
~~~~~~~~~~~~~~~
<?php
function getUsers($difficulty) {
$puzzles[1][] = "First";
$puzzles[2][] = "Second";
$puzzles[3][] = "Third";
$randpuz = array_rand($puzzles[$difficulty]);
return $puzzles[$difficulty][$randpuz];
}
$server = new SoapServer("test.wsdl");
$server->addFunction("getUsers");
$server->handle();
?>
 
~~~~~~~~~~~~~~~~~~~~~~
WSDL
~~~~~~~~~~~~~~~~~~~~~~
<?xml version ='1.0' encoding ='UTF-8' ?> 
<definitions 
	name='AfterAction' 
	targetNamespace='urn:AfterAction' 
	xmlns:typens='urn:AfterAction' 
	xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
	xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' 
	xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' 
	xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
	xmlns='http://schemas.xmlsoap.org/wsdl/'>
	<message name='getUsers'>
		<part name='difficulty' type='xsd:int' />
	</message>
	<message name='getUsersResponse'>
		<part name='return' type='xsd:string' />
	</message>
	<portType name='AfterActionPort'>
		<operation name='getUsers'>
			<input message='typens:getUsers' />
			<output message='typens:getUsersResponse' />
		</operation>
	</portType>
	<binding name='AfterActionBinding' type='typens:AfterActionPort'>
		<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' />
		<operation name='getUsers'>
			<soap:operation soapAction='urn:AfterActionAction' />
			<input>
				<soap:body use='encoded' namespace='urn:AfterAction'
					encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
			</input>
			<output>
				<soap:body use='encoded' namespace='urn:AfterAction'
					encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
			</output>
		</operation>
	</binding>
	<service name='AfterActionService'>
		<port name='AfterActionPort' binding='typens:AfterActionBinding'>
			<soap:address location='http://localhost/server.php' />
		</port>
	</service>
</definitions>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sekurity863
Sekurity863
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hallikpapa
hallikpapa

ASKER

Sorry for changing that since it cause confusion, I removed the actual URL. It's actually hosted on a linux image in VMWare on this machine. I have a virtual host setup in apache, and an entry in my windows host file to point to that location.

It's a test website I have been working on and it resolves just fine (trying to recreate  a real world scenario).

I just added a web service this morning for testing, and it's giving me these errors.
What I meant was, instead of it being localhost, it's actually dev-mysite.com and it resolves correctly.
You know what, you were right. I changed it to the IP address, and it works?

Why can't it resolve it correctly when web browsers do? what am I missing?
What version of PHP?

If I am understanding you correctly, PHP is actually pulling the address as localhost but it just resolves localhost correctly?

PHP has a known bug in PHP > 5.0.2 that can be resolved by upgrading:
http://snaps.php.net/php5-latest.tar.gz

Please review this bug report for reference:
http://bugs.php.net/bug.php?id=31308&edit=1
It was definitely a connection issue due in part to the host because:
php_network_getaddresses:
getaddrinfo failed <-- shows it couldnt get the address
It's actually not a problem with the php or wsdl, but the way it's resolving I guess?

The only thing I changed was from domain name to IP address, and it works. Why would this occur? Is there something I am forgetting to make it resolve domain names?

Like I said, if I type in the IP address or domain name in any web browser, I get the same page.
PHP 5.2.6 (cli) (built: Dec  2 2008 16:28:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    with Zend Core v2.5.2, Copyright (c) 1998-2006, by Zend Technologies
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.6, Copyright (c) 1998-2007, by Zend Technologies
    with Zend Debugger v5.2.15, Copyright (c) 1999-2008, by Zend Technologies

The web server is on the same machine that your running the web browser?

If the web server is on linux and its not the same environment the browser is in, there needs to be an exception to the /etc/hosts so that localhost will reverse
Those entries are in the /etc/hosts

When I ping the domain name, it responses exactly as I would expect. Perhaps I am missing some information in my soap client?



weird.. not exactly sure but im sure it has to do with php not being able to reverse the host / ip. sorry i cant be more help but i hope my first response got you where you need to be. good luck!