簡體   English   中英

PHP-SOAP請求-將xml嵌套為參數?

[英]PHP - SOAP request - nest xml as param?

我需要使XML SOAP請求的結構如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.fines.pl/api/contract">
    <SOAP-ENV:Body>
        <ns1:newApplicationRequest>
            <user_login>XYZ</user_login>
            <user_password>XYZ</user_password>
            <contract>
<?xml version="1.0" encoding="UTF-8"?>
<sof:Contract xmlns:s="http://www.fines.pl/simple" xmlns:sof="http://www.fines.pl/sof" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fines.pl/sof model.xsd ">
    <product>
        <prefix>MOP</prefix>
    </product>
    <participants>
        <customers>
            <main_borrower>
                <personal_data>
                    <pesel>85050949761</pesel>
                    <firstname>Anna</firstname>
                    <lastname>Test</lastname>
                    <firstname_father></firstname_father>
                    <firstname_mother></firstname_mother>
                    <secondname />
                    <sex>female</sex>
                </personal_data>
                <contact_data>
                    <addresses>
                        <address>
                            <type>registered</type>
                            <street_name>Grunwaldzka</street_name>
                            <block_number>11</block_number>
                            <flat_number>5</flat_number>
                            <postal_code>80-100</postal_code>
                            <city>Gdańsk</city>
                        </address>
                    </addresses>
                    <phones_mobile>
                        <phone_mobile>
                            <type>personal</type>
                            <number>602200300</number>
                        </phone_mobile>
                    </phones_mobile>
                </contact_data>
                <incomes>
                    <income>
                        <type>employment</type>
                        <main_income>true</main_income>
                        <fixed_term_contract>false</fixed_term_contract>
                        <paychecks>
                            <paycheck>
                                <amount_net>
                                    <amount>1444.00</amount>
                                    <currency>PLN</currency>
                                </amount_net>
                                <type>base</type>
                            </paycheck>
                        </paychecks>
                    </income>
                </incomes>
                <household_pointer>/households.0</household_pointer>
            </main_borrower>
        </customers>
    </participants>
</sof:Contract></contract></ns1:newApplicationRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

我已經將$params變量設置為包含user_loginuser_password元素及其各自的值,但是我不知道如何設置所需內容的contract參數。

$contract變量提供XML代碼(我認為這可能是一種解決方法)會Fatal error: Uncaught SoapFault exception: [xml_structure] String could not be parsed as XML錯誤。

非常感謝您解釋如何做到這一點。

您已經兩次聲明了<?xml?> ,在第一行中聲明了一個,在第八行中聲明了第二個。 這是我在xml方面看到的唯一錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM