List Info

Thread: .NET SOAP throwing "String was not recognized as a valid DateTime." error




.NET SOAP throwing "String was not recognized as a valid DateTime." error
user name
2006-12-13 23:10:50

I'm guessing it's choking on the milliseconds. But I don't know enough
about .NET implementations to provide a suggestion on a fix. There are
probably other folks on the list that do.

Best,
-Y!SM Monkey

y_trafficstrategies wrote:
> I am attempting to implement Yahoo's new EWS API and I've run into a
> roadblock. When .NET attempts to deserialize the SOAP message, it
> Throws-up on Date fields. I can successfully parses the specified date
> string using
>; System.Xml.Serialization.XmlSerializationReader.ToDateTime("2006-12-07T13:35:55.865-08:00").
> My computer's location is US_en and I have this entry in my app.config
> file
> <configuration>
> <system.web>
&gt; <globalization culture=&quot;en-US&quot; uiCulture="en-US" />
>;
> Here is the stack trace:
&gt; There is an error in XML document (1, 1148). --->
&gt; System.FormatException: String was not recognized as a valid DateTime.
> at System.DateTimeParse.ParseExactMultiple(String s, String[]
> formats, DateTimeFormatInfo dtfi, DateTimeStyles style, DateTime&amp; result)
&gt; at System.DateTime.ParseExact(String s, String[] formats,
> IFormatProvider provider, DateTimeStyles style)
&gt; at System.Xml.XmlConvert.ToDateTime(String s, String[] formats)
> at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String
> value, String[] formats)
> at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)
&gt; at
> System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value)
&gt; at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read1_Campaign(Boolean
> isNullable, Boolean checkType)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read4_CampaignResponse(Boolean
&gt; isNullable, Boolean checkType)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read77_updateCampaignResponse()
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.updateCampaignResponseSerializer.Deserialize(XmlSerializationReader
> reader)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, String encodingStyle, XmlDeserializationEvents events)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, XmlDeserializationEvents events)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
> message, WebResponse response, Stream responseStream, Boolean asyncCall)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters)
> at CampaignServiceService.updateCampaign(Campaign campaign, Boolean
&gt; updateAll)
>
> Here is the request SOAP XML:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
&gt; xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
&gt; xmlnssd="http://www.w3.org/2001/XMLSchema"&gt;
> <soap:Header>
> <accountID
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345</accountID>
&gt; <license
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345-678-910-111-12345abc</license>
&gt; <masterAccountID
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345</masterAccountID>
> <Security xmlns=&quot;http://schemas.xmlsoap.org/ws/2002/07/secext">
> <UsernameToken xmlns=&quot;">;
> <Username>username</Username>
> <Password>password</Password>
> </UsernameToken>;
> </Security>
&gt; </soap:Header>
> <soap:Body>
&gt; <updateCampaign xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <campaign>
>; <ID>1245</ID>
> <accountID>12345</accountID>
> <advancedMatchON&gt;true</advancedMatchON>
> <campaignOptimizationON>true</campaignOptimizationON&gt;
> <contentMatchON>;false</contentMatchON>
> <description>My first campaign&lt;/description>
&gt; <name&gt;Cessna<;/name>
> <sponsoredSearchON>true&lt;/sponsoredSearchON&gt;
> <status>On</status>
> </campaign>
&gt; <updateAll>false</updateAll>
> </updateCampaign&gt;
> </soap:Body>
&gt; </soap:Envelope>;
>
> And here is the response SOAP XML:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
&gt; xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">;
> <soap:Header>
> <yns:remainingQuota
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>998&lt;/yns:remainingQuota>
> <yns:commandGroup
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>Marketing</yns:commandGroup>
> <yns:timeTakenMillis
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>94&lt;/yns:timeTakenMillis>
> <yns:sid
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>sk1-sbxadservices-002.ysm.sk1.yahoo.com</yns:sid>
> <yns:stime xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>Mon Dec
> 11 09:27:42 PST 2006</yns:stime>;
> </soap:Header>
> <soap:Body>
&gt; <updateCampaignResponse xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <out xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <campaign>
>; <ID>1245</ID>
> <accountID>12345</accountID>
> <advancedMatchON&gt;true</advancedMatchON>
> <campaignOptimizationON>false</campaignOptimizationON>
> <contentMatchON>;false</contentMatchON>
> <createTimestamp&gt;2006-12-07T13:35:55.865-08:00</createTimestamp>
> <deleteTimestamp xsi:nil=&quot;true&quot; />
>; <description>My first campaign&lt;/description>
&gt; <endDate xsi:nil=&quot;true&quot; />
> <lastUpdateTimestamp>2006-12-11T09:27:42.895-08:00</lastUpdateTimestamp&gt;
> <name&gt;Cessna<;/name>
> <sponsoredSearchON>true&lt;/sponsoredSearchON&gt;
> <startDate>2006-12-07T00:00:00-08:00</startDate>
> <status>On</status>
> <watchON>false&lt;/watchON>
> </campaign>
&gt; <errors xsi:nil=&quot;true&quot; />
>; <operationSucceeded>true&lt;/operationSucceeded>
> </out&gt;
> </updateCampaignResponse>
> </soap:Body>&lt;/soap:Envelope>
>
> Any ideas?
&gt;
>
>
>
> Yahoo! Groups Links
>;
>
>

