0

After moving to the new server with php7, SOAP stopped generating one of the elements contained in the transferred object in the XML request.

Link to the WSDL file: WSDL to test WebApi

And a sample code that generates object passing to SOAP:

    $shipment = new addShipment();
    $P = new przesylkaBiznesowaType();
    $A = new adresType();

    $adres = new adresType();
    $adres->miejscowosc = "Gdynia";
    $adres->kodPocztowy = "81-301";
    $adres->kraj = "Polska";
    $adres->nazwa = "Jan Kowalski";
    $adres->ulica = "10 Lutego";
    $adres->numerDomu = "10";
    $adres->email = "[email protected]";
    $adres->mobile = "510000000";
    $P->adres = $adres;

    $P->opis = "";
    $P->masa = "500";
    $P->wartosc = "600";
    $P->ostroznie = true;
    $P->gabaryt = gabarytBiznesowaType::XL;
    unset($P->urzadWydaniaEPrzesylki);  

    $subPrzesylka1 = new subPrzesylkaBiznesowaType();
    $subPrzesylka1->guid = getGuid();
    $subPrzesylka1->gabaryt = gabarytBiznesowaType::M;
    $subPrzesylka1->masa = 4233;
    $subPrzesylka1->ostroznie = false;
    $subPrzesylka1->opis = "";
    $subPrzesylka2 = new subPrzesylkaBiznesowaType();
    $subPrzesylka2->guid = getGuid();
    $subPrzesylka2->gabaryt = gabarytBiznesowaType::L;
    $subPrzesylka2->masa = 4233;
    $subPrzesylka2->ostroznie = false;
    $subPrzesylka2->opis = "";
    $subPrzesylka3 = new subPrzesylkaBiznesowaType();
    $subPrzesylka3->guid = getGuid();
    $subPrzesylka3->gabaryt = gabarytBiznesowaType::XXL;
    $subPrzesylka3->masa = 4233;
    $subPrzesylka3->ostroznie = false;
    $subPrzesylka3->opis = "";
    $subPrzesylka4 = new subPrzesylkaBiznesowaType();
    $subPrzesylka4->gabaryt = gabarytBiznesowaType::S;
    $subPrzesylka4->masa = 4233;
    $subPrzesylka4->guid = getGuid();
    $subPrzesylka4->ostroznie = false;
    $subPrzesylka4->opis = "";
    $subPrzesylka5 = new subPrzesylkaBiznesowaType();
    $subPrzesylka5->guid = getGuid();
    $subPrzesylka5->gabaryt = gabarytBiznesowaType::M;
    $subPrzesylka5->masa = 4233;
    $subPrzesylka5->ostroznie = false;
    $subPrzesylka5->opis = "";

    $P->subPrzesylka = array(
            $subPrzesylka1,
            $subPrzesylka2,
            $subPrzesylka3,
            $subPrzesylka4,
            $subPrzesylka5 );

    $shipment->guid = getGuid();
    $P->guid = $this->guid;
    $shipment->przesylki[] = $P;
    $E = new ElektronicznyNadawca();
    $result = $E->addShipment($shipment);

In the sample code I'm using classess defined in the file ElektronicznyNadawca.php from this archive: webapi specification

Object looks like this:

addShipment Object
(
[przesylki] => Array
    (
        [0] => przesylkaBiznesowaType Object
            (
                [pobranie] => 
                [subPrzesylka] => Array
                    (
                        [0] => subPrzesylkaBiznesowaType Object
                            (
                                [ubezpieczenie] => 
                                [numerNadania] => 
                                [masa] => 4233
                                [gabaryt] => M
                                [wartosc] => 
                                [ostroznie] => 
                                [guid] => 9419B78744013A2F06A503F2A32AA977
                                [opis] => 
                            )

                        [1] => subPrzesylkaBiznesowaType Object
                            (
                                [ubezpieczenie] => 
                                [numerNadania] => 
                                [masa] => 4233
                                [gabaryt] => L
                                [wartosc] => 
                                [ostroznie] => 
                                [guid] => 0F10CB861668B705C657A3C567924E00
                                [opis] => 
                            )

                        [2] => subPrzesylkaBiznesowaType Object
                            (
                                [ubezpieczenie] => 
                                [numerNadania] => 
                                [masa] => 4233
                                [gabaryt] => XXL
                                [wartosc] => 
                                [ostroznie] => 
                                [guid] => F3DC09C9090CD62FCCD56B55BDD9373A
                                [opis] => 
                            )

                        [3] => subPrzesylkaBiznesowaType Object
                            (
                                [ubezpieczenie] => 
                                [numerNadania] => 
                                [masa] => 4233
                                [gabaryt] => S
                                [wartosc] => 
                                [ostroznie] => 
                                [guid] => 730F8E0E7DA0C89F2051651B0F221BBD
                                [opis] => 
                            )

                        [4] => subPrzesylkaBiznesowaType Object
                            (
                                [ubezpieczenie] => 
                                [numerNadania] => 
                                [masa] => 4233
                                [gabaryt] => M
                                [wartosc] => 
                                [ostroznie] => 
                                [guid] => 179E6EB18B16CBE1D44E2640312B0562
                                [opis] => 
                            )

                    )

                [ubezpieczenie] => 
                [epo] => 
                [zasadySpecjalne] => 
                [masa] => 500
                [gabaryt] => XL
                [wartosc] => 600
                [ostroznie] => 1
                [numerTransakcjiOdbioru] => 
                [adres] => adresType Object
                    (
                        [nazwa] => Jan Kowalski
                        [nazwa2] => 
                        [ulica] => 10 Lutego
                        [numerDomu] => 10
                        [numerLokalu] => 
                        [miejscowosc] => Gdynia
                        [kodPocztowy] => 81-301
                        [kraj] => Polska
                        [telefon] => 
                        [email] => [email protected]
                        [mobile] => 510000000
                        [osobaKontaktowa] => 
                        [nip] => 
                    )

                [opis] => 
                [guid] => 627EFD182DDBDFEF9E4D263E32E093CC
            )

    )

[idBufor] => 697283
[guid] => 627EFD182DDBDFEF9E4D263E32E093CC
)

