PHP SoapClient Call Method set parameter attributes

Hi,
I am working on a soap project.
When I test with soap UI I get successful results.
If you look at the codes below, I think I can tell you what I want to do.
But I’m having a problem when I do the operation with PHP. I define the values I send as Array, but I need to define 2 as an XML attribute for a value. I couldn’t do that with Array I wonder if there is another way to do it.

WSDL address
:frowning:
Transaction address
:frowning:

XML I send with Soap UI
    <soapenv:Envelope xmlns:soapenv="......envelope/" xmlns:wsdl="....schemas.i2i.com/ei/wsdl" xmlns:xm="......mlmime">
       <soapenv:Header/>
       <soapenv:Body>
          <wsdl:SendInvoiceRequest>
             <REQUEST_HEADER>
                <SESSION_ID>c64e467f-5058-454d-a828-e27fe79df8b0</SESSION_ID>
                <COMPRESSED>N</COMPRESSED>
             </REQUEST_HEADER>
             <!--Optional:-->
             <RECEIVER vkn="2930059278" alias="..................."/>
             <INVOICE>
             		<CONTENT>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmN.........</CONTENT>
             </INVOICE>
          </wsdl:SendInvoiceRequest>
       </soapenv:Body>
    </soapenv:Envelope>

PHP code
        $req = [
                            "REQUEST_HEADER" => [
                                "SESSION_ID" => $sid,
                                "COMPRESSED" => "N"
                            ],
                            'RECEIVER'=>[
                                [
                                    '_' => '',
                                    'vkn'=>$this->dbFatura->alvkn,
                                    'alias'=>$this->eFaturaPk,
                                ],
                            ],
                            'INVOICE'=>[
                                'CONTENT'=>base64_encode($this->faturaData),
                            ],
                    ];
        $send = $c->SendInvoice($req);

I can’t figure out how to do the above XML with array in PHP. I searched a lot. I guess PHP doesn’t support it.

https://www.php.net/manual/en/class.soapclient.php

I think you answered the message before reading it. Give me the first look at the link you provided and there is no answer regarding this problem.

I did miss a portion. How are you building the XML structure?

https://www.php.net/manual/en/simplexmlelement.addattribute.php

SimpleXml?

Sponsor our Newsletter | Privacy Policy | Terms of Service