对于在数据库中存储为 BLOB 的图像,wsdl 中的 xsd 应该使用什么数据类型?

What data type should put for the xsd in the wsdl for images stored as BLOB in the database?

我正在尝试创建一个简单的 Web 服务,用户可以在其中根据输入的价格从数据库中检索名称价格和图片,但出现错误:

Exception: SOAP-ERROR: Encoding: object has no 'Image' property

我想这一定是因为我没有在 xsd 中输入正确的数据类型。这是 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:hexBinary"/> //data type
     </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>

任何帮助将不胜感激。

如果图像确实必须存储在 XML 中,请将其转换为 Base64 and use xsd:base64Binary 类型。

但是,如果可能,请尝试将图像与 XML 文件分开存储,并在 XML 中包含对图像的引用(例如 URL)。