XML request should look like this

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://e-nadawca.poczta-polska.pl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:addShipment>
<przesylki guid="1064FEBB36ECA2CB9C04B2163DE14A97" opis="" masa="500" gabaryt="XL" wartosc="600" ostroznie="true" xsi:type="ns1:przesylkaBiznesowaType">
<adres nazwa="Jan Kowalski" ulica="10 Lutego" numerDomu="10" miejscowosc="Gdynia" kodPocztowy="81-301" kraj="Polska" email="[email protected]" mobile="510000000"/>
<subPrzesylka guid="134571C05EBAB5125D2205E52C6D3309" opis="" masa="4233" gabaryt="M" ostroznie="false"/>
<subPrzesylka guid="173E430572FF57276A1CAE125BB5D703" opis="" masa="4233" gabaryt="L" ostroznie="false"/>
<subPrzesylka guid="134FF717F643F51F7BF4126A5668D5A8" opis="" masa="4233" gabaryt="XXL" ostroznie="false"/>
<subPrzesylka guid="1584130F49408A45D375F73DC483485A" opis="" masa="4233" gabaryt="S" ostroznie="false"/>
<subPrzesylka guid="1E3E081414818276A842AAE255ABC68C" opis="" masa="4233" gabaryt="M" ostroznie="false"/>
</przesylki>
<idBufor>20279201</idBufor>
</ns1:addShipment>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

But it doesn't coinatin 'subPrzesylka' elements and it looks like this:

<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://e-nadawca.poczta-polska.pl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap-env:body>
    <ns1:addshipment>
        <przesylki guid="2E367E17EEE4DC52FFF47F7170769F21" opis="" masa="500" gabaryt="XL" wartosc="600" ostroznie="true" xsi:type="ns1:przesylkaBiznesowaType">
            <adres nazwa="Jan Kowalski" ulica="10 Lutego" numerdomu="10" miejscowosc="Gdynia" kodpocztowy="81-301" kraj="Polska" email="[email protected]" mobile="510000000"></adres>
        </przesylki>
        <idbufor>697283</idbufor>
    </ns1:addshipment>
</soap-env:body>
</soap-env:envelope>

The same code works on older servers with php 5.3 and 5.6. It looks like SOAP on php 7 doesn't recognizes this part of WSDL definition:

<xsd:choice>
    <xsd:element name="urzadWydaniaEPrzesylki" type="tns:urzadWydaniaEPrzesylkiType" maxOccurs="1" minOccurs="0" />
    <xsd:element name="subPrzesylka" type="tns:subPrzesylkaBiznesowaType" minOccurs="4" maxOccurs="unbounded" />
</xsd:choice>

in

<xsd:complexType name="przesylkaBiznesowaType">
    <xsd:complexContent>
        <xsd:extension base="tns:przesylkaRejestrowanaType">
            <xsd:sequence>
                <xsd:element name="pobranie" type="tns:pobranieType" maxOccurs="1" minOccurs="0" />
                <xsd:choice>
                    <xsd:element name="urzadWydaniaEPrzesylki" type="tns:urzadWydaniaEPrzesylkiType" maxOccurs="1" minOccurs="0" />
                    <xsd:element name="subPrzesylka" type="tns:subPrzesylkaBiznesowaType" minOccurs="4" maxOccurs="unbounded" />
                </xsd:choice>
                <xsd:element name="ubezpieczenie" type="tns:ubezpieczenieType" maxOccurs="1" minOccurs="0" />
            </xsd:sequence>
            <xsd:attribute name="masa" type="tns:masaType" />
            <xsd:attribute name="gabaryt" type="tns:gabarytBiznesowaType" />
            <xsd:attribute name="wartosc" type="tns:wartoscType" />
            <xsd:attribute name="ostroznie" type="xsd:boolean" />
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="subPrzesylkaBiznesowaType">
    <xsd:complexContent>
        <xsd:extension base="tns:przesylkaType">
            <xsd:sequence>
                <xsd:element name="pobranie" type="tns:pobranieType" maxOccurs="1" minOccurs="0" />
                <xsd:element name="ubezpieczenie" type="tns:ubezpieczenieType" maxOccurs="1" minOccurs="0" />
            </xsd:sequence>
            <xsd:attribute name="numerNadania" type="tns:numerNadaniaType" />
            <xsd:attribute name="masa" type="tns:masaType" />
            <xsd:attribute name="gabaryt" type="tns:gabarytBiznesowaType" />
            <xsd:attribute name="wartosc" type="tns:wartoscType" />
            <xsd:attribute name="ostroznie" type="xsd:boolean" />
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

I've spent hours trying to figure it out. Does anyone know what could be the problem here?

1
  • 1
    In the meantime I've placed WSDL file on a local server and moved <xsd:element name="subPrzesylka" type="tns:subPrzesylkaBiznesowaType" minOccurs="4" maxOccurs="unbounded" /> element outside <xsd:choice> structure. And now the request xml contains subPrzesylka elements. That is only a temporary solution, we have to appeal to the original WSDL file but it looks like SOAP on php 7 doesn't react good on xsd:choice. Does anyone know why? Commented May 8, 2018 at 10:21

1 Answer 1

1

This is a bug in PHP 7.X. You should report it on bugs.php.net BTW CHOICE is a valid structure in WSDL files. Described in the official documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.