Web服务无法正常工作

时间:2011-11-20 16:56:06

标签: php

我是PHP的新手,并不太了解Web服务,但是我已经用PHP编写了一个代码片段,但它没有显示输出,是否有任何正文可以帮助吗?

以下是代码:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>PHP NuSoap Shakespeare Client</title>
</head>
<body>
<h3>PHP program to access the Shakespeare web service.</h3>
<?php
require_once('lib/nusoap.php');
$request = array('Request'=> 'Winter of our discontent');
$wsdl="http://www.xmlme.com/WSShakespeare.asmx?wsdl";
$soapClient = new soapclient($wsdl, true);
$result = $soapClient->call
        (
              'Get Speech',
              $request,
              'http://xmlme.com/WebServices',
              'http://xmlme.com.WebServices/GetSpeech');
echo '<h2>Shakespeare Web Service Response from a PHP Client</h2>';
echo '<h2>PHP Array Response</h2>';
print_r($result);
echo '<h2>Request</h2>';
echo '<pre>'.htmlspecialchars($soapClient->request, ENT_QUOTES).'</pre>';
echo '<h2>Response</h2>';
echo '<pre>'.htmlspecialchars($soapClient->response, ENT_QUOTES).'</pre>';
?>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

I have some results with this:

$soap_client = new SoapClient("http://www.xmlme.com/WSShakespeare.asmx?WSDL");

$request = array('Request'=> 'To be, or not to be');
$quote = $soap_client->GetSpeech($request);
$speech = $quote->GetSpeechResult;

echo $speech;

I am new to this, but maybe the info helps you further.