c# - Date Format Issue with Web service -
i have web service input parameters. relevant xsd in wsdl below
when added wsdl service reference in visual studio, generated class corresponding fields assystem.datetime
. below example of field in reference class added wsdl
private system.nullable<system.datetime> startdatefield;
my binding service create client custombinding below
protected custombinding getcustombinding() { var custombinding = new custombinding() { name = "custombinding" }; custombinding.elements.add(new textmessageencodingbindingelement() { messageversion = messageversion.soap11 }); var securitybindingelement = securitybindingelement.createusernameovertransportbindingelement(); securitybindingelement.allowinsecuretransport = true; securitybindingelement.enableunsecuredresponse = true; securitybindingelement.includetimestamp = false; custombinding.elements.add(securitybindingelement); custombinding.elements.add(new httptransportbindingelement()); return custombinding; }
my c# code assign input
myobject.input.enddate = convert.todatetime(enddate);
after assigning input values, called web method see in fiddler
date parameters missing in request.
i tried test in soapui. looks service expects date in format yyyy-mm-dd
though type of date. webservice returns data when supply date in format yyyy-mm-dd
.
i'm not sure if expected date format web service. obviously, can't send in format yyyy-mm-dd .net generated reference class has datetime
not string
data type.
i tried forcibly set specified
true
myobject.input.enddate = convert.todatetime(enddate).date; myobject.input.enddatespecified = true;
i got below error:
a value being set exceeded maximum allowable field length.
now, suspect web service expects date .net trying send datetime might extending length
it looks last code worked error due field.
myobject.input.enddate = convert.todatetime(enddate).date; myobject.input.enddatespecified = true;
Comments
Post a Comment