使用PHP SoapClient

时间:2017-12-08 15:05:47

标签: php arrays soap

我试图向soap服务器发出请求,我的数据是:

[0] => Array
    (
        [fid] => 1
        [fvalueString] => Knaanic Language Structure Historical Background
        [fvalueInt] => 0
        [fvalueFloat] => 0
        [fvalueImage] => 0
        [fvalueDatetime] => 0
        [fvalueDate] => 
        [fvalueRangeInt] => Array
            (
                [fvalueRangeIntMin] => 0
                [fvalueRangeIntMax] => 0
            )

        [fvalueRangeFloat] => Array
            (
                [fvalueRangeFloatMin] => 0
                [fvalueRangeFloatMax] => 0
            )

        [fvalueRangeDate] => Array
            (
                [fvalueRangeDateMin] => 
                [fvalueRangeDateMax] => 
            )

    )

[1] => Array
    (
        [fid] => 2
        [fvalueString] => 
        [fvalueInt] => 6708
        [fvalueFloat] => 0
        [fvalueImage] => 0
        [fvalueDatetime] => 0
        [fvalueDate] => 
        [fvalueRangeInt] => Array
            (
                [fvalueRangeIntMin] => 0
                [fvalueRangeIntMax] => 0
            )

        [fvalueRangeFloat] => Array
            (
                [fvalueRangeFloatMin] => 0
                [fvalueRangeFloatMax] => 0
            )

        [fvalueRangeDate] => Array
            (
                [fvalueRangeDateMin] => 
                [fvalueRangeDateMax] => 
            )

    )

[2] => Array
    (
        [fid] => 3
        [fvalueString] => 
        [fvalueInt] => 0
        [fvalueFloat] => 0
        [fvalueImage] => 0
        [fvalueDatetime] => stdClass Object
            (
                [serverTime] => 1504262612
            )

        [fvalueDate] => 
        [fvalueRangeInt] => Array
            (
                [fvalueRangeIntMin] => 0
                [fvalueRangeIntMax] => 0
            )

        [fvalueRangeFloat] => Array
            (
                [fvalueRangeFloatMin] => 0
                [fvalueRangeFloatMax] => 0
            )

        [fvalueRangeDate] => Array
            (
                [fvalueRangeDateMin] => 
                [fvalueRangeDateMax] => 
            )

    )

有更多字段,但所有字段与上面相同。我尝试使用带有__call方法的php SoapClient进行soap调用:

$this->_client->doCheckNewAuctionExt( array(
            'sessionHandle' => $this->_session['sessionHandlePart'],
            'fields' => $fields
        )
    );

其中$ fields是包含我在上面发布的数据的数组,而_session是我用另一个请求获得的sessionId。服务器给我错误,当我检查请求xml它看起来:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="https://webapi.aukro.cz/service.php"><SOAP-ENV:Body>
<ns1:DoCheckNewAuctionExtRequest>
<ns1:sessionHandle>my session Id is passed correctly</ns1:sessionHandle>
<ns1:fields/></ns1:DoCheckNewAuctionExtRequest>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

为什么空?这是wsdl:https://webapi.aukro.cz/?wsdl

编辑:

我找到了解决方案,但我不知道为什么会起作用:

    $req=[];
    foreach ($Fields as $field){
        $req[]=$field;
    }
    $response = ($this->_client->doCheckNewAuctionExt(array(
            'sessionHandle' => $this->_session['sessionHandlePart'],
            'fields' =>  $req)))

0 个答案:

没有答案