EcStart PHP 技術討論論壇's Archiver

FIEND 發表於 2004-9-3 16:35

nusoap 手冊

[url=http://dietrich.ganx4.com/nusoap/APIDoc/]http://dietrich.ganx4.com/nusoap/APIDoc/[/url]

FIEND 發表於 2004-9-3 16:39

nusoap 手冊

[url=http://jakarta.apache.org/commons/betwixt/apidocs/org/apache/commons/betwixt/schema/Schema.html]http://jakarta.apache.org/commons/betwixt/...ema/Schema.html[/url]

FIEND 發表於 2004-9-3 16:43

nusoap 手冊

因為 Irose 採用 Mobocash 的 Web Service 來執行付款機制,但是 PHP 早期並沒有內建 SOAP ,必須透過一些 3rd Party 的程式來呼叫 Web Service。

另外好消息是 PHP5 已經有內建 SOAP extension,官方發佈消息如下:

Some of the key features of PHP 5 include:


    * The Zend Engine II with a new object model and dozens of new features.
    * XML support has been completely redone in PHP 5, all extensions are now focused around the excellent libxml2 library ( [url=http://www.xmlsoft.org/]http://www.xmlsoft.org/[/url] ).
    * A new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa.
    * A brand new built-in SOAP extension for interoperability with Web Services.
    * A new MySQL extension named MySQLi for developers using MySQL 4.1 and later. This new extension includes an object-oriented interface in addition to a traditional interface; as well as support for many of MySQL's new features, such as prepared statements.
    * SQLite has been bundled with PHP. For more information on SQLite, please visit their website .
    * Streams have been greatly improved, including the ability to access low-level socket operations on streams.

(以上資料來源: [url=http://www.php.net/)]http://www.php.net/)[/url]

如果使用的是 PHP 4.3.0 以上,又不想用3rd Party的函式,可以參考這篇:
[url=http://www.onlamp.com/pub/a/php/2003/10/30/amazon_rest.html]http://www.onlamp.com/pub/a/php/2003/10/30/amazon_rest.html[/url]

至於 PHP 早期的版本,比較有名的3rd Party 就屬 XML-RPC 跟 NuSOAP 了,XML-RPC 則是從 PHP 3 時代就能使用了,NuSOAP 目前到現在程式還是有在維護。

XML-RPC 官方網站
[url=http://xmlrpc.usefulinc.com/php.html]http://xmlrpc.usefulinc.com/php.html[/url]

XML-RPC SourceForge 網站
[url=http://sourceforge.net/project/showfiles.php?group_id=34455]http://sourceforge.net/project/showfiles.php?group_id=34455[/url]

XML-RPC 使用範例:
[url=http://php.weblogs.com/xml-rpc]http://php.weblogs.com/xml-rpc[/url]

NuSOAP 官方網站:
[url=http://dietrich.ganx4.com/index.php?category=NuSOAP]http://dietrich.ganx4.com/index.php?category=NuSOAP[/url]

NuSOAP 使用範例:
[url=http://www.phpbuilder.com/columns/kramberger20031226.php3]http://www.phpbuilder.com/columns/kramberger20031226.php3[/url]

XML-RPC 及 NuSOAP 使用範例:
[url=http://www.xml.com/pub/a/ws/2004/03/24/phpws.html]http://www.xml.com/pub/a/ws/2004/03/24/phpws.html[/url]


在美國 Web Service 組織的網站中,可以找到 PHP 相關的資訊:
[url=http://www.webservices.org/index.php/ws/content/search?SearchText=php]http://www.webservices.org/index.php/ws/co...?SearchText=php[/url]

FIEND 發表於 2004-9-3 16:47

nusoap 手冊

<a href="http://www.nonplus.net/geek/000752.php" target="_blank">http://www.nonplus.net/geek/000752.php<br>
<br>
</a>
<div class="contentbody">
<p>In a <a href="http://www.nonplus.net/geek/000740.php">previous entry</a>
I wrote about passing and returning structured data using NuSOAP. While
that approach worked when using a client written in the same version of
NuSOAP, it didn’t work for more stringest clients which need well
formed WSDL to create proxies for methods and structures.</p>

<p>After some more digging I discovered a couple of things:</p>

<ol><li>I was using <a href="http://dietrich.ganx4.com/nusoap">version 0.6.4</a> of NuSOAP which I found via Google.  That’s quite an old version and frankly doesn’t support WSDL well.
</li><li>After more searching, I found a more current version of <a href="http://sourceforge.net/projects/nusoap/">NuSOAP on SourceForge</a>.</li><li>There don’t seem to be any official releases (yet), so simply <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/nusoap/lib/nusoap.php?rev=HEAD&amp;content-type=text/plain">download the latest version</a> from the CVS repository.</li><li>I used version 1.59 of nusoap.php and it worked for me without any problems.</li></ol>

<p>So, make sure you use the latest version of NuSOAP from SourceForge in your application.</p>

<p><b>Note:</b> The example this document links to has been updated
10/30/2003 to correct problems on PHP installation that emit warnings
about unquoted string constants.</p>

<a name="more"></a>
<h3>Using WSDL</h3>

<p>Due to PHP’s loose typing, you have to epxlictly specify which types
are being used by your functions. I believe you can do this with an
external WSDL file. I describe the functional approach for registering
the types. The following begins the WSDL configuration for a NuSOAP
server object:</p>

<pre><span class="category1">require_once</span>('<span class="quote">nusoap.php</span>');<br> <br>$NAMESPACE = '<span class="quote">http://books.org/Books</span>';<br> <br>$server = new soap_server;<br>$server-&gt;configureWSDL('<span class="quote">Books</span>', $NAMESPACE);<br>$server-&gt;wsdl-&gt;schemaTargetNamespace = $NAMESPACE;</pre>


<h3>Declaring Complext Types for WSDL</h3>

<p>You use the <tt>addComplexType()</tt> method to register structures and arrays.  The following code registers a structure <tt>Chapter</tt> which contains two members (a string <tt>title</tt> and an int <tt>page</tt>), an array of <tt>Chapter</tt> structures and a structure <tt>Book</tt> which has several members, including a chapter array.</p>

<pre>$server-&gt;wsdl-&gt;addComplexType(<br>    '<span class="quote">Chapter</span>',<br>    '<span class="quote">complexType</span>',<br>    '<span class="quote">struct</span>',<br>    '<span class="quote">all</span>',<br>    '<span class="quote"></span>',<br>    <span class="category2">array</span>(<br>        '<span class="quote">title</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">title</span>','<span class="quote">type</span>'=&gt;'<span class="quote">xsd:string</span>'),<br>        '<span class="quote">page</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">page</span>','<span class="quote">type</span>'=&gt;'<span class="quote">xsd:int</span>')<br>    )<br>);<br> <br>$server-&gt;wsdl-&gt;addComplexType(<br>    '<span class="quote">ChapterArray</span>',<br>    '<span class="quote">complexType</span>',<br>    '<span class="quote">array</span>',<br>    '<span class="quote"></span>',<br>    '<span class="quote">SOAP-ENC:Array</span>',<br>    <span class="category2">array</span>(),<br>    <span class="category2">array</span>(<br>        <span class="category2">array</span>('<span class="quote">ref</span>'=&gt;'<span class="quote">SOAP-ENC:arrayType</span>','<span class="quote">wsdl:arrayType</span>'=&gt;'<span class="quote">tns:Chapter[]</span>')<br>    ),<br>    '<span class="quote">tns:Chapter</span>'<br>);<br> <br>$server-&gt;wsdl-&gt;addComplexType(<br>    '<span class="quote">Book</span>',<br>    '<span class="quote">complexType</span>',<br>    '<span class="quote">struct</span>',<br>    '<span class="quote">all</span>',<br>    '<span class="quote"></span>',<br>    <span class="category2">array</span>(<br>        '<span class="quote">author</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">author</span>','<span class="quote">type</span>'=&gt;'<span class="quote">xsd:string</span>'),<br>        '<span class="quote">title</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">title</span>','<span class="quote">type</span>'=&gt;'<span class="quote">xsd:string</span>'),<br>        '<span class="quote">numpages</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">numpages</span>','<span class="quote">type</span>'=&gt;'<span class="quote">xsd:int</span>'),<br>        '<span class="quote">toc</span>' =&gt; <span class="category2">array</span>('<span class="quote">name</span>'=&gt;'<span class="quote">toc</span>','<span class="quote">type</span>'=&gt;'<span class="quote">tns:ChapterArray</span>')<br>    )<br>);</pre>


<h3>Registering Functions for WSDL</h3>

<p>When you register functions with the NuSOAP server, you need to
specify the incoming parameters/types and the return type. The
following registers a function <tt>getBook</tt> that takes a string parameter <tt>title</tt> and returns a <tt>Book</tt> structure.</p>

<pre>$server-&gt;register(<br>    '<span class="quote">getBook</span>',<br>    <span class="category2">array</span>('<span class="quote">title</span>'=&gt;'<span class="quote">xsd:string</span>'),<br>    <span class="category2">array</span>('<span class="quote">return</span>'=&gt;'<span class="quote">tns:Book</span>'),<br>    $NAMESPACE);</pre>


<h3>Accessing the WSDL</h3>

<p>Once your WSDL specification is complete, you can examine it by passing the <tt>wsdl</tt>
parameter to your PHP script. The script will return the generated WSDL
which you can use in your tool to generate proxy classes, etc. Here is
the WSDL for this example: <a href="http://www.nonplus.net/geek/samples/books.php?wsdl">http://www.nonplus.net/geek/samples/books.php?wsdl</a>.</p>

<h3>Implementing Functions</h3>

<p>Using the WSDL specification, you can return SOAP structures as
regular PHP associative arrays. When the server handles a SOAP request,
it serializes and unserializes the PHP arrays using the WSDL
description. The following function returns a book with two chapters
(note that it’s blissfully unaware of SOAP):</p>

<pre><span class="category3">function</span> getBook($title) {<br>     <span class="linecomment">// Create TOC</span><br>     $toc = <span class="category2">array</span>();<br>     $toc[] = <span class="category2">array</span>('<span class="quote">title</span>' =&gt; '<span class="quote">Chapter One</span>', '<span class="quote">page</span>' =&gt; 1);<br>     $toc[] = <span class="category2">array</span>('<span class="quote">title</span>' =&gt; '<span class="quote">Chapter Two</span>', '<span class="quote">page</span>' =&gt; 30);<br>  <br>     <span class="linecomment">// Create book</span><br>     $book = <span class="category2">array</span>(<br>                 '<span class="quote">author</span>' =&gt; "<span class="quote">Jack London</span>",<br>                 '<span class="quote">title</span>' =&gt; $title,<br>                 '<span class="quote">numpages</span>' =&gt; 42,<br>                 '<span class="quote">toc</span>' =&gt; $toc);<br>  <br>     <span class="category1">return</span> $book;<br>}</pre>


<h3>Tying it All Together</h3>

<p>The example <a href="http://www.nonplus.net/software/download/geek/books.php">books.php</a> implements a SOAP server using the structures described above.  It registers two methods <tt>getBook(title)</tt> and <tt>getBooks(author)</tt>,
the latter returns an array of Books. Make sure that you have a current
version of NuSOAP installed when using the sample script.</p>


</div>



<div class="sidebox">
<a name="trackbacks"></a>
<div class="sidetitle" style="border-bottom: medium none;">
<span class="title_left">Trackbacks</span>
<span class="title_right" style="text-transform: none;">http://www.nonplus.net/mt/mt-tb.cgi/691</span>
<br clear="all"></div>

</div>



<div class="sidebox">
<a name="comments"></a>
<div class="sidetitle"><span class="title_left">Comments</span><br clear="all"></div>
<div class="sidebody">
<ol><li>
<p>And does it works with MS SOAP?</p>
<span class="comments-post">Posted by: igo on October  5, 2003 11:22 AM</span>
</li><li>
<p>Yes, I’ve tested this with MS Studio.NET. When you register a web
service in Studio.NET, point it to the WSDL URL of your NuSOAP web
service, i.e. <a href="http://www.nonplus.net/geek/samples/books.php?wsdl" rel="nofollow">http://www.nonplus.net/geek/samples/books.php?wsdl</a>.</p>
<span class="comments-post">Posted by: <a href="http://www.nonplus.net/" rel="nofollow">stepan</a> on October  5, 2003 10:51 PM</span>
</li><li>
<p>I’ve been testing out your example using Flash MX 2004 as a SOAP client, but I’m running into a problem.</p>

<p>If I use <a href="http://www.nonplus.net/geek/samples/books.php?wsdl" rel="nofollow">http://www.nonplus.net/geek/samples/books.php?wsdl</a> on your server, things work as expected.</p>

<p>Connecting to the same books.php file on my server however generates this error when Flash interacts with it:</p>

<p>WebServiceFault<br>
VersionMismatch<br>
Request implements version: <a href="http://schemas.xmlsoap.org/soap/envelope/" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/</a> Response implements version</p>

<p>Any idea what might be wrong?</p>
<span class="comments-post">Posted by: dave on October 29, 2003  2:08 PM</span>
</li><li>
<p>Thanks so much for this wonderful article. <br>
Really helped to get the best out of my<br>
lame isp.</p>
<span class="comments-post">Posted by: <a href="http://www.benz-experiments.de/" rel="nofollow">Benjamin Dobler</a> on October 30, 2003  6:33 PM</span>
</li><li>
<p>I need a guide of how consume the nusoap in VB .NET, if somene could help!!<br>
</p>
<span class="comments-post">Posted by: Roly on November  8, 2003  9:14 PM</span>
</li><li>
<p>You consume NuSOAP web services in VB.NET just like you would any other web service.  For this example do the following:</p>

<ol><li>In the solution explorer in Studio.NET, right-click on your project and select “Add Web Service…”</li><li>In the “URL” field, enter the URL to the web service’s WSDL, i.e. <a href="http://www.nonplus.net/geek/samples/books.php?wsdl" rel="nofollow">http://www.nonplus.net/geek/samples/books.php?wsdl</a></li><li>In the “Web reference name” field, enter a short name, i.e. “WS” (for wbe service)</li><li>Click on the “Go” button. Studio.NET retrieves the WSDL and generates proxy classes from it.</li><li>Now you’re ready to use the Web Service.  For example, the following calls a service and extracts some info from the result:
<pre>        Dim info As String<br>        Dim WS As New WS.Books<br>        Dim b As WS.Book<br> <br>        ' Retrieve book from web service<br>        b = WS.getBook("Les Miserables")<br> <br>        ' Create a multi-line string with title, author, num pages<br>        ' and first chapter<br>        info = b.title + vbCrLf<br>        info += b.author + vbCrLf<br>        info += CStr(b.numpages) + vbCrLf<br>        info += CStr(b.toc(0).page) + ": " + b.toc(0).title + vbCrLf</pre></li></ol>
<span class="comments-post">Posted by: <a href="http://www.nonplus.net/" rel="nofollow">stepan</a> on November  9, 2003  8:52 AM</span>
</li><li>
<p>I’m getting a parsing error on this script from my IIS server. <br>
Any help would be appreciated. </p>
<span class="comments-post">Posted by: <a href="http://addison.ra.cwru.edu/orc/calendar/books.php" rel="nofollow">Rachel Wilkins</a> on November 17, 2003  4:40 PM</span>
</li><li>
<p>Could someone tell me how to consume this web service in Visual C#?
When I add it as a web refrence I get a .map file and a .wsdl file, but
no proxy class file. Am I missing a step somewhere?</p>
<span class="comments-post">Posted by: Shaun on November 25, 2003  6:06 AM</span>
</li><li>
<p>I consume this in C# without any problems. It is done exactly the
same as in VB.NET (see comment 6). Except, of course, the syntax
differs a little.</p>
<span class="comments-post">Posted by: <a href="http://www.nonplus.net/" rel="nofollow">stepan</a> on November 25, 2003  7:36 AM</span>
</li><li>
<p>I’ve found out that if I use the command line “wsdl” command, it
makes me a .cs file which I can use successfully. However, if I right
click the project and use the “Add Web Refrence…” dialog in C#, I get a
.map and .wsdl but no .cs file. I guess I will just continue using the
command line rather than adding web refrences.</p>
<span class="comments-post">Posted by: Shaun on November 25, 2003  9:59 PM</span>
</li><li>
<p>Is there an exemple for using this web service in php ?</p>
<span class="comments-post">Posted by: ben on November 27, 2003  9:07 AM</span>
</li><li>
<p>i wantto make a wsdl like this (part):</p>

<p>targetNamespace=”http://www.msn.com/webservices/Messenger/Client” xmlns=”http://schemas.xmlsoap.org/wsdl/”&gt;<br>
- <br>
- <br>
- <br>
- <br>
- <br>
   <br>
  <br>
  <br>
  <br>
- <br>
- <br>
   <br>
   <br>
   <br>
   <br>
   <br>
  <br>
  <br>
- <br>
- <br>
- <br>
   <br>
  <br>
  <br>
  <br>
  <br>
  </p>

<p>how can i do?<br>
</p>
<span class="comments-post">Posted by: <a href="http://oo8h.com/" rel="nofollow">Ron</a> on December  9, 2003  4:30 AM</span>
</li><li>
<p>send the code , try argin:<br>
[code]<br>
targetNamespace=”http://www.msn.com/webservices/Messenger/Client” xmlns=”http://schemas.xmlsoap.org/wsdl/”&gt;<br>
- <br>
- <br>
- <br>
- <br>
- <br>
   <br>
  <br>
  <br>
  <br>
- <br>
- <br>
   <br>
   <br>
   <br>
   <br>
   <br>
  <br>
  <br>
- <br>
- <br>
- <br>
   <br>
  <br>
  <br>
  <br>
  <br>
  <br>
[/code]</p>
<span class="comments-post">Posted by: <a href="http://oo8h.com/" rel="nofollow">Ron</a> on December  9, 2003  4:33 AM</span>
</li><li>
<p>Hi, I am getting the same problem as noted by dave on October 29. Has anyone found the reason for this?</p>

<p>WebServiceFault<br>
VersionMismatch<br>
Request implements version: <a href="http://schemas.xmlsoap.org/soap/envelope/" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/</a> Response implements version </p>

<p>Any response would be appreciated.</p>
<span class="comments-post">Posted by: chris on December 17, 2003  2:58 AM</span>
</li><li>
<p>First:<br>
Thanks for this great article. i wonder how you guys get so easily(?) into new shit ;-)</p>

<p>Second:<br>
I had no problems when using Flash MX 2004 (pro).</p>

<p>When calling<br>
<a href="http://myserver/nusoap/wsdl_books.php?wsdl" rel="nofollow">http://myserver/nusoap/wsdl_books.php?wsdl</a><br>
in a browser (wsdl_books.php is the books.php you can download above,
just renamed), i receive the XML. So everything is up and running.</p>

<p>You can also check this by adding the URL to the ‘Web Services’ Panel in Flash which shows you all available methods, too.</p>

<p>After adding the ‘WebServiceClasses’ to my Library (from Windows
&gt; Other Panels &gt; Common Libraries &gt; Classes) (Flash
Professional only) add the following code into the first frame of the
empty movie:</p>




// use WebServices
import mx.services.*;

<p>// Variables<br>
wsdlURL = “http://myserver/nusoap/wsdl_books.php?wsdl”;<br>
query = “temp”;</p>

<p>// Log Object<br>
LO = new Log(“DEBUG”, Log.LO);<br>
LO.onLog = function (txt) {<br>
        trace (txt);<br>
}</p>

<p><br>
// WebService Object (using Log Object)<br>
WSO = new WebService (wsdlURL, LO);</p>

<p>WSO.onLoad = function () {<br>
        trace (“loading…”);<br>
}</p>

<p>WSO.onFault = function (error) {<br>
        trace (“WSO error :”);        <br>
        trace (error.faultcode + ” , ” + error.faultstring);        <br>
}</p>

<p><br>
// PendingCall Object<br>
PCO = WSO.getBook (query);</p>

<p>PCO.onResult = function (result) {<br>
        trace (“AUTHOR: ” + result.author);<br>
        trace (“TITLE : ” + result.title);<br>
        trace (“PAGES : ” + result.numpages);<br>
}</p>

<p>PCO.onFault = function (error) {<br>
        trace (“PCO error :”);<br>
        trace (error.faultcode + ” , ” + error.faultstring);<br>
}<br>
</p>

<p>I turned on full debugging mode in the Log Object to help finding errors.</p>

<p>That’s it.</p>

<p><br>
:::m.</p>
<span class="comments-post">Posted by: <a href="http://www.dyrdee.com/" rel="nofollow">mesaullion</a> on December 27, 2003  2:34 PM</span>
</li><li>
<p>note to my comment above:</p>

<p>if you copy and paste the code into flash, it’ll probably not detect the correct quotation marks (they are kinda italic).</p>

<p>all you have to do is, use the search and replace function within
the actionscript editor and replace all 22 quotation marks with normal
ones.<br>
</p>
<span class="comments-post">Posted by: <a href="http://www.dyrdee.com/" rel="nofollow">mesaullion</a> on December 27, 2003  3:39 PM</span>
</li><li>
<p>thanks a lot!!! if been already looking for 2 days to get .NET connected with nusoap</p>

<p>this is the first nusoap-WSDL i found which supports ARRAYS with .NET</p>
<span class="comments-post">Posted by: <a href="http://www.linktree.info/" rel="nofollow">jesus</a> on February  2, 2004  6:48 PM</span>
</li><li>
<p>Thanks for this great article. Got me a woopin’ step further! keep up the good work!</p>
<span class="comments-post">Posted by: Christian Wolf on February 27, 2004  6:53 AM</span>
</li><li>
<p>This article was great.  You rock!!!!</p>
<span class="comments-post">Posted by: lastKnight on March  4, 2004 12:46 PM</span>
</li><li>
<p>Hello,</p>

<p>When connecting to nusoap using .NET 1.1 and Visual Studio I get the following error:<br>
Possible SOAP version mismatch: Envelope namespace <a href="http://schemas.xmlsoap.org/wsdl/" rel="nofollow">http://schemas.xmlsoap.org/wsdl/</a> was unexpected. Expecting <a href="http://schemas.xmlsoap.org/soap/envelope/" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/</a></p>

<p>Any ideas? <br>
Thank you <br>
Pablo Godel</p>
<span class="comments-post">Posted by: Pablo Godel on March  7, 2004  4:25 PM</span>
</li><li>
<p>Awesome article! I had a C# client hooked up to a NuSOAP web service within a couple of hours.</p>
<span class="comments-post">Posted by: Catatonic on March 10, 2004 10:18 PM</span>
</li><li>
<p>I wonder if you’ve been able to accept an associative array as input to your getBook() function.</p>

<p>I tried and even if I pass a complex structure to the function all I
get as a parameter is a single string (the first element of the
associative array). Any ideas?<br>
</p>
<span class="comments-post">Posted by: <a href="http://tanis.hateseed.com/" rel="nofollow">Valerio Santinelli</a> on March 11, 2004  8:41 AM</span>
</li><li>
<p>I haven’t tried using associative arrays as parameters, and I’m not
sure whether they are supported in SOAP (or what the WSDL configuration
would look like). But you should be able to pass an array of {key,
value} pairs and convert it to an associative array in your function.</p>

<p>If you want to do that for the getBook() function, you’d have to
create the appropriate complex types (i.e. a {key, value} structure and
an array of these structures) and then modify the “getBook”
registeration to use this array as its input.</p>
<span class="comments-post">Posted by: <a href="http://www.nonplus.net/" rel="nofollow">stepan</a> on March 11, 2004 10:02 AM</span>
</li><li>
<p>I’m trying to consume .net services with<br>
nuSoap and I’m getting result errors since<br>
my client is only sending the first character<br>
of a string. It only happens with .net services.<br>
For example if I’m trying to consume a ip address finder it only sends the first number and consecuently I get a wrong result.<br>
Any ideas on how to overcome this problem?</p>
<span class="comments-post">Posted by: David Laserna on April 12, 2004  2:36 PM</span>
</li><li>
<p>Passing associative arrays works :)</p>

<p>I have finished my first real web service and it works fine with associative arrays passed to functions. I love nusoap ;)<br>
</p>
<span class="comments-post">Posted by: <a href="http://tanis.hateseed.com/" rel="nofollow">Valerio Santinelli</a> on April 15, 2004  5:04 AM</span>
</li><li>
<p>I am new to web servie and takes me so much time figure out the nusoap client.</p>

<p>By the way, I am still think a way on how to call it from Excel (VBA) and retrieve the array.<br>
Seems the .net sample wasn’t work.  </p>

<p><br>
// include the SOAP classes<br>
require_once(‘nusoap.php’);</p>

<p>// define parameter array (ISBN number)<br>
$param = array (”);</p>

<p>// define path to server application<br>
$serverpath =’http://www.nonplus.net/geek/samples/books.php?wsdl.’;</p>

<p>//define method namespace<br>
$namespace=”urn:xmethods-BNPriceCheck”;</p>

<p>// create client object<br>
$client = new soapclient($serverpath, true);</p>

<p>// make the call<br>
$price = $client-&gt;call(‘getBooks’,$param,$namespace);<br>
// Display the result<br>
print_r($result);</p>

<p>// Display the request and response<br>
echo ‘Request’;<br>
echo ” . htmlspecialchars($client-&gt;request, ENT_QUOTES) . ”;<br>
echo ‘Response’;<br>
echo ” . htmlspecialchars($client-&gt;response, ENT_QUOTES) . ”;</p>

<p>// if a fault occurred, output error info<br>
if (isset($fault))<br>
{<br>
  print “Error: “. $fault;<br>
}<br>
else if ($result == -1)<br>
{<br>
  print “The book is not in the database.”;<br>
}<br>
else<br>
{<br>
  var_dump ($result);<br>
}</p>
<span class="comments-post">Posted by: mugmug on May 20, 2004  3:13 AM</span>
</li><li>
<p>Need help in VBA.</p>

<p>I got the folloing result when calling nusoap server by nusoap client.  Which works perfectly fine.</p>

<p>array(2) {<br>
  [0]=&gt;<br>
  array(2) {<br>
    [“bookname”]=&gt;<br>
    string(19) “This is a good book”<br>
    [“price”]=&gt;<br>
    int(22)<br>
  }<br>
  [1]=&gt;<br>
  array(2) {<br>
    [“bookname”]=&gt;<br>
    string(12) “not bad book”<br>
    [“price”]=&gt;<br>
    int(33)<br>
  }<br>
}</p>

<p>but how can I retriece the result by using VBA code?  </p>

<p>I have read the above code and try <br>
      <br>
  Cells(5, 1) = fResult(1).bookname<br>
and <br>
  Cells(5, 1) = fResult.bookname</p>

<p>but seems doesnt work.</p>

<p>However, i can retrieve and view the value in VBA local window. Any
help will be greatly appreciate. I will post the full verion of code
once complete. thanks in advance.</p>
<span class="comments-post">Posted by: Mug Mug on May 20, 2004 11:45 PM</span>
</li><li>
<p>we try to generate java code from nusoap wsdl using axis. this will
work fine with complex types but will fail with an array of a complex
type. axis try to extend the java.lang.Object[] but this fail.</p>

<p>has anyone an idea to “workaround” this problem and exchange a list/array of complex types?</p>
<span class="comments-post">Posted by: kl3tte on June 24, 2004  2:31 AM</span>
</li><li>
<p>Hi </p>

<p>First of thank you for this wonderful article. It helped me very
much. But i am facing a problem when i use this service in VB.Net The
error that is coming is ” Client foud response content of type
“text\html”, but expected “text\xml” the resuest failed with error
message: No output file specified”</p>

<p>Could any one tell me what could be wrong. It would be a great favour<br>
</p>
<span class="comments-post">Posted by: rakesh on July  3, 2004 12:40 PM</span>
</li><li>
<p>Using nusoap, how do you call a .NET web service that takes an
integer array as a parameter? Any help would be very much appreciated!
rangi.robinson AT framestore-cfc.com</p>
<span class="comments-post">Posted by: <a href="http://www.framestore-cfc.com/" rel="nofollow">rangi500</a> on September 13, 2004  8:07 AM</span>
</li><li>
<p>I met the same program with Rakesh. </p>

<p>Client found response content of type “text\html”, but expected “text\xml”.<br>
What’s wrong?</p>

<p>Appreciate your help~ :)</p>
<span class="comments-post">Posted by: West on September 28, 2004  2:58 AM</span>
</li><li>
<p>When successful, NuSOAP is returning a text/xml. If you see
text/html, it’s probably an error document being returned by the web
server. Look through your server’s error log to see if it’s reporting
any problems.</p>
<span class="comments-post">Posted by: <a href="http://www.nonplus.net/" rel="nofollow">stepan</a> on September 28, 2004  1:52 PM</span>
</li><li>
<p>Hi, is there a way to use an XSD file to define a complex structure?
I need my service to output the results of a mysql query using the XSD
format for the output structure</p>
<span class="comments-post">Posted by: Norbert on October  5, 2004  1:21 PM</span>
</li><li>
<p>I really don’t get this $NAMESPACE variable. What is that supposed
to be? I’m looking and looking at it and searching but there is no
light.</p>
<span class="comments-post">Posted by: <a href="http://www.waveride.net/" rel="nofollow">Mark</a> on November  9, 2004  5:08 PM</span>
</li><li>
<p>decoded it ;)</p>
<span class="comments-post">Posted by: <a href="http://www.waveride.net/" rel="nofollow">Mark</a> on November 10, 2004  4:04 PM</span>
</li><li>
<p>Hello:</p>

<p>I want to do a web service which the server is writen in python and
the consumer is writen in php with nusoap but I haven’t found some
example about that and I don’t know if it could be possible.</p>

<p>If you know some answer please answer me.</p>

<p>Thanks a lot</p>

<p>Friederich Marcks</p>
<span class="comments-post">Posted by: <a href="http://www.frog-it.net/" rel="nofollow">Friederich Marcks</a> on November 26, 2004  2:08 PM</span>
</li><li>
<p>I’ve created a web service using NuSOAP, and I’m able to connect to
it from a PHP(NuSOAP) and Java(Apache Axis) client with no problems.
Where the problems begin is putting the web service in a password
protected directory using HTTP Authentication. If I created the web
service without using WSDL my PHP client can connect using HTTP
Authentication, but once I use the WSDL feature of NuSOAP I get
problems. I need the WSDL feature because I want the Java client to
connect, and possible other clients. Below I placed a sample of a
simple service that’s giving trouble. I would greatly appreciate some
help, it’s driving me nuts.</p>

<p>/***************************************/</p>

<p><br>
// Insert the NuSOAP code<br>
require_once(‘nusoap.php’);</p>

<p>$NAMESPACE = “http://www.myserver.com/WebService”;</p>

<p>// Create an instance of the server<br>
$server = new soap_server;</p>

<p>// Initialize WSDL support<br>
$server-&gt;configureWSDL(‘Events’, $NAMESPACE);</p>

<p>// Put the WSDL schema types in the namespace with the tns prefix<br>
$server-&gt;wsdl-&gt;schemaTargetNamespace = $NAMESPACE;</p>

<p>$server-&gt;wsdl-&gt;addComplexType(<br>
        ‘Person’,<br>
        ‘complexType’,<br>
        ‘struct’,<br>
        ‘all’,<br>
        ”,<br>
        array(<br>
                ‘personId’=&gt;array(‘name’=&gt;’personId’,’type’=&gt;’xsd:int’),<br>
                ‘firstName’=&gt;array(‘name’=&gt;’firstName’,’type’=&gt;’xsd:string’),<br>
                ‘lastName’=&gt;array(‘name’=&gt;’lastName’,’type’=&gt;’xsd:string’)<br>
        )<br>
);</p>

<p>$server-&gt;register(<br>
        ‘getPerson’,<br>
        array(‘personId’=&gt;’xsd:int’),<br>
        array(‘return’=&gt;’tns:Person’),<br>
        $NAMESPACE,<br>
        $NAMESPACE . ‘#’ . ‘getPerson’,<br>
        ‘rpc’,<br>
        ‘encoded’,<br>
        ‘Returns a pserson by ID’<br>
);</p>

<p>function getPerson($personId) {<br>
        if($personId==0||$personId==”) {<br>
                return new soap_fault(‘Client’, ”, ‘Must supply a person id.’);<br>
        }<br>
        else {<br>
                $aPerson = array(<br>
                                        ‘personId’=&gt;$personId,<br>
                                        ‘firstName’=&gt;’Bart’,<br>
                                        ‘lastName’=&gt;’Simpson’<br>
                                        );<br>
                        return $aPerson;<br>
        }<br>
}</p>

<p>$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ”;<br>
$server-&gt;service($HTTP_RAW_POST_DATA);<br>
</p>
<span class="comments-post">Posted by: Robert on December  1, 2004  2:12 PM</span>
</li><li>
<p> Ok, I got the problem solved. So here’s the solution to anyone else
who might have the same problem. The client should be as follows:</p>

<p>define(‘username’, ‘foo’);<br>
define(‘password’, ‘bar’);<br>
<br>
// This is location of the remote service<br>
$client = new soapclient(‘http://’ . username . “:” . password . ‘@www.myserver.com/ws/server.php?wsdl’, true);<br>
$client-&gt;setCredentials(username,password);</p>

<p>I define the username and password as constants, and that’s it.<br>
</p>
<span class="comments-post">Posted by: Robert on December  2, 2004 11:11 AM</span>
</li><li>
<p>Thankyou so much for this article, i was completely stuck on parsing mulitdimensional arrays until reading this. </p>
<span class="comments-post">Posted by: <a href="http://www.perplexed.co.uk/" rel="nofollow">Andy</a> on December 21, 2004  5:00 AM</span>
</li><li>
<p>Hey :).<br>
My little testing script using nusoap to get Alexa services is coming
unstuck, claiming I am only sending one of the required parameters:<br>
Array<br>
(<br>
    [OperationRequest] =&gt; Array<br>
        (<br>
            [RequestId] =&gt; 1QXVH0NY2C2M1BMSHKFN<br>
        )</p>

<p>    [UrlInfoResult] =&gt; Array<br>
        (<br>
            [Request] =&gt; Array<br>
                (<br>
                    [IsValid] =&gt; False<br>
                    [Errors] =&gt; Array<br>
                        (<br>
                            [Error] =&gt; Array<br>
                                (<br>
                                    [Code] =&gt; AWS.MissingParameters<br>
[Message] =&gt; Your request is missing required parameters. Required
parameters include Url.<br>
…..</p>

<p>and yet my code is:</p>

<p>———snip——-<br>
// Call the SOAP method</p>

<p><br>
$proxy-&gt;soap_defencoding = “UTF-8”;<br>
$result = $proxy-&gt;UrlInfo(array(‘SubscriptionId’ =&gt; ‘1405M88PWV52RDDEKTG2’,’Url’ =&gt; ‘www.djpauledge.com’));</p>

<p><br>
var_dump($result);<br>
——-snip—————</p>

<p><br>
Any ideas anyone ? <br>
Thanks in advance,<br>
Mik.e</p>
<span class="comments-post">Posted by: <a href="http://www.tol23.com/" rel="nofollow">Mike Tondrius</a> on December 23, 2004  8:27 PM</span>
</li><li>
<p>Mike: what is the WSDL URL?</p>

<p>All: the NuSOAP mailing list on SourceForge is a great place for your questions.  Go to <a href="http://sourceforge.net/projects/nusoap/" rel="nofollow">http://sourceforge.net/projects/nusoap/</a> and follow the links to join the list.</p>
<span class="comments-post">Posted by: Scott Nichol on April  2, 2005  1:34 PM</span>
</li><li>
<p>First thanks for this great artical ,it helps me so much ! But still
I have some problems in using web service. I want to call a web service
wrote by .net, how can I do this??? Does anyone know this? </p>
<span class="comments-post">Posted by: nicole on May 18, 2005  3:58 AM</span>
</li><li>
<p>Wonderful article.</p>
<span class="comments-post">Posted by: Ramachandran on July  9, 2005  1:35 PM</span>
</li><li>
<p>Hi Guys</p>

<p>Prob being thick, but the above wsdl code, where does this go. </p>

<p>If it is a separate file placed with my php nusoap file and server
files, should it have a .php extenstion, and if so, how does the client
request know to look at the wsdl file.</p>
<span class="comments-post">Posted by: che on July 18, 2005  2:40 AM</span>
</li><li>
<p>I have finally solved a problem I’ve seen posted on many forums including this one.<br>
— WebServiceFault: VersionMismatch —<br>
Make sure that if you’re using nusoap and apache compression that you
go edit nusoap and comment out the lines that perform compression on
the soap envelope. Whats happening is that it is being double
compressed and the flash client is getting garbage (when viewed in IE).
It works fine from the local host since you’re not passing the
“compress me plz” header (which both Apache AND nusoap react to).<br>
</p>
<span class="comments-post">Posted by: <a href="http://groupnetwork.com/" rel="nofollow">Seth Caldwell</a> on September 13, 2005  4:27 PM</span>
</li><li>
<p>Hi,</p>

<p>I have been trying to implement an example of nusoap for a week and am really stuck now. Could someone please help me?</p>

<p>i have created the following server code, which basically (if
correct) should return to the client multiple rows of data. However, I
can’t get the client to work. Can someone please explain to me what the
client code should be. I am desperate. Thanks.</p>

<p>here is the server code;</p>

<p><br>
      <br>
    // includes nusoap classes<br>
    require(‘nusoap.php’);<br>
   <br>
    // create server<br>
    $l_oServer = new soap_server();<br>
  <br>
    // wsdl generation<br>
    $l_oServer-&gt;debug_flag=false;<br>
    $l_oServer-&gt;configureWSDL(‘TvData’, ‘http://abctv.org/schedule’);<br>
    $l_oServer-&gt;wsdl-&gt;schemaTargetNamespace = ‘http://abctv.org/schedule’;</p>

<p>    // add complex type<br>
    $l_oServer-&gt;wsdl-&gt;addComplexType(<br>
        ‘scheduleitem’,<br>
        ‘complexType’,<br>
        ‘struct’,<br>
        ‘all’,<br>
        ”,<br>
        array(<br>
            ‘name’ =&gt; array(‘name’=&gt;’name’, ‘type’=&gt;’xsd:string’), <br>
            ‘start’ =&gt; array(‘name’=&gt;’start’, ‘type’=&gt;’xsd:string’),<br>
            ‘end’ =&gt; array(‘name’=&gt;’end’, ‘type’=&gt;’xsd:string’))<br>
    );<br>
    <br>
    $l_oServer-&gt;wsdl-&gt;addComplexType(<br>
        ‘dailyschedule’,<br>
        ‘complexType’,<br>
        ‘array’,<br>
        ”,<br>
        ‘SOAP-ENC:Array’,<br>
        array(),<br>
        array(<br>
            array(‘ref’=&gt;’SOAP-ENC:arrayType’,’wsdl:arrayType’=&gt;’tns:scheduleitem[]’)<br>
        ),<br>
        ‘tns:scheduleitem’<br>
    );<br>
  <br>
    // register method<br>
    $l_oServer-&gt;register(‘getSchedule’, array(<br>
        ‘date’ =&gt; ‘xsd:string’), <br>
            array(‘return’=&gt;’tns:dailyschedule’), <br>
                ‘http://abctv.org/schedule’);<br>
  <br>
    // method code (get DB result)<br>
    function getSchedule ($a_stInput) {<br>
        if (is_string($a_stInput)) {   <br>
            $l_oDBlink   = @mysql_connect(<br>
                ‘abc’, ‘abc’, ‘abc’);<br>
            $l_oDBresult = @mysql_db_query(<br>
                ‘tvdb’, <br>
‘SELECT item.name, slot.start, slot.end FROM (episode INNER JOIN item
ON episode.itemID = item.itemID) INNER JOIN slot ON episode.episodeID =
slot.episodeID <br>
                WHERE slot.date = (“’ . mysql_escape_string((string)$a_stInput) . ‘”)’);<br>
                <br>
            // simple error checking<br>
            if (!$l_oDBresult) {<br>
                return new soap_fault(‘Server’, ”, ‘Internal server error.’);<br>
            }<br>
     <br>
            // no data avaible for x city<br>
            if (!mysql_num_rows($l_oDBresult)) {<br>
                return new soap_fault(‘Server’, ”, <br>
                    ‘Service contains data only for a few cities.’);<br>
            }<br>
            mysql_close($l_oDBlink);<br>
          <br>
            // return data<br>
            $schedule = array();<br>
            <br>
                                   <br>
                                   for ( $counter = 0;<br>
                                    $list = mysql_fetch_object( $l_oDBresult);<br>
                                    $counter++ )<br>
                            {<br>
                    <br>
                            $itemname = $list -&gt; name;<br>
                            $start = $list -&gt; start;<br>
                            $end = $list -&gt;        end;<br>
                            <br>
                           // build table to display results<br>
               <br>
                        $schedule[] = array(‘scheduleitem’ =&gt; $itemname, $start, $end);<br>
                            <br>
                        }<br>
            <br>
            <br>
            <br>
            return $schedule;    <br>
        } <br>
        // we accept only a string<br>
        else {<br>
          return new soap_fault(‘Client’, ”, ‘Service requires a string parameter.’);<br>
        }<br>
      }<br>
  <br>
    // pass incoming (posted) data<br>
    $l_oServer-&gt;service($HTTP_RAW_POST_DATA);</p>
<span class="comments-post">Posted by: <a href="http://none/" rel="nofollow">Bryan</a> on October 23, 2005  3:07 PM</span>
</li><li>
<p>hi guys…i’d like to ask.. i try connected php webservices with
vb.net as a client, when im trying to connected with two output or more
that i get from array, it works, like tutorial that i get from stepan
how to consume php ws to vb.net.. it really work, but.. when i turning
into database that i use from my sql. im stuck.. i cant get the
output.. <br>
for example.. i have database name it stockprices and with 3 field =
stock_id,stock_price,stock_symbol, for ex i do my query like this.
Select stock_symbol,Stok_price from stockprices where id = 1; <br>
i can’t show the data, but if with array it doin well.. also i’d like
to ask you.. how to show multiple data to dbgrid vb.net.. for example
select * from stockPrices; and i’d like to show the data into dbgrid.<br>
please i need ur help with a sample code how to make it from php as
webservices, and vb.net as a client.. please send me a email at
salim_shammakh@yahoo.com <br>
best regard…</p>
<span class="comments-post">Posted by: Salim on February 27, 2006 11:35 PM</span>
</li><li>
<p>When I use the example and click on the WSDL link the following error messag is shown:</p>

<p>Anyone any idea what could be wrong?</p>

<p>START ERROR MESSAGE<br>
The XML page cannot be displayed <br>
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. </p>

<p>Only one top level element is allowed in an XML document. Error processing resource ‘http://localhost/test/TMPfjqstz3xo7.ph…</p>

<p><b>Warning</b>:  Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroo…<br>
END ERROR MESSAGE</p>
<span class="comments-post">Posted by: Erik on May 11, 2006  9:30 AM</span>
</li><li>
<p>Thanks to your example, I have made a C# web service consumer (server done in php).</p>

<p>Thanks so much.</p>
<span class="comments-post">Posted by: <a href="http://www.lossoprano.net/" rel="nofollow">Robert</a> on July 24, 2006  1:57 PM</span>
</li><li>
<p>Thanks. <br>
Your example is very simple and very clean.</p>
<span class="comments-post">Posted by: <a href="http://www.altodebito.pt/" rel="nofollow">Ricardo Augusto</a> on October 23, 2006  8:56 AM</span>
</li></ol>
</div>
</div>
<a href="http://www.nonplus.net/geek/000752.php" target="_blank"><br>
</a>

FIEND 發表於 2004-9-3 16:48

nusoap 手冊

[url=http://xaraya.com/documentation/phpxref/nav.html?index.html]http://xaraya.com/documentation/phpxref/nav.html?index.html[/url]

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.