For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > Help please trying to create web services sample?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help please trying to create web services sample?
M

2005-02-19, 3:55 pm

Hi Folks,

Hope someone can help?

I followed your instructions on:

http://www.devx.com/webdev/Article/22338/0/page/4

and I get the following error when I tried to create my own server:

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] looks like we
got no XML document in
c:\Inetpub\wwwroot\Php\DummyWebService\M
yWebServerClient.php:20 Stack trace:
#0 c:\Inetpub\wwwroot\Php\DummyWebService\M
yWebServerClient.php(20):
SoapClient->getTemp('getTemp', Array) #1 {main} thrown in
c:\Inetpub\wwwroot\Php\DummyWebService\M
yWebServerClient.php on line 20



Any Ideas what I am doing wrong?

Be most grateful if someone could help,

Cheers,

Martin

URL Used:

http://localhost/php/DummyWebServic...p?zipcode=10036

---------------------------------------------------------------------------------------------------------------------------
Server.php

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php

//include ( "nusoap.php" );

function getTemp($zip) {
$temp = rand(40,80);
return $temp;
}

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("temperature.wsdl");
$server->addFunction("getTemp");
$server->handle();


//phpinfo();


?>
</body>
</html>

****************************************
****************************************
********

MyWebServerClient.php

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php

/*
$ZIP = $_GET['zipcode'];
$client = new SoapClient
("http://www.xmethods.net/sd/2001/TemperatureService.wsdl");
$return = $client->getTemp($ZIP);
echo("Temperature is: " . $return);
*/

//$ZIP = $_GET['zipcode'];
$ZIP = "10036";
$client = new SoapClient("temperature.wsdl");
$return = $client->getTemp($ZIP);
echo("Temperature is: " . $return);


?>
</body>
</html>

****************************************
*************************************tem
perature.wsdl<?xml version ='1.0' encoding ='UTF-8' ?><definitions name='Temperature'targetNamespace='http:
//example.org/temperature'xmlns:tns=' http://example.org/temperatur
e '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='
getTempRequest'><part name='symbol' type='xsd:string'/></message><message name='getTempResponse'><part name='Result' type='xsd:float'/></message><portType name='TempPortType'><operation name='getTemp'><input message='tns:getTempRequest'/><output message='
tns:getTempResponse'/></operation></portType><binding name='TempBinding' type='tns:TempPortType'><soap:binding style='rpc'transport='http://schemas.xmlsoap.org/soap/http'/><operation name='getTemp'><soap:operation soapAction='urn:localhost-temperature#get
Temp'/><input><soap:body use='encoded' namespace='urn:localhost-temperature'encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/></input><output><soap:body use='encoded' namespace='urn:localhost-temperature'encodingStyle='http://schemas.xmlsoap.org/
soap/encoding/'/></output></operation></binding><service name='TemperatureService'><port name='TempPort' binding='TempBinding'><soap:address location='http://localhost/Php/DummyWebService/server.php'/></port></service></definitions>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com