Web服务不显示

时间:2014-12-09 05:58:56

标签: php web-services soap

我有这段代码,功能位工作正常,但立即从行
要求( '的NuSOAP / LIB / nusoap.php');使它显示错误XML声明只允许我在浏览器上查看wsdl时文档的开头,请帮助

<?php 
function getStockQuote($symbol)
{
 $serverName = "MYSERVER"; //serverName\instanceName
$connectionInfo = array( "Database"=>"projects", "UID"=>"MYUSERNAME", "PWD"=>"MYPASSWORD");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( !$conn ) {
     echo "Connection not established.<br />";
}
if( $conn === false ) {
    die( print_r( sqlsrv_errors(), true));
}

$sql = "SELECT stock_symbol, stock_price FROM stockprices";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
      return $row['stock_price'];
}

sqlsrv_free_stmt( $stmt);



 }
require('nusoap/lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('stockserver', 'urn:stockquote');

    $server->register("getStockQuote",
                    array('symbol' => 'xsd:string'),
                    array('return' => 'xsd:decimal'),
                    'urn:stockquote',
                    'urn:stockquote#getStockQuote');

    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                          ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA); ?>
</pre>

0 个答案:

没有答案