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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I am trying to run a simple example. I cant load WSDL file. Following is my code:
WSDL file
dotNet.wsdl
[syntax="xml"]
<?xml version="1.0"?>
<definitions name="NetPuzzle" targetNamespace="urn:NetPuzzle" xmlns:
typens="urn:NetPuzzle" 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/">
</definitions>
<message name="getPuzzle">
<part name="difficulty" type="xsd:int" />
</message>
<message name="getPuzzleResponse">
<part name="return" type="string" />
</message>
<portType name="NetPuzzlePort">
<operation name="getPuzzle">
<input message="typens:getPuzzle" />
<output message="typens:getPuzzleResponse" />
</operation>
</portType>
<binding name="NetPuzzleBinding" type="typens:NetPuzzlePort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getPuzzle">
<soap:operation soapAction="urn:NetPuzzleAction" />
<input>
<soap:body use="encoded" namespace="urn:NetPuzzle"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:NetPuzzle"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="NetPuzzleService">
<port name="NetPuzzlePort" binding="typens:NetPuzzleBinding">
<soap:address location="http://localhost/server.php" />
</port>
</service>
<?php
function getPuzzle($difficulty) {
$puzzles[1][] = “What is the best web mag in the world?”;
$puzzles[2][] = “What is the air-speed velocity of an unladen swallow?”;
$puzzles[3][] = “What is the meaning of life?”;
$randpuz = array_rand($puzzles[$difficulty]);
return $puzzles[$difficulty][$randpuz];
}
$server = new SoapServer(“dotnet1.wsdl”);
$server->addFunction(“getPuzzle”);
$server->handle();
?>
When I try to run this example I got followibng error:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/dotNet.wsdl' in C:\wamp\www\client.php:2 Stack trace: #0 C:\wamp\www\client.php(2): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in C:\wamp\www\client.php on line 2
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by phpcoder on Tue Jul 17, 2007 7:57 am, edited 1 time in total.
should be xmlns:typens, same with xmlns:soap and xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/".
Why do you close the definitions element immediately? Move </definitions> to the end of the document.
Who or what created this wsdl file?
should be xmlns:typens, same with xmlns:soap and xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/".
Why do you close the definitions element immediately? Move </definitions> to the end of the document.
Who or what created this wsdl file?
thanks for you help. Now I am getting this error:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\client.php:3 Stack trace: #0 [internal function]: SoapClient->__call('getPuzzle', Array) #1 C:\wamp\www\client.php(3): SoapClient->getPuzzle(1) #2 {main} thrown in C:\wamp\www\client.php on line 3
response: <br />
<b>Parse error</b>: syntax error, unexpected $end in <b>C:\wamp\www\server.php</b> on line <b>10</b><br />
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\client.php:12 Stack trace: #0 [internal function]: SoapClient->__call('getPuzzle', Array) #1 C:\wamp\www\client.php(12): SoapClientDebug->getPuzzle('1') #2 {main} thrown in C:\wamp\www\client.php on line 12
phpcoder wrote:response: <br />
<b>Parse error</b>: syntax error, unexpected $end in <b>C:\wamp\www\server.php</b> on line <b>10</b>
There's a syntax error in your server.php
Yeah it says there is an syntax error. But I have simple server.php file and I cant see any error in that file . Please check my server file and tell me whats the error
Server.php
<?php
function getPuzzle($difficulty) {
$puzzles = "What is the best web mag in the world?";
return $puzzles;
}
$server = new SoapServer("http://192.168.1.55/dotNet.wsdl");
$server->addFunction("getPuzzle”);
$server->handle();
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="volka"][quote="phpcoder"]$server->addFunction("getPuzzle”)[/quote]replace ” by "[/quote]
Now I am getting this error :
request: [syntax="xml"]<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:NetPuzzle" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getPuzzle><difficulty xsi:type="xsd:int">1</difficulty></ns1:getPuzzle></SOAP-ENV:Body></SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:NetPuzzle" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getPuzzleResponse><return xsi:type="xsd:string">What is the best web mag in the world?</return></ns1:getPuzzleResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\client.php:12 Stack trace: #0 [internal function]: SoapClient->__call('getPuzzle', Array) #1 C:\wamp\www\client.php(12): SoapClientDebug->getPuzzle('1') #2 {main} thrown in C:\wamp\www\client.php on line 12
I am sorry I am anoying you but as I told you I am new to soap and xml.
Thanks
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]