SOAP请求中的内容不完整

时间:2018-04-10 14:56:26

标签: php xml soap

我是SOAP请求的新手,我正在试图弄清楚它是如何工作的。

我正在尝试请求销售订单对象。 这是我收到的wsdl代码:

<s:element name="Start">
<s:complexType>
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="company" type="s:string" />
        <s:element minOccurs="0" maxOccurs="1" name="orders" type="tns:ArrayOfSalesOrdersSalesOrder" />
    </s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfSalesOrdersSalesOrder">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="unbounded" name="SalesOrdersSalesOrder" nillable="true">
            <s:complexType>
                <s:sequence>
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="CustomerNumber" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="OrderNumber" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Currency" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="CustomerComment" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="OrderReference" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="FirstName" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="LastName" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Street" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="ZipCode" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="City" type="s:string" />
                    <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Country" type="s:string" />
                    <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Discount" type="s:decimal" />
                    <s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="ChargeHeader">
                        <s:complexType>
                            <s:sequence>
                                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Code" type="s:string" />
                                <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Value" type="s:decimal" />
                            </s:sequence>
                        </s:complexType>
                    </s:element>
                    <s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="Orderline">
                        <s:complexType>
                            <s:sequence>
                                <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="PartNumber" type="s:string" />
                                <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Qty" type="s:decimal" />
                                <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="FreeIssue" type="s:boolean" />
                                <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Discount" type="s:decimal" />
                                <s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="ChargeLine">
                                    <s:complexType>
                                        <s:sequence>
                                            <s:element minOccurs="0" maxOccurs="1" form="unqualified" name="Code" type="s:string" />
                                            <s:element minOccurs="1" maxOccurs="1" form="unqualified" name="Value" type="s:decimal" />
                                        </s:sequence>
                                    </s:complexType>
                                </s:element>
                            </s:sequence>
                        </s:complexType>
                    </s:element>
                </s:sequence>
            </s:complexType>
        </s:element>
    </s:sequence>
</s:complexType>

我发现我必须做以下事情:

$order = array( 
    'company' => '10',
    'orders' => array(
        'SalesOrdersSalesOrder' => array(
            'CustomerNumber'        => '12345234',
            'OrderNumber'           => '0000001',
            'Currency'              => 'EUR',
            'CustomerComment'       => 'Dit is de comment',
            'FirstName'             => 'Lex',
            'LastName'              => 'Test',
            'Street'                => 'Teststraat 12',
            'ZipCode'               => '1231df',
            'City'                  => 'Testing',
            'Country'               => 'NL',
            'Discount'              => 11.11,
            'ChargeHeader'          => array(
                'Code'          => '001',
                'Value'         => 99.99
            ),
            'OrderLine'             => array (
                'PartNumber'    => '01-001-000-42',
                'Qty'           => 1,
                'FreeIssue'     => false,
                'Discount'      => 1.11,
                'ChargeLine'    => array(
                    'Code'          => '001',
                    'Value'         => 33.33
                )
            ),                            
            'OrderLine'             => array (
                'PartNumber'    => '01-001-000-42',
                'Qty'           => 1,
                'FreeIssue'     => false,
                'Discount'      => 1.11,
                'ChargeLine'    => array(
                    'Code'          => '001',
                    'Value'         => 33.33
                )
            ),                            
            'OrderLine' => array (
                'PartNumber'    => '01-001-000-42',
                'Qty'           => 1,
                'FreeIssue'     => false,
                'Discount'      => 1.11,
                'ChargeLine'    => array(
                    'Code'          => '001',
                    'Value'         => 33.33
                )
            )
        )
    )
);

但是,当我尝试将此帖子发布到客户端时,我得到以下回复:

  

SalesOrder元素的内容不完整。预期清单   模块化元素:ChargeHeader,Orderline。

在wsdl中,关于ChargeHeader的内容如下:

<s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="Orderline">
<s:complexType>

所以我想知道如何进行以下工作?我认为complexType是一个数组,但它可能是别的东西。

感谢所有帮助。

1 个答案:

答案 0 :(得分:0)

您不能在PHP中的数组中包含具有相同键的多个值。每一个都会覆盖前一个。

WSDL说SalesOrdersSalesOrderOrderline都应该是这些值的数组。

此外,它应该是Orderline而不是OrderLine

$order = array(
    'company' => '10',
    'orders' => array(
        'SalesOrdersSalesOrder' => array(
            array(
                'CustomerNumber'        => '12345234',
                'OrderNumber'           => '0000001',
                'Currency'              => 'EUR',
                'CustomerComment'       => 'Dit is de comment',
                'FirstName'             => 'Lex',
                'LastName'              => 'Test',
                'Street'                => 'Teststraat 12',
                'ZipCode'               => '1231df',
                'City'                  => 'Testing',
                'Country'               => 'NL',
                'Discount'              => 11.11,
                'ChargeHeader'          => array(
                    'Code'          => '001',
                    'Value'         => 99.99
                ),
                'OrderLine'             => array(
                    array (
                        'PartNumber'    => '01-001-000-42',
                        'Qty'           => 1,
                        'FreeIssue'     => false,
                        'Discount'      => 1.11,
                        'ChargeLine'    => array(
                            'Code'          => '001',
                            'Value'         => 33.33
                        )
                    ),
                    array (
                        'PartNumber'    => '01-001-000-42',
                        'Qty'           => 1,
                        'FreeIssue'     => false,
                        'Discount'      => 1.11,
                        'ChargeLine'    => array(
                            'Code'          => '001',
                            'Value'         => 33.33
                        )
                    ),
                    array (
                        'PartNumber'    => '01-001-000-42',
                        'Qty'           => 1,
                        'FreeIssue'     => false,
                        'Discount'      => 1.11,
                        'ChargeLine'    => array(
                            'Code'          => '001',
                            'Value'         => 33.33
                        )
                    )
                ),
            )
        )
    )
);