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

落花浮王杯 提交于 2019-12-24 02:36:06

问题


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

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

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>

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>

回答1:


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.

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>

and remove the definition of DischargeDate.



来源:https://stackoverflow.com/questions/5922620/wsdl-problem-with-php-objects-strange-soap-encstruct-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!