Simon Fell > Its just code > July 2004

Saturday, July 31, 2004

I just posted a sample showing how to do DIME and SwA attachments in PocketSOAP using eVC, That means there's now attachment samples in VB, eVB, eVC and C#.

Friday, July 30, 2004

Just got back from Scott's Web Services talk at Bay.NET, I enjoyed it, I think he did a great job on the zen of web services, and pulled off the trick of making a 2 hour talk on angle brackets both entertaining and informative. Pity he had to run for his flight, would of like to had the chance to talk about some more advanced issues around doing real world stuff with today's tools.

Wednesday, July 28, 2004

Russ has a demo app of making an AtomAPI post from a J2ME phone. I got it installed and running on my Nokia 3650 without any trouble, and managed to capture the request it sends.

POST /atom HTTP/1.0
content-type: */*
user-agent: AtomME
X-WSSE: UsernameToken Username="Sfell", PasswordDigest="xCU+TMHlemjeNRlm8AXOaG3rXc4=", Created="2004-07-27T21:57:14Z", Nonce="1221470753"
Content-Length: 131
accept: */*, text/x-vcard, text/x-vcalendar, image/vnd.wap.wbmp, image/gif
Via: WTP/1.1 proatlwap04 (Nokia WAP Gateway 4.0/ECD10/4.0.64), HTTP/1.1 proatledmpxy01[0540000C] (Traffic-Server/5.1.3-55590 [uScM])
X-Network-info: GPRS,unsecured
X-Nokia-CONNECTION_MODE: CMODE
X-Nokia-BEARER: GPRS
X-Nokia-gateway-id: NWG/4.0/Build64
hname1: hvalue1
hname2: 
hname3: hvalue3
Client-ip: 10.184.24.199
Connection: keep-alive
Host: soap.4s4c.com

<?xml version="1.0"?><entry xmlns="http://purl.org/atom/ns#"><title>Testing AtomME</title><content>Testing 1,2,3!</content></entry>

I didn't see a chunked POST that Russ mentions (which is good, HTTP 1.0 doesn't do chunking), but on the subject of doing chunked POSTs, last time I looked at this, support for it on the server side seemed really thin on the ground, this was a while back, don't know if things are better now, but this might be an issue. The content-type doesn't look right, but that should be easy to fix, right ?

Anyway this is cool stuff, I brought the 3650 with the intent of doing some programming stuff on it, but have never gotten around to it, hopefully this'll spur me on to get around to looking at it.

Tuesday, July 27, 2004

Now available, contains PocketHTTP 1.2.1, dependencies are statically linked, various bug fixes and performance improvements. Likely to be the last beta release for v1.5

Monday, July 26, 2004

RSS Scaling continues to be the topic de jour, Jeremy Zawodny being the most recent to mention it. It seems to me that if the centralized aggregators opened up their cache of RSS data as an HTTP proxy, that could easily solve it, and has the advantage of being deployable with the bulk of today's desktop aggregators which mostly already include support for HTTP proxies.

Friday, July 23, 2004

Yasser responds to my ealier post on Nullable and XxxSpecified in .NET 2.0.

He's correct in that xsi:nil='true' and a element not sent at all are 2 different things are you need to be able to control both, but this doesn't jive too well with the current implementation in the 2.0 beta. Here's an example.

A sample WSDL doc defines a complexType that has nilable='true' and minOccurs='0' for a string element and a boolean element.

<xsd:complexType name="address">
  <xsd:sequence>
    <xsd:element name="City" type="xsd:string" nillable='true' minOccurs='0'/>
    <xsd:element name="State" type="xsd:string" nillable='true' minOccurs='0'/>
    <xsd:element name="IsVerified" type="xsd:boolean" nillable='true' minOccurs='0'/>
  </xsd:sequence>
</xsd:complexType>

I'll run this through wsdl.exe, lets see what we get, the generated struct for address has

