为什么我不能从本地主机访问图像?甚至可以通过网络服务显示图像吗?
Why can't i access an image from the localhost? Is it even possible to display an image through web services?
每次我尝试显示图像时,都好像 link 不正确。使用控制台我得到错误
Failed to load resource: the server responded with a status of 404 (Not Found)
同一个文件夹怎么找不到呢?
我检查了 link,我发现正确的 link 是 xampp/htdocs/WebService/Client/images/1.jpg 而不是 localhost/WebService/Client/images/1.jpg 但 xampp/htdocs 本身被视为本地主机,对吗?
那么解决这个问题的方法是什么?我一直在寻找2天。通过做一些研究,我什至尝试创建单独的虚拟主机但无济于事。
它只是无法从本地主机找到文件图像。我能做些什么?
请帮忙。
client.php的代码:
<?php
if(isset($_POST['search_input']))
{
try
{
$input = $_POST['search_input'];
$wsdl = "http://localhost/WebService/UDDI/90210Store.wsdl";
$options = array('cache_wsdl'=>WSDL_CACHE_NONE, 'features'=>SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($wsdl, $options);
$response = $client->viewDressPerPrice($input);
if(isset($response->DressPerPrice))
{
$HTMLDocument = "<!DOCTYPE html>
<html>
<head><h3>Dresses</h3></head>
<body>
<table border='1'>";
foreach($response->DressPerPrice as $record)
{
$HTMLDocument .= "<tr><td>".$record->Name."</td>";
$HTMLDocument .="<td>".$record->Price."</td>";
$HTMLDocument .="<td><img src=images/".$record->Image."/></td>";
}
$HTMLDocument .= "</table>
</body>
</html>";
echo "<table border='1'><tr><td><img src='C:/xampp/htdocs/WebService/Client/images/1.jpg'/></td></tr></table>";
echo $HTMLDocument;
}
else
{
echo "This field is not found in database";
}
}
catch(Exception $e)
{
echo 'Exception: '.$e->getMessage();
}
catch(SOAPFault $exception)
{
echo 'SOAP Exception: '.$exception->getMessage();
}
}
else
{
header("Location: http://localhost/WebService/Client/Category.html");
}
?>
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:element name="Image" type="xs:anyURI"/>
</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>
</definitions>
图像正在 link 编辑到 C:/xampp/htdocs/WebService/Client/images/1.jpg
。您必须 link 来自本地主机的图像。网站(甚至本地网站)无法访问您的 C:
驱动器。因此,将图像更改为 http://localhost/WebService/Client/images/1.jpg
甚至 /WebService/Client/images/1.jpg
都可以。
每次我尝试显示图像时,都好像 link 不正确。使用控制台我得到错误
Failed to load resource: the server responded with a status of 404 (Not Found)
同一个文件夹怎么找不到呢? 我检查了 link,我发现正确的 link 是 xampp/htdocs/WebService/Client/images/1.jpg 而不是 localhost/WebService/Client/images/1.jpg 但 xampp/htdocs 本身被视为本地主机,对吗? 那么解决这个问题的方法是什么?我一直在寻找2天。通过做一些研究,我什至尝试创建单独的虚拟主机但无济于事。 它只是无法从本地主机找到文件图像。我能做些什么? 请帮忙。
client.php的代码:
<?php
if(isset($_POST['search_input']))
{
try
{
$input = $_POST['search_input'];
$wsdl = "http://localhost/WebService/UDDI/90210Store.wsdl";
$options = array('cache_wsdl'=>WSDL_CACHE_NONE, 'features'=>SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($wsdl, $options);
$response = $client->viewDressPerPrice($input);
if(isset($response->DressPerPrice))
{
$HTMLDocument = "<!DOCTYPE html>
<html>
<head><h3>Dresses</h3></head>
<body>
<table border='1'>";
foreach($response->DressPerPrice as $record)
{
$HTMLDocument .= "<tr><td>".$record->Name."</td>";
$HTMLDocument .="<td>".$record->Price."</td>";
$HTMLDocument .="<td><img src=images/".$record->Image."/></td>";
}
$HTMLDocument .= "</table>
</body>
</html>";
echo "<table border='1'><tr><td><img src='C:/xampp/htdocs/WebService/Client/images/1.jpg'/></td></tr></table>";
echo $HTMLDocument;
}
else
{
echo "This field is not found in database";
}
}
catch(Exception $e)
{
echo 'Exception: '.$e->getMessage();
}
catch(SOAPFault $exception)
{
echo 'SOAP Exception: '.$exception->getMessage();
}
}
else
{
header("Location: http://localhost/WebService/Client/Category.html");
}
?>
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:element name="Image" type="xs:anyURI"/>
</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>
</definitions>
图像正在 link 编辑到 C:/xampp/htdocs/WebService/Client/images/1.jpg
。您必须 link 来自本地主机的图像。网站(甚至本地网站)无法访问您的 C:
驱动器。因此,将图像更改为 http://localhost/WebService/Client/images/1.jpg
甚至 /WebService/Client/images/1.jpg
都可以。