php 不是有效的 AllXsd 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2899332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:03:25  来源:igfitidea点击:

not a valid AllXsd value

phpxmlsoap

提问by Loreto Gabawa Jr.

I got this from a Soap client request:

我从 Soap 客户端请求中得到了这个:

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}

异常:SoapFault 异常:[soap:Client] 服务器无法读取请求。---> XML 文档中存在错误 (2, 273)。---> 字符串“2010-5-24”不是有效的 AllXsd 值。在 /path/filinet.php:21 堆栈跟踪:#0 [内部函数]:SoapClient->__call('SubIdDetailsByO...', Array) #1 /path/filinet.php(21):SoapClient->SubIdDetailsByOfferId(数组)#2 {main}

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

好像我发送的值不正确,如何在 php 的 AllXsd 中格式化我的值?

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);
?>

回答by ólafur Waage

AllXsd values look something like this IIRC

AllXsd 值看起来像这个 IIRC

2010-05-24T18:13:00

2010-05-24T18:13:00

回答by dabaR

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

您需要使用 ISO 8601 日期格式 date('c', strtotime($my_date));

http://php.net/date

http://php.net/日期

回答by Harry Slaughter

Cut to the chase and use

切入正题并使用

date('c');

回答by Dejan

// 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");

回答by Jarrod Nettles

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

问题在于 $start 或 $end 的日期格式。与其只是使用 $_GET 从查询字符串中获取数据并将其发送过来,您还需要进行一些完整性检查以确保日期与所需的格式匹配

2010-05-24T13:46:00

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

而不是使用 date("Ymd") 尝试使用:

$startDate = date("Y-m-d") . 'T' . date("H:i:s");