By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,397 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,397 IT Pros & Developers. It's quick & easy.

Php Client / .Net Webservice / Datetime problem - Urgent!

P: n/a
Problem in sending datatime format to the .net webservice from php.
description follows.
I've created a .net webservice.

..Net Webservice:

<WebMethod()> _
Public Function HelloDate(ByVal mydate As DateTime) As String
mystr = mydate.ToString("dddd") 'Which displays day
Return mystr
End Function

Php Client:

$parameters['mydate'] = "12 June 2005;
$soap_proxy = $s->getProxy();
$result = $soap_proxy->HelloDate($parameters);
if (!$err = $soap_proxy->getError()){
echo($result["HelloDateResult"]);
}else{
echo 'Error: ' . $err . "\n";
}

When i tried to communicate the .net webservice. It shows following
error.

"Error: soap:Client: Server was unable to read request. --> There is an
error in XML document (1, 460). --> String was not recognized as a
valid DateTime. "

How to send datetime format data to the webservice from php. For
String, Numbers above code works well.

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 3 Jun 2005 10:16:12 -0700, ra*******@gmail.com wrote:
Problem in sending datatime format to the .net webservice from php.
description follows.

I've created a .net webservice.

.Net Webservice:

<WebMethod()> _
Public Function HelloDate(ByVal mydate As DateTime) As String
mystr = mydate.ToString("dddd") 'Which displays day
Return mystr
End Function

Php Client:

$parameters['mydate'] = "12 June 2005;
$soap_proxy = $s->getProxy();
$result = $soap_proxy->HelloDate($parameters);
if (!$err = $soap_proxy->getError()){
echo($result["HelloDateResult"]);
}else{
echo 'Error: ' . $err . "\n";
}

When i tried to communicate the .net webservice. It shows following
error.

"Error: soap:Client: Server was unable to read request. --> There is an
error in XML document (1, 460). --> String was not recognized as a
valid DateTime. "

How to send datetime format data to the webservice from php. For
String, Numbers above code works well.


Having never used webservices this may be the wrong track, but I'd look at:

http://www.w3.org/TR/xmlschema-2/#dateTime

"12 June 2005" doesn't look like the sort of thing a portable format would
accept. 2005-06-12T00:00:00 looks more like it.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

P: n/a
NC
ra*******@gmail.com wrote:

I've created a .net webservice.

.Net Webservice:

<WebMethod()> _
Public Function HelloDate(ByVal mydate As DateTime) As String
mystr = mydate.ToString("dddd") 'Which displays day
Return mystr
End Function
Bad idea. Web services exchange data in text format and should
be platform-independent. Consequently, the only argument type
(and the only return type) allowed for a Web service method
should be String.

Rewrite your method:

<WebMethod()> _
Public Function HelloDate(ByVal myinput As String) As String
if IsDate(myinput) Then
mydate = CDate(myinput)
mystr = mydate.ToString("dddd")
Return mystr
Else
' handle the error; the supplied argument
' cannot be converted to date
End If
End Function
How to send datetime format data to the webservice from php.


DateTime is a .NET-specific structure. You should avoid having
to send to (or receive from) a Web service anything that is not
string.

Cheers,
NC

Jul 17 '05 #3

P: n/a
On 3 Jun 2005 10:16:12 -0700, ra*******@gmail.com wrote:
$parameters['mydate'] = "12 June 2005;
$result = $soap_proxy->HelloDate($parameters);


In addition to the remarks made by Andy and NC, try passing the actual
string, not an array.

$result = $soap_proxy->HelloDate($parameters['mydate']);
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #4

P: n/a
Thanks Andy,

It wroks well. thanks a lot..

$parameters['mydate'] = "2005-06-04T00:00:00";
$soap_proxy = $s->getProxy();
$result = $soap_proxy->HelloDate($parameters);
if (!$err = $soap_proxy->getError()){
echo($result["HelloDateResult"]);
}
else{
echo 'Error: ' . $err . "\n";
}
Thanks for your effort.

Thanks NC, Ewoud Dronkert.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.