2010-05-24 78 views
11

我得到这个从SOAP客户端请求:不是有效的AllXsd值

异常:异常的SOAPFault: [肥皂:客户端]服务器无法 读请求。 --->在XML文档(2,273)中有一个错误 。 ---> 字符串'2010-5-24'不是有效的 AllXsd值。在/path/filinet.php:21 堆栈跟踪:#0 [内部函数]: SoapClient - > __ call('SubIdDetailsByO ...', Array)#1 /path/filinet.php(21): SoapClient - > SubIdDetailsByOfferId(阵列)#2 {}主要

好像我发送一个不正确的值,我如何在PHP格式化的AllXsd我的价值?

这里是我的代码:

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

回答

25

AllXsd值是这个样子IIRC

2010-05-24T18:13:00

0

问题是与日期$ start或$ end的格式。而不是从查询字符串就可以抓取的数据与$ _GET和发送过来,你需要做一些完整性检查,以确保日期匹配要求的格式

2010-05-24T13:46:00 

而不是使用日期(“年月日”的)尝试使用:

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

遗憾,它并没有奏效。 – 2010-05-24 20:09:43

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

切入正题,并使用

date('c'); 
相关问题