PHP对象的WSDL问题,奇怪的<SOAP-ENC:Struct>元素 [英] WSDL problem with PHP objects, strange <SOAP-ENC:Struct> elements
问题描述
我正在尝试处理通过 WSDL 提供一些数据的 PHP 代码.WSDL 文件中有两种方法,一种是有效的,另一种是完全相同的.
I'm trying to deal with PHP code which is serving some data through WSDL. There are two methods in the WSDL file, one of the is working, the other which is totally identical is not.
GetAllProducts 返回:
GetAllProducts returns:
<ns1:GetAllProductsResponse>
<describedProductArray>
<DescribedProduct>
<id> ... </id>
<foo> ... </foo>
</DescribedProduct>
<Describedproduct>
...
</DescribedProduct>
...
</describedProductArray>
etc
但 GetAllDischargedProducts 返回
But GetAllDischargedProducts returns
<ns1:GetAllDischargedProductsResponse>
<dischargedProductArray>
<DischargedProduct>
<SOAP-ENC:Struct>
<DischargeDate> ... </DischargeDate>
<id> ... </id>
</SOAP-ENC:Struct>
<SOAP-ENC:Struct>
<DischargeDate> ... </DischargeDate>
<id> .. </id>
</SOAP-ENC:Struct>
...
</DischargedProduct>
<dischargedProductArray>
我必须摆脱这些元素并将每组数据放入一个单独的元素中.PHP 部分看起来不错.我想问题出在 WSLD 文件中.
I have to get rid of these elements and put each set of data into a separate element. The PHP part looks ok. I suppose the problem is somewhere in the WSLD file.
描述数据的部分是这样的:
The part that describes the data is this:
<complexType name="DescribedProduct">
<complexContent>
<extension base="self:Product">
<sequence>
<element name="Name" type="self:Name" />
<element name="Barcode" type="self:Barcode" />
<element name="Exportation" type="boolean" />
<element name="Company" type="self:Company" />
<element name="Prescription" type="self:Prescription" />
<element name="CommercialForm" type="self:CommercialForm" />
<element name="IngredientArray" type="self:IngredientArray" />
<element name="DayToExcretion" type="self:DayToExcretion" />
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="DescribedProductArray">
<sequence>
<element name="DescribedProduct" type="self:DescribedProduct" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
<simpleType name="DischargeDate">
<restriction base="date" />
</simpleType>
<complexType name="DischargedProduct">
<complexContent>
<extension base="self:Product">
<sequence>
<element name="DischargeDate" type="self:DischargeDate" />
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="DischargedProductArray">
<sequence>
<element name="DischargedProduct" type="self:DischargedProduct" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
推荐答案
这是因为 DischargeDate
简单类型受到了限制.我建议对此元素使用简单的字符串类型,并对代码中的日期执行任何类型的验证.
This is because the DischargeDate
simple type has been given a restriction. I'd suggest to use simple string type for this element and perform any kind of validation for dates in your code.
因此将 DischargedProduct
定义更改为:
So change the DischargedProduct
definition to something like:
<complexType name="DischargedProduct">
<complexContent>
<extension base="self:Product">
<sequence>
<element name="DischargeDate" type="string" />
</sequence>
</extension>
</complexContent>
</complexType>
并删除DischargeDate
的定义.
这篇关于PHP对象的WSDL问题,奇怪的<SOAP-ENC:Struct>元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!