473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2950
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
4
by: John J. Hughes II | last post by:
I have several functions that save the time when they did certain tasks to an SQL table. This was working fine as far as I could tell but I now have systems that are updating thousands of records...
2
by: Don Kim | last post by:
Hi, I'm trying to port the IGo Portal on the gotdotnet site from vb.net to c#. I'm having problems with the following: public DataSet GetAnnouncements(int moduleId) { // Create Instance...
0
by: Tim::.. | last post by:
Can someone please help! I'm trying to write an insert statement for a complex datagrid! The database consists of the following data structure! ..tblContent PageID PK ModDate Description...
1
by: Bill Medland | last post by:
I am trying to do some P/Invoke custom marshaling and am looking for a little help on custom marshaling a value type. I am working based on Kate Gregory's "Arranging Custom Marshaling With...
6
by: rn5a | last post by:
I am inserting records in a MS-Access database table. The data type of one of the columns named *OrderDate* in the DB table is Date/Time. This is the SQL query I am using to insert the records in...
24
by: rn5a | last post by:
The date in my local machine is set to the dd/MM/yyyy format. When I insert a date in a MS-Access DB table, it gets populated in the above format. For e.g. if the date is, say, 8th March 2007, it...
0
by: SAL | last post by:
I'm curious if anyone else is having this problem. If I let the Dataset designer generate update commands for me, I don't seem to be able to get them to work without an exception getting thrown,...
1
by: =?ISO-8859-1?Q?Jo=E3o_Maia?= | last post by:
Hello there, I'm using Cache VaryByParam on a page and I'm not getting the behaviour I expected. Here's what happens: - I have page a.aspx declared with Cache VaryByParam="name" - Page a.aspx...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.