LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-29-2006, 07:57 PM   #1
eikeland
Member
 
Registered: Nov 2004
Location: Newport, RI, USA
Distribution: Mandriva 2006
Posts: 125

Rep: Reputation: 15
Need help creating webservice and WSDL file to use with PHP


Hi,

I am having some problems creating a WSDL file. The file was created in JDeveloper, and validates, but when I try calling a service from a PHP program, I get an error.
This is the WSDL file (gindex.wsdl):

<definitions targetNamespace="urn:gindex"
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:gindex"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:types="http://gindex.xsd">
<types>
<schema targetNamespace="http://gindex.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<element name="id" type="int"/>
<element name="coursename" type="string"/>
</schema>
</types>
<service name="gindexService">
<port name="gindexServiceSOAPhttpPort" binding="tns:gindexSOAPhttp">
<soap:address location="http://192.168.1.3:9990/serverGindex.php"/>
</port>
</service>
<message name="gindexRequestMessage">
<part name="id" element="types:id"/>
</message>
<message name="gindexResponseMessage">
<part name="coursename" element="types:coursename"/>
</message>
<portType name="Gindex">
<operation name="processgindex">
<input message="tns:gindexRequestMessage"/>
<output message="tns:gindexResponseMessage"/>
</operation>
</portType>
<binding name="gindexSOAPhttp" type="tns:Gindex">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="processgindex">
<soapperation soapAction="urn:gindex/processgindex"/>
<input>
<soap:body use="literal" parts="id"/>
</input>
<output>
<soap:body use="literal" parts="coursename"/>
</output>
</operation>
</binding>
</definitions>


This is the server (serverGindex.php):

<?php
class gIndexService {
echo "\na";
private $coursename = array(1 => "Newport Country Club");
echo "test";
function processindex($id) {
echo "In processindex";
if (isset($this->coursename[$id])) {
return $this->coursename[$id];
} else {
throw new SoapFault("Server","Unknown Symbol '$symbol'.");
echo "\naa";
}
}
}

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


This is the client (clientGIndex.php):

<?php
//The SOAP server for this client is serverGIndex.php
//The WSDL file is GIndex.wsdl
print "<pre>Entering the client";
$client = new SoapClient("gindex.wsdl", array("trace"=> 1, "exceptions" => 1));

try{
print "<pre>Calling processindex.";
$client->processindex(1);
//$client->gindexService(1);
}catch(SoapFault $exception){
echo $exception;
}
print "<pre>Exiting the client";
?>


When I enter the clientGIndex.php, I get the following output:

Entering the client

Calling processindex.SoapFault exception: [SOAP-ENV:Client] Function ("processindex") is not a valid method for this service in /var/www/html/clientGIndex.php:9
Stack trace:
#0 /var/www/html/clientGIndex.php(9): SoapClient->__call('processindex', Array)
#1 /var/www/html/clientGIndex.php(9): SoapClient->processindex(1)
#2 {main}

Exiting the client


Not sure what the problem is here. I would think the WSDL file is correct since it validates, and there isn't really much to the client and server.
 
Old 10-31-2006, 10:24 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Doesn't

Code:
 <operation name="processgindex">
suggest that the function that the client calls should be processgindex, not processindex as you've got in your code?
 
Old 10-31-2006, 08:37 PM   #3
eikeland
Member
 
Registered: Nov 2004
Location: Newport, RI, USA
Distribution: Mandriva 2006
Posts: 125

Original Poster
Rep: Reputation: 15
Hehe, amazing what a difference it makes having the correct spelling.
Thanks.

However, I am having another problem now since it doesn't look like there is anything in the SOAP message.

This is the output I get now:

SoapFault exception: [SOAP-ENV:Client] looks like we got no XML document in /var/www/html/clientGIndex.php:9
Stack trace:
#0 /var/www/html/clientGIndex.php(9): SoapClient->__call('processgindex', Array)
#1 /var/www/html/clientGIndex.php(9): SoapClient->processgindex(1)
#2 {main}

I am passing in an integer, and expect back a string. The binding style is 'document' and the use is 'literal'. I thought this statement would add a parameter in this statement (line 9 that fails):

$client->processgindex(1);

, but it doesn't look like it does.
Any suggestions?
 
Old 11-01-2006, 02:18 AM   #4
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Line 0 of the stack trace seems to suggest that processgindex is expecting an array. So how about the following?

Code:
$client->processgindex(Array(1));
 
Old 11-01-2006, 09:21 PM   #5
eikeland
Member
 
Registered: Nov 2004
Location: Newport, RI, USA
Distribution: Mandriva 2006
Posts: 125

Original Poster
Rep: Reputation: 15
Thanks for the suggestion, but it still doesn't work.
 
Old 11-07-2006, 02:38 PM   #6
eikeland
Member
 
Registered: Nov 2004
Location: Newport, RI, USA
Distribution: Mandriva 2006
Posts: 125

Original Poster
Rep: Reputation: 15
I am using JDeveloper (Windows) to create the WSDL file, and some tags seems to have a different format than a tutorial I did that worked fine.
http://devzone.zend.com/node/view/id/689
For example, in my wsdl file I have:
<message name='getQuoteRequest'>
<part name='symbol' type='xsd:string'/>
which is different from the 'message name' in the example where the type doesn't have xsd in front of it (see previous post on this page).
I would think wsdl follows a standard that can be used regardless on what software generated it, what woftware will be running it, or what OS it will be running on.
Any suggestions on what might be wrong?
Does anyone have any tutorials on creating wsdl files and using them with PHP?
Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd Webservice problems fatum112 *BSD 6 08-14-2006 12:24 PM
PHP wsdl problem bahadur Programming 3 07-24-2006 12:22 PM
Sending Objects to a Webservice (Java) megabot Programming 4 07-03-2006 07:38 AM
creating file with php xiekke Programming 6 03-14-2006 06:08 PM
soap WSDL generator? Thinking Programming 0 09-21-2005 04:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration