Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

Problems marshaling DateTime parameters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Wone - 01 Feb 2005 03:20 GMT
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) ?
Peter Wone - 01 Feb 2005 03:49 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.