__._,_.___
.

__,_._,___
.NET SOAP throwing "String was not recognized as a valid DateTime." error
user name
2006-12-13 23:57:16

The only problems I’ve had in .NET (so far) regarding time was initializing the report request structure.  The problem involved the timezone and I got it to work using the following code:

_ReportRequest.startDate = eachDate.Year.ToString() + "-&quot; + eachDate.Month.ToString().PadLeft(2, &quot;0") + "-&quot; + eachDate.Day.ToString().PadLeft(2, ";0") + "T00:00:00-08:00"

_ReportRequest.startDateSpecified = True

_ReportRequest.endDate = _ReportRequest.startDate

_ReportRequest.endDateSpecified = True

 

I haven̵7;t tried deserializing a SOAP message since I am getting/setting Campaign fields directly accessing the API.  For the start and end date of a Campaign, I use System.DateTime.

 


From: yws-searchmarketingyahoogroups.com [mailto:yws-searchmarketingyahoogroups.com] On Behalf Of Yahoo! Search Marketing Monkey
Sent: Wednesday, December 13, 2006 3:11 PM
To: yws-searchmarketingyahoogroups.com
Subject: Re: [yws-searchmarketing] .NET SOAP throwing "String was not recognized as a valid DateTime.&quot; error

 

I'm guessing it's choking on the milliseconds. But I don't know enough
about .NET implementations to provide a suggestion on a fix. There are
probably other folks on the list that do.

Best,
-Y!SM Monkey

