我正在尝试创建一个简单的Web服务,用户可以根据输入的价格从数据库中检索名称价格和图片,但我收到错误:
异常:SOAP-ERROR:编码:对象没有'Image'属性
我假设它一定是因为我没有在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>
非常感谢任何帮助。
答案 0 :(得分:0)
如果图片确实必须存储在XML中,请将其转换为Base64并使用xsd:base64Binary
类型。
但是,如果可能的话,尝试将图像与XML文件分开存储,并在XML中包含对图像的引用(例如URL)。