Click here to Skip to main content
12,948,566 members (61,347 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi,

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
 
good
Please Sign up or sign in to vote.

Solution 1

Try formating the date like
DateTime.Now.ToString("yyyy-MM-dd");


Refer C# DateTime Format[^]

Hope this helps
  Permalink  
Comments
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
OriginalGriff 5,419
CHill60 3,275
Maciej Los 2,778
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web01 | 2.8.170524.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2017
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