简体   繁体   English

WSDL与PHP对象有关的问题,很奇怪 <SOAP-ENC:Struct> 分子

[英]WSDL problem with PHP objects, strange <SOAP-ENC:Struct> elements

I'm trying to deal with PHP code which is serving some data through WSDL. 我正在尝试处理通过WSDL提供一些数据的PHP代码。 There are two methods in the WSDL file, one of the is working, the other which is totally identical is not. WSDL文件中有两种方法,一种有效,另一种完全不同。

GetAllProducts returns: GetAllProducts返回:

<ns1:GetAllProductsResponse>
    <describedProductArray>
        <DescribedProduct>
            <id> ... </id>
            <foo> ... </foo>
        </DescribedProduct>
        <Describedproduct>
            ...
        </DescribedProduct>
        ...
</describedProductArray>
etc

But GetAllDischargedProducts returns 但是GetAllDischargedProducts返回

<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>

I have to get rid of these elements and put each set of data into a separate element. 我必须摆脱这些元素,并将每组数据放入一个单独的元素中。 The PHP part looks ok. PHP部分看起来还可以。 I suppose the problem is somewhere in the WSLD file. 我想问题出在WSLD文件中。

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>

This is because the DischargeDate simple type has been given a restriction. 这是因为对DischargeDate简单类型进行了限制。 I'd suggest to use simple string type for this element and perform any kind of validation for dates in your code. 我建议对此元素使用简单的字符串类型,并对代码中的日期执行任何形式的验证。

So change the DischargedProduct definition to something like: 因此,将DischargedProduct定义更改为:

<complexType name="DischargedProduct">
    <complexContent>
        <extension base="self:Product">
            <sequence>
                <element name="DischargeDate" type="string" />
            </sequence>
        </extension>
    </complexContent>
</complexType>

and remove the definition of DischargeDate . 并删除DischargeDate的定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM