我试图根据用户输入的价格创建一个简单的网络服务来检索服装的名称(仅用于尝试),但我收到错误消息
例外:功能(" DressPerPrice")不是此服务的有效方法
我做了一些研究,我发现它可能是因为缓存但在我的服务器中我已经指定禁用缓存:
server.php文件:
<?php
header("Cache-Control: no-cache");
header("Pragma: no-cache");
require_once('dbconnect.class.php');
require_once('PriceHandler.class.php');
dbconnect::initialise();
ini_set("soap.wsdl_cache_enabled","0"); //disable caching
$server = new SoapServer('http://localhost/WebService/UDDI/90210Store.wsdl');
$server->setClass('PriceHandler');
$server->setPersistence(SOAP_PERSISTENCE_REQUEST);
$server->handle();
dbconnect::close();
?>
WSDL 90210Store.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://www.shehzad.edu/webservice" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:this="http://www.shehzad.edu/webservice" xmlns="http://schemas.xmlsoap.org/wsdl/" xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/wsdl.xsd http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
<types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.shehzad.edu/webservice" elementFormDefault="qualified">
<xs:element name="Input" type="xs:string"/>
<xs:complexType name="DressType">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Price" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ArrayOfDresses">
<xs:sequence>
<xs:element name="DressPerPrice" minOccurs="1" maxOccurs="unbounded" type="this:DressType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Result" type="this:ArrayOfDresses"/>
</xs:schema>
</types>
<!--input message-->
<message name="getDressPerPriceRequest">
<part name="input" element="this:Input"/>
</message>
<!--output message-->
<message name="getDressPerPriceResponse">
<part name="result" element="this:Result"/>
</message>
<portType name="DressPerPricePortType">
<operation name="viewDressPerPrice">
<input message="this:getDressPerPriceRequest"/>
<output message="this:getDressPerPriceResponse"/>
</operation>
</portType>
<binding name="DressPerPriceBinding" type="this:DressPerPricePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="viewDressPerPrice">
<soap:operation soapAction="http://www.shehzad.edu/webservice"/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output>
</operation>
</binding>
<service name="DressPerPriceService">
<port name="DressPerPricePort" binding="this:DressPerPriceBinding">
<soap:address location="http://localhost/WebService/Server/Server.php"/>
</port>
</service>
保留服务器使用的方法/函数的类(PriceHandler.class.php):
<?php
class PriceHandler{
public function dressPerPrice($param)
{
$sql = "SELECT (name,price) FROM product WHERE
price LIKE '%".$param."%';";
$db_result = mysql_query($sql);
if(!db_result)
{
echo ("Query failed: ".mysql_error());
}
$ns = "http://www.shehzad.edu/webservice";
$dressPerPrice = array();
$result = array();
if(mysql_num_rows($db_result) > 0)
{
while($row = mysql_fetch_assoc($db_result))
{
$dressPerPrice[] = array('Name' => $row['name'] , 'Price' => $row['price']);
}
mysql_free_result($db_result);
$result = array('DressPerPrice'=>$dressPerPrice);
}
return $result;
}
}
?>
category.html文件(表单所在的位置):
<!DOCTYPE HTML>
<html>
<head><h1>Dresses</h1></head>
<body>
<p>
<center>
<table border="1" style="border-collapse:collapse;">
<form id = "get_dress" action="Client.php" method="post">
<tr><td colspan="2">
<h3><center>Getting dresses per price</center></h3>
</td>
</tr>
<tr><td>Enter field to search for: </td>
<td><input type="text" name="search_input"></td>
</tr>
<tr style="text-align:center;"><td colspan="2"><input type="submit" value="SUBMIT" name="submit"></td></tr>
</form>
</table>
</center>
</p>
</body>
</html>
如果您需要任何其他代码,请告诉我们。
我真的不知道可能导致错误的原因。我对Web服务不熟悉,请宽容一点。感谢。