One of my webservices has a parameter of type System.DateTime. It compiles
ok but at runtime I get this exception:
An unhandled exception of type 'System.Web.Services.Protocols.SoapException'
occurred in system.web.services.dll
Additional information: Server was unable to process request. --> Invalid
cast from System.DateTime to System.Byte[].
Can anyone tell me how to deal with this issue?
Should I box the parameters into an object derived from MarshalByValue (or
whatever it's called) ?
This is where it's unhappy:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/empire/LogUsage",
RequestNamespace="http://localhost/empire",
ResponseNamespace="http://localhost/empire",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void LogUsage(System.Guid SiteID, System.DateTime Timestamp, int
PeakConcurrentSessions) {
object[] oa;
oa = new object[] {
SiteID,
Timestamp,
PeakConcurrentSessions};
this.Invoke("LogUsage",oa);
}
I broke this code (generated by importing a web reference) into three
statements so I could see which part gave it trouble.
oa = new object[] {
SiteID,
Timestamp,
PeakConcurrentSessions};
is what it doesn't like. This statement produces the exception "Invalid cast
from System.DateTime to System.Byte[]."
Any thoughts, people?
AC - 06 Feb 2005 00:07 GMT
Hello,
Have not you try to create a service with only one this method? Does it
work? And what is "this.Invoke("LogUsage",oa);"? May be a problem in it.
> This is where it's unhappy:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost
/empire/LogUsage",
> RequestNamespace="http://localhost/empire",
> ResponseNamespace="http://localhost/empire",
[quoted text clipped - 22 lines]
>
> Any thoughts, people?
William Stacey [MVP] - 06 Feb 2005 01:27 GMT
Curious. Why are you using "Invoke" anyway? I suspect the method signature
on that method expects a byte[] in the second parm - not a DataTime.

Signature
William Stacey, MVP
http://mvp.support.microsoft.com
> This is where it's unhappy:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost
/empire/LogUsage",
> RequestNamespace="http://localhost/empire",
> ResponseNamespace="http://localhost/empire",
[quoted text clipped - 22 lines]
>
> Any thoughts, people?