繁体   English   中英

PHP和mysql中的Webservice SOAP

[英]Webservice SOAP in php & mysql

我是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>

我应该改变什么?

尝试为用户设置数据库密码。 它为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM