468,507 Members | 1,518 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,507 developers. It's quick & easy.

Problems marshaling DateTime parameters

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) ?
Nov 23 '05 #1
3 2672
This is where it's unhappy:

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost/empire/LogUsage",
RequestNamespace="http://localhost/empire",
ResponseNamespace="http://localhost/empire",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.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?
Nov 23 '05 #2
AC
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.

"Peter Wone" <pe****@wamoz.com> сообщил/сообщила в новостях следующее:
news:OP**************@TK2MSFTNGP14.phx.gbl...
This is where it's unhappy:

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost
/empire/LogUsage", RequestNamespace="http://localhost/empire",
ResponseNamespace="http://localhost/empire",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.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?

Nov 23 '05 #3
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.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Peter Wone" <pe****@wamoz.com> wrote in message
news:OP**************@TK2MSFTNGP14.phx.gbl...
This is where it's unhappy:

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://localhost
/empire/LogUsage", RequestNamespace="http://localhost/empire",
ResponseNamespace="http://localhost/empire",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.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?


Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Stephen Gennard | last post: by
4 posts views Thread by John J. Hughes II | last post: by
2 posts views Thread by Don Kim | last post: by
reply views Thread by Tim::.. | last post: by
1 post views Thread by Bill Medland | last post: by
6 posts views Thread by rn5a | last post: by
24 posts views Thread by rn5a | last post: by
reply views Thread by SAL | last post: by
1 post views Thread by =?ISO-8859-1?Q?Jo=E3o_Maia?= | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.