dt2002 2011-08-30 09:11
浏览 47
已采纳

错误的请求生成soap客户端php

I'm trying to make a request to a soap webservice of mine.

    class DateTime2 extends DateTime {
        function __toString() { 
            return $this->format("d/m/Y H:i");
        }
    }
    $date = new DateTime2();

    $client = new SoapClient("http://www.myos.it/sp/smartphonelayer.asmx?wsdl",array("trace" => 1));
    $result = $client->SetReservation("Mario Rossi",2,"01234567",$date."");
    echo "REQUEST:".$client->__getLastRequest()."<br>"; 
    print_r($result);

The output i get is:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
    <SOAP-ENV:Body>
        <ns1:SetReservation/>
        <param1>2</param1>
        <param2>3286026817</param2>
        <param3>2011-08-30T07:10:32</param3>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<br>stdClass Object
(
  [SetReservationResult] => stdClass Object
     (
         [Success] => SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
            [DeskCode] => 
            [Message] => 
       )

)

As you can see i get only 3 parameters in request created by soapClient when i give it 4 parameteres.

展开全部

  • 写回答

1条回答 默认 最新

  • douhuang1852 2011-09-07 04:41
    关注

    For Sending the Parameter you need to use the array()

    Also for Date Time, XML needs following format

    class DateTime2 extends DateTime {
        function __toString() { 
            return $this->format("Y-m-d\TH:i:s.000\Z");
        }
    }
    $date = new DateTime2();
    $client = new SoapClient("http://www.myos.it/sp/smartphonelayer.asmx?wsdl",array("trace" => 1));
    
    $result = $client->SetReservation(array( "RDescription"=>"Giuseppe Silvestri",
                                             "RNumber"=>2,
                                             "RPhoneNumber"=>"3286026817",
                                             "RDate"=>$date.""));
    echo "REQUEST:".$client->__getLastRequest()."<br>"; 
    print_r($result);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部