Hi all, In an ASP.NET web service, is there a way I can centralize processing of SOAP Headers? Currently I need to nput my header logic into each webmethod - is there an event, mechanism, extension, etc I can hook into to do all my processing before the webmethod is executed? Thanks! -- spamhoneypot@rogers.com (Do not e-mail)
I'm writing a webservice where all of the data elements should have a minOccurs = 0. I'm using VS2005. This is fine for most of my elements, but all of my datetime elements automatically receive a minOccurs = 1 in the auto generated WSDL file. For example , if these were some fields in my Web Service code: public string category; public string condition; public datetime dateOfPurchase; My WSDL file turns out like this: <s:element minOccurs="0" maxOccurs="1" name="category" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="condition" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="dateOfPurchase" type="s:dateTime" /> Any thoughts? I'm working on another project where I've been given a WSDL file generated from VS2008 - and this WSDL does have dateTimes with minOccurs = 0. Is this a VS2005 limitation? Or am I doing something wrong? Any thoughts? Thanks so much! ami
"ads" wrote in message news:9089ef24-76be-477a-b56a-1dd202a0ebb3@k13g2000hse.googlegroups.com... > I'm writing a webservice where all of the data elements should have a > minOccurs = 0. I'm using VS2005. > > This is fine for most of my elements, but all of my datetime elements > automatically receive a minOccurs = 1 in the auto generated WSDL > file. What value would you want assigned to your DateTime parameter if it isn't supplied in the SOAP? There is no really good answer to that, as DateTime.MinValue is a valid DateTime. Instead, try using DateTime? (System.Nullable<DateTime>) for the parameter type and see if that changes the WSDL that is generated. Finally, if you ever get into a situation where the generated WSDL doesn't match what you want, remember that you don't have to allow .NET to generate the WSDL. You can create your own WSDL instead. -- -------------------------------------------------------------------------------- John Saunders | MVP - Windows Server System - Connected System Developer
Try using the "Specified" attribute: If you have a public property called dateOfPurchase "ads" wrote: > I'm writing a webservice where all of the data elements should have a > minOccurs = 0. I'm using VS2005. > > This is fine for most of my elements, but all of my datetime elements > automatically receive a minOccurs = 1 in the auto generated WSDL > file. > > For example , if these were some fields in my Web Service code: > public string category; > > public string condition; > > public datetime dateOfPurchase; > > My WSDL file turns out like this: > <s:element minOccurs="0" maxOccurs="1" name="category" > type="s:string" /> > <s:element minOccurs="0" maxOccurs="1" name="condition" > type="s:string" /> > <s:element minOccurs="1" maxOccurs="1" name="dateOfPurchase" > type="s:dateTime" /> > > Any thoughts? I'm working on another project where I've been given a > WSDL file generated from VS2008 - and this WSDL does have dateTimes > with minOccurs = 0. Is this a VS2005 limitation? Or am I doing > something wrong? > > Any thoughts? > Thanks so much! > > ami >