Click here to Skip to main content
12,396,047 members (64,017 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET WCF WC ASMX WebService

I am trying to post a SOAP request on third-party web service.

I have added web service as a reference in my Visual Studio project.

Generated WSDL has attributes CheckIn/CheckOut, which of type Date.

Web Services accept only following form of request -

<ns:HotelProduct City="WAS" CheckInDate="2012-11-25" CheckOutDate="2012-11-30"> 

But since CheckIn/CheckOut attribute are defined as Date in WSDL, the request becomes

<ns:HotelProduct City="WAS" CheckInDate="2012-11-25 12:00:00 AM" CheckOutDate="2012-11-30 12:00:00AM">

TimeStamp is appended while building SOAP message.

I don't have any control over web service since it's from third party.

I have tried using different DateTime formats, making change in generated WSDL,, but no luck.

How to cope with this issue.
Any alternative would be much helpful.
Posted 19-Nov-12 3:35am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try formating the date like

Refer C# DateTime Format[^]

Hope this helps
vikram_shinde 20-Nov-12 8:39am
I tried by doing same way but still it's appending timestamp.
__TR__ 20-Nov-12 8:45am
Can't think of another way. Are you passing the value as a string or Datetime?
vikram_shinde 20-Nov-12 10:51am
As a string. But in WSDL it has type restriction as Date so whatever you assign to it , it becomes CheckInDate="2012-11-25 12:00:00 AM".

After applying datetime formatting I am getting result as CheckInDate="2012-11-25"
but after assigning this formatted result it appends time stamp.

I have done like -

WSProxy.HotelSearchRequestCT hs = new HotelSearchRequestCT();
hs.City = "WAS";
DateTime d = DateTime.Parse("2012-11-25");
hs.CheckInDate = d.ToString("yyyy-MM-dd"); // CheckInDate = 2012-11-25 12:00:00 AM

__TR__ 20-Nov-12 11:19am
Try assigning the value "2012-11-25" directly and see if the time gets appended
hs.CheckInDate = "2012-11-25";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100