Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 -

XML
<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

XML
<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

1 solution

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


Refer C# DateTime Format[^]

Hope this helps
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900