1

我是 SOAP 新手,我正在尝试创建我的 Web 服务;不幸的是,出了点问题,似乎没有调用 server.php 页面。我使用了一个非常简单的查询开始。问题出在哪里?

这是服务器:

<?php 
function getStockQuote($symbol) { 
   mysql_connect('localhost','root'); 
   mysql_select_db('mio'); 
   $query = "SELECT * FROM nomi WHERE nome = '$symbol' "; 
   $result = mysql_query($query); 
   $row = mysql_fetch_assoc($result) 
   return $row['scuola'];
}

require('nusoap.php'); 
$server = new nusoap_server(); 
$server->configureWSDL('stockquote', 'urn:stockquote'); 
$server->register("getStockQuote", 
            array('symbol' => 'xsd:string'), 
            array('return' => 'xsd:string'), 
            'urn:stockquote', 
            'urn:stockquote#getStockQuote'); 

if( ! isset( $HTTP_RAW_POST_DATA )) {
   $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
}
$server->service($HTTP_RAW_POST_DATA); 
?> 

这是客户..

<html> 
<body> 

<form method="get" action="client.php"> 
ID: <input name="symbol" type="text" value=""> 
<br> 
<br> 
<input type="submit"> 
</form> 

<?php 
$symbol = $_GET['symbol']; 
if ($symbol) { 
   require_once('nusoap.php'); 
   $c = new nusoap_client('serv.wsdl',true); 
   $stockprice = $c->call('getStockQuote', 
          array('symbol' => $symbol)); 
   echo "Information for $symbol is $stockprice."; 
} 
?> 
</body> 
</html> 

这是wsdl:

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  
ema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:stockquote"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:stockquote">
<types>
<xsd:schema targetNamespace="urn:stockquote">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>

</xsd:schema>
</types>
<message name="getStockQuoteRequest">
<part name="symbol" type="xsd:string"/>
</message>
<message name="getStockQuoteResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="stockquotePortType">
<operation name="getStockQuote">
<input message="tns:getStockQuoteRequest"/>
<output message="tns:getStockQuoteResponse"/>
</operation>
</portType>
<binding name="stockquoteBinding" type="tns:stockquotePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getStockQuote">
<soap:operation soapAction="urn:stockquote#getStockQuote" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:stockquote" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:stockquote"       
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="stockquote">
<port name="stockquotePort" binding="tns:stockquoteBinding">
<soap:address location="server.php"/>
</port>
</service>
</definitions>

我应该改变什么?

4

1 回答 1

0

尝试为您的数据库设置具有密码的用户。它对我有用。

于 2019-03-06T12:56:21.303 回答