not a valid AllXsd value

2020-03-01 07:03发布

I got this from a Soap client request:

Exception: SoapFault exception: [soap:Client] Server was unable to read request. ---> There is an error in XML document (2, 273). ---> The string '2010-5-24' is not a valid AllXsd value. in /path/filinet.php:21 Stack trace: #0 [internal function]: SoapClient->__call('SubIdDetailsByO...', Array) #1 /path/filinet.php(21): SoapClient->SubIdDetailsByOfferId(Array) #2 {main}

Seems like I am sending an incorrect value, how do I format my value in an AllXsd in php?

Here is my code:

<?php       
$start = isset($_GET['start']) ? $_GET['start'] : date("Y-m-d");
$end = isset($_GET['end']) ? $_GET['end'] : date("Y-m-d");

//define parameter array
$param = array('userName'=>'user', 'password'=>'pass', 'startDate' => $start, 'endDate' => $end, 'promotionId' => '');

//Get wsdl path
$serverPath = "https://webservices.filinet.com/affiliate/reports.asmx?WSDL";

 //Declare Soap client
 $client = new SoapClient($serverPath);
 try {
        //make the call
        $result = $client->SubIdDetailsByOfferId($param);
        //If error found display error
        if(isset($fault))
        {
            echo "Error: ". $fault;
        }
        //If no error display response
        else
        {
            //Used to display raw XML in the Web Browser
            header("Content-Type: text/xml;");
            //SubIdDetailsResult = XML results
            echo $result->SubIdDetailsByOfferIdResult;
        }
    }
    catch(SoapFault $ex) {
        echo "<b>Exception:</b> ". $ex;
    }
unset($client);
?>

标签: php xml soap
5条回答
一夜七次
2楼-- · 2020-03-01 07:30

You need to use the ISO 8601 date format date('c', strtotime($my_date));

http://php.net/date

查看更多
迷人小祖宗
3楼-- · 2020-03-01 07:31

The problem is with the date format of either $start or $end. Instead of just grabbing the data from the query string with $_GET and sending it over, you need to do some integrity checking to make sure that the date matches the required format

2010-05-24T13:46:00

Instead of using date("Y-m-d") try using:

$startDate = date("Y-m-d") . 'T' . date("H:i:s");
查看更多
闹够了就滚
4楼-- · 2020-03-01 07:35

AllXsd values look something like this IIRC

2010-05-24T18:13:00

查看更多
兄弟一词,经得起流年.
5楼-- · 2020-03-01 07:38
// set the default timezone to use. Available since PHP 5.1
date_default_timezone_set('UTC');
// get the date
$startDate = date("Y-m-d") . 'T' . date("H:i:s");
查看更多
混吃等死
6楼-- · 2020-03-01 07:48

Cut to the chase and use

date('c');
查看更多
登录 后发表回答