January 2004 - Posts
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 ...:-)
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:
- use ToString() method of DateTime
DateTime.Now.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz");
- use ToString() method of SoapDateTime class:
System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDateTime.ToString(dt);
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;
.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...
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 ?
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.
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