Pierre Greborio.NET

Talking about .NET world

January 2004 - Posts

Data extension for SQL Server Reporting Services
I implemented a new data extension for SQL Server Reporting Services that loads an image given an URL (it accept parameters too) for a project I am working on. Since there isn't reasons to keep it private, I decided to share the code on GotDotNet in order to have feedbacks and suggestions ...:-)
Priting DateTime following ISO 8601 spec.

With web services the dateTime type is formatted as point 3.2.7 of the XML schema datatype specification. When you use ASP.NET to develop web services this formatting is done by the XmlSerializer and then you don't have to care about it. But, if you work manually you have two ways to do this job:

  1. use ToString() method of DateTime

    DateTime.Now.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz");

  2. use ToString() method of SoapDateTime class:

    System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime.ToString(dt);

Posted: Jan 19 2004, 01:41 PM by PierreG | with 1 comment(s)
Filed under:
Default value for elements on the WSDL

Sometimes you need to define a default value for an element into the WSDL type section. Consider the following XML snippet code:

<s:element minOccurs="0" maxOccurs="1" default="100" name="MaxLimit" type="s:double" />

to get the default value automatically you can set it by decorating the property (MaxLimit) with the attribute System.ComponentModel.DefaultValueAttribute as following:

[System.ComponentModel.DefaultValue(100)]
public double MaxLimit;

Posted: Jan 16 2004, 02:51 PM by PierreG | with no comments
Filed under:
WSDL by attributes
.NET attributes are a very powerful mechanism. I use them every day to manipulate the XML stream during an object serialization and with web services. Sometimes, specially for web services, it's difficult to find the right attribute to use in order to customize the generated WSDL. The following article helps in finding these attributes...
Posted: Jan 12 2004, 10:56 PM by PierreG | with no comments
Filed under:
Started to play with Indigo
Yesterday night I started to play with Indigo. It seems a really new way developping distributed applications. Are web services and remoting reached the maturity ?
Posted: Jan 12 2004, 02:22 PM by PierreG | with 2 comment(s)
Filed under:
XML Serialization and enums

Well, I was looking what ASP.NET web services generates when I have an enum parameter. Consider the following type:

public enum MyEnum : int
{
  EnumValue1 = 0,
  EnumValue2 = 2
}

I'm expecting something like

<xs:simpleType name="MyEnum">
 <xs:restriction base="xs:int">
  <xs:enumeration value="0" />
  <xs:enumeration value="2" />
 </xs:restriction>
</xs:simpleType>

But the xsd produces:

<xs:simpleType name="MyEnum">
 <xs:restriction base="xs:string">
  <xs:enumeration value="EnumValue1" />
  <xs:enumeration value="EnumValue2" />
 </xs:restriction>
</xs:simpleType>

Even if I'm decorating the enum values with System.Xml.Serialization.XmlEnumAttribute I can't get back an XML schema with a restriction of int instead of string. Why DataType of XmlElementAttribute doesn't work from primitives ? I don't know, but today I have to edit the WSDL manually.

 

Posted: Jan 09 2004, 06:04 PM by PierreG | with 2 comment(s)
Filed under:
Here I am...
Ok, I'm back from a very busy time. I was involved on my new startup company with two big projects and the book writing I'm co-autoring. Now, I can see the light at the end of the tunnel....
More Posts