[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://samples.pocketsoap.com/dn2/")]
public class address {
    
    private string cityField;
    
    private string stateField;
    
    private System.Nullable<bool> isVerifiedField;
    
    private bool isVerifiedFieldSpecified;
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public string City {
        get {
            return this.cityField;
        }
        set {
            this.cityField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public string State {
        get {
            return this.stateField;
        }
        set {
            this.stateField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Nullable<bool> IsVerified {
        get {
            return this.isVerifiedField;
        }
        set {
            this.isVerifiedField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool IsVerifiedSpecified {
        get {
            return this.isVerifiedFieldSpecified;
        }
        set {
            this.isVerifiedFieldSpecified = value;
        }
    }
}

First thing to note is that only the boolean got an additional Specified flag, what about the strings ?. Lets set some different values on the instance and see what it sends over the wire, first the test code, straightforward enough.

class dn2
{
	public static void Main(string [] args)
	{
		dn2PortType svc = new dn2PortType();
		svc.Url = "http://coldcut:8081/service.asmx";
		
		Console.WriteLine("no values specified");
		address a = new address();
		svc.sendAddress(a);

		Console.WriteLine("a string value set");
		a = new address();
		a.City = "San Francisco";
		svc.sendAddress(a);

		Console.WriteLine("a boolean value set");
		a = new address();
		a.IsVerified = true;
		svc.sendAddress(a);

		Console.WriteLine("a boolean value & Specified set");
		a = new address();
		a.IsVerified = true;
		a.IsVerifiedSpecified = true;
		svc.sendAddress(a);

		Console.WriteLine("a boolean specified set, no value");
		a = new address();
		a.IsVerifiedSpecified = true;
		svc.sendAddress(a);
	}
}

And now the generated requests (I'll leave all the envelope/body goo off, and just show how the address was serialized)

<Address><City xsi:nil="true" /><State xsi:nil="true" /></Address>

<Address><City>San Francisco</City><State xsi:nil="true" /></Address>

<Address><City xsi:nil="true" /><State xsi:nil="true" /></Address>

<Address><City xsi:nil="true" /><State xsi:nil="true" /><IsVerified>true</IsVerified></Address>

<Address><City xsi:nil="true" /><State xsi:nil="true" /><IsVerified xsi:nil="true" /></Address>

Someone on the ASMX team needs to take a step back and have a fresh look at this, for the Specified flags to be useful there really need to be 2 things,

  • They're needed on all elements that have a minOccurs='0', why do I get it on boolean elements, and not string elements ?
  • Look carefully at the 3rd example, I explicitly set a value for the boolean, but it still didn't get serialized, this is totally lame behavior and my major complaint. There's a property setter right there, if I've set a value for the IsVerified property then I want to send it!, have the IsVerified property setter also set the IsVerifiedSpecified flag as well.
  • Not shown above, but there's a bug with System.Nullable and xsd:date, looks like the DataType attribute and System.Nullable don't play nicely together.

Friday, July 23, 2004

PocketXML-RPC v1.2 is now available, this has been updated to PocketHTTP v1.2.1, expat is now statically linked fixed a problem where a different version of expat is already loaded into the process, and there are now binaries for the PocketPC 2002 emulator.

Saturday, July 17, 2004

A minor update, PocketHTTP v1.2.1 is now available, this has the following changes.

  • Dependencies are all now statically linked, PocketHTTP now consists of a single DLL, PocketHTTP.dll
  • Upgraded to zlib 1.2.1, see the zlib website for details on the speed and memory improvements.
  • The IHttpResponse.String method will now correctly transcode UTF-8 & UTF-16 encoded responses.
  • The installer has been updated to NSIS 2.0

Tuesday, July 13, 2004

My subscriber service for weblogs.com has been ticking away in the background, as i was moving to a new box I took a poke around the DB, there's over 100,000 active weblogs (updated within the last 28 days), and its received 3.5 million pings from blo.gs in the last 6 months.

If I had any time, I'd build a WS-Events version of the subscriber interface.

Thursday, July 8, 2004

Tomas is asking about which way to go with binary attachments. My $0.02 is that SwA and DIME are eventually going to be dead ends, if you're controlling both ends, then yeah go ahead with one and switch later. The more likely case is that your service will be called by different people, then you're going to have a hard time yanking SwA or DIME support later when you want to, you're better off taking the hit in the short term and sticking with inlined base64 content.

Wednesday, July 7, 2004

Was looking throught the bug reports and suggestions over on thew new msdn product feedback center, had to laugh when i saw i suggestion that pointed to PocketSOAP as the way to do it :)

Wednesday, July 7, 2004

Oppps, looks like profile.microsoft.com is running with a self signed cert.

Wednesday, July 7, 2004

Turns out it doesn't matter what it generates, cause it doesn't run. :(

Unhandled Exception: System.InvalidOperationException: Method SforceService.create can not be reflected. 
	---> System.InvalidOperationException: There was an error reflecting 'sObjects'. 
	---> System.InvalidOperationException: There was an error reflecting type 'sforce.sObject'. 
	---> System.InvalidOperationException: There was an error reflecting type 'sforce.Task'. 
	---> System.InvalidOperationException: There was an error reflecting property 'ActivityDate'. 
	---> System.InvalidOperationException: There was an error reflecting type 'System.Nullable`1[System.DateTime]'.
 	--->System.InvalidOperationException: 'date' is an invalid value for the XmlElementAttribute.DataType property. 
	The property may only be specified for primitive types.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, 
	ImportContext context, String dataType, Boolean repeats, Boolean openModel)

ActivitiyDate is specified as

<s:element minOccurs="0" name="ActivityDate" nillable="true" type="s:date" />

Wednesday, July 7, 2004

Just got the VS C# Express beta 1 installed so I can checkout what improvements to wsdl.exe they've been. I've been hoping for a long time that this release would fix the hokeyness around the fooSpecified fields on generated classes, have looked at what it generates I can't believe how they got so close yet decided not to fix it, are we to be saddled with every dodgy .NET 1.0 decision until Indigo ships when we get to start over again ?

Here's an example, for an complex type that contains an element defined as

<s:element minOccurs="0" name="SystemModstamp" nillable="true" type="s:dateTime" />
it generates this property (yay, properties at last, at least if you run the command line version, for some reason VS.NET sets the flag to get the old fields approach)

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Nullable<System.DateTime> SystemModstamp {
        get {
            return this.systemModstampField;
        }
        set {
            this.systemModstampField = value;
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool SystemModstampSpecified {
        get {
            return this.systemModstampFieldSpecified;
        }
        set {
            this.systemModstampFieldSpecified = value;
        }
    }

So, now that it generates Nullable<DateTime> for the property why do we even need the Specified field, string properties don't get one. I'm assuming its for backwards compatibility with previously code gen'd classes. But why oh why couldn't they of gone the extra couple of inches and had the setter for the value set the Specified property as well ???