y_trafficstrategies wrote:
&gt; I am attempting to implement Yahoo's new EWS API and I've run into a
> roadblock. When .NET attempts to deserialize the SOAP message, it
> Throws-up on Date fields. I can successfully parses the specified date
> string using
>; System.Xml.Serialization.XmlSerializationReader.ToDateTime(&quot;2006-12-07T13:35:55.865-08:00").
> My computer's location is US_en and I have this entry in my app.config
> file
> <configuration>
> <system.web>
&gt; <globalization culture=&quot;en-US&quot; uiCulture="en-US" /&gt;
>
> Here is the stack trace:
&gt; There is an error in XML document (1, 1148). --->
&gt; System.FormatException: String was not recognized as a valid DateTime.
> at System.DateTimeParse.ParseExactMultiple(String s, String[]
> formats, DateTimeFormatInfo dtfi, DateTimeStyles style, DateTime&amp; result)
> at System.DateTime.ParseExact(String s, String[] formats,
> IFormatProvider provider, DateTimeStyles style)
&gt; at System.Xml.XmlConvert.ToDateTime(String s, String[] formats)
> at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String
> value, String[] formats)
> at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)
&gt; at
> System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read1_Campaign(Boolean
> isNullable, Boolean checkType)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read4_CampaignResponse(Boolean
&gt; isNullable, Boolean checkType)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCampaignServiceService.Read77_updateCampaignResponse()
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.updateCampaignResponseSerializer.Deserialize(XmlSerializationReader
> reader)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, String encodingStyle, XmlDeserializationEvents events)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader, XmlDeserializationEvents events)
&gt; at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
> xmlReader)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
> message, WebResponse response, Stream responseStream, Boolean asyncCall)
> at
> System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters)
> at CampaignServiceService.updateCampaign(Campaign campaign, Boolean
&gt; updateAll)
>
> Here is the request SOAP XML:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
&gt; xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
&gt; xmlnssd="http://www.w3.org/2001/XMLSchema"&gt;
> <soap:Header>
> <accountID
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345</accountID>
&gt; <license
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345-678-910-111-12345abc</license>
&gt; <masterAccountID
> xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>12345</masterAccountID>
> <Security xmlns=&quot;http://schemas.xmlsoap.org/ws/2002/07/secext">
> <UsernameToken xmlns=&quot;">;
> <Username>username</Username>
> <Password>password</Password>
> </UsernameToken>;
> </Security>
&gt; </soap:Header>
> <soap:Body>
&gt; <updateCampaign xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <campaign>
>; <ID>1245</ID>
> <accountID>12345</accountID>
> <advancedMatchON&gt;true</advancedMatchON>
> <campaignOptimizationON>true</campaignOptimizationON&gt;
> <contentMatchON>;false</contentMatchON>
> <description>My first campaign&lt;/description>
&gt; <name&gt;Cessna<;/name>
> <sponsoredSearchON>true&lt;/sponsoredSearchON&gt;
> <status>On</status>
> </campaign>
&gt; <updateAll>false</updateAll>
> </updateCampaign&gt;
> </soap:Body>
&gt; </soap:Envelope>;
>
> And here is the response SOAP XML:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
&gt; xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">;
> <soap:Header>
> <yns:remainingQuota
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>998&lt;/yns:remainingQuota>
> <yns:commandGroup
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>Marketing</yns:commandGroup>
> <yns:timeTakenMillis
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>94&lt;/yns:timeTakenMillis>
> <yns:sid
> xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>sk1-sbxadservices-002.ysm.sk1.yahoo.com</yns:sid>
> <yns:stime xmlns:yns="http://marketing.ews.yahooapis.com/V1&quot;>Mon Dec
> 11 09:27:42 PST 2006</yns:stime>;
> </soap:Header>
> <soap:Body>
&gt; <updateCampaignResponse xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <out xmlns=&quot;http://marketing.ews.yahooapis.com/V1&quot;>
&gt; <campaign>
>; <ID>1245</ID>
> <accountID>12345</accountID>
> <advancedMatchON&gt;true</advancedMatchON>
> <campaignOptimizationON>false</campaignOptimizationON>
> <contentMatchON>;false</contentMatchON>
> <createTimestamp&gt;2006-12-07T13:35:55.865-08:00</createTimestamp>
> <deleteTimestamp xsi:nil=&quot;true&quot; />
>; <description>My first campaign&lt;/description>
&gt; <endDate xsi:nil=&quot;true&quot; />
> <lastUpdateTimestamp>2006-12-11T09:27:42.895-08:00</lastUpdateTimestamp&gt;
> <name&gt;Cessna<;/name>
> <sponsoredSearchON>true&lt;/sponsoredSearchON&gt;
> <startDate>2006-12-07T00:00:00-08:00</startDate>
> <status>On</status>
> <watchON>false&lt;/watchON>
> </campaign>
&gt; <errors xsi:nil=&quot;true&quot; />
>; <operationSucceeded>true&lt;/operationSucceeded>
> </out&gt;
> </updateCampaignResponse>
> </soap:Body>&lt;/soap:Envelope>
>
> Any ideas?
&gt;
>
>
>
> Yahoo! Groups Links
>;
>
>

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )