Simon Fell > Its just code > June 2004

Tuesday, June 29, 2004

A few folks have pinged me about working on RESTlog.NET, so I've moved it to sourceforge. The code up there has a bunch of stuff ( comments, comment-api, wfw:comment, atom feed ), that's not in the 0.1 release. Going to try and get the current features finalized and a 0.3 release wrapped up.

Tuesday, June 29, 2004

Hey, looks like Scott Hanselman is coming to the bay area, and bonus for me, its only one floor away!, looking forward to seeing what Scott has to say.

Tuesday, June 29, 2004

Tim has a post about Doc/Literal/Bare style web services in .NET over on his new blog. For the PocketSOAPers out there, this is exactly what the PocketSOAP WSDL wizard will generate.

Saturday, June 19, 2004

Burried in this MSDN doc on choice's for attachments is the statement that Microsoft don't plan on supporting Soap with Attachments, which is the basis for the WS-I Attachments profile. Oh well, don't expect the current nightmare around soap attachments (for which we largely have MS to thank for) to go away anytime soon.

Wednesday, June 16, 2004

Very interesting post to Full Disclosure and NTBugTraq about the state of the MS Web site and its over active use of client side scripting to do simple server side stuff.

Wednesday, June 9, 2004

Microsoft patents 'to-do' list, surely the Eclipse boys had this before VS.NET ?

Tuesday, June 8, 2004

Been reading up on WS-Eventing (and WS-Events) recently, however the potential IP issues with both specs (the spec doesn't give you any IP license, nor indicate what terms any IP license might be on) would make me nervous about implementing either of them. I tend to agree with Steve Vinoski's post that this is hurting more than helping. Until the GXA folks detail the IP stance for all these specs, how is anyone outside of the GXA clan (not just people building tools, but people building services too) supposed to make any forward progress ?, or perhaps with my cynical bastard hat on, I'd say that was the point.

Monday, June 7, 2004

A popular question recently, you have 2 choices, (1) go grab the WSDL Wizard and have it generate all the code for you or (2) follow this example.

This quick demo will call a method from the SOAPBuilders Interop tests called echoStructArray, this method takes an array of structures (aka ComplexTypes) as input and echos the array back as output (see the WSDL for the details. By default, an array of complex types is going to be represented in PocketSOAP as an array of CoSoapNode objects, each Node object will have child nodes in the Nodes property containing the child elements. So to create an array of complex types, we need to declare the array, then populate each array item with a CoSoapNode object, e.g.

    Dim arr(2) As Object
    Set arr(0) = makeSoapStruct("String one", 1, 1.1)
    Set arr(1) = makeSoapStruct("String two", 2, 2.2)
    Set arr(2) = makeSoapStruct("String three", 3, 3.3)

Where makeSoapStruct is defined as

' helper function to create a SOAPStruct complex type
Private Function makeSoapStruct(varString As String, varInt As Long, varFloat As Single) As CoSoapNode
    Dim ct As New CoSoapNode
    ct.Nodes.Create "varString", varString
    ct.Nodes.Create "varInt", varInt
    ct.Nodes.Create "varFloat", varFloat
    Set makeSoapStruct = ct
End Function

To handle the response, its just the reverse, grab the parameter, its value will be an array of variants, each variant will contain a CoSoapNode object, e.g.

    'get the returned array
    Dim res()
    res = e.Parameters.Item(0).Value
    ' iterate over it
    Dim idx As Integer
    Dim n As CoSoapNode
    For idx = LBound(res) To UBound(res)
        ' each item in the array is a soapnode, with child nodes for varString, varInt, varFloat
        Set n = res(idx)
        List1.AddItem n.Nodes.ItemByName("varString").Value & " " & n.Nodes.ItemByName("varInt").Value & " " & n.Nodes.ItemByName("varFloat").Value
    Next

That's all there is to it!. The full VB code is available for download (2k), for reference, these are the generated request and response messages from this code.

POST http://soap.4s4c.com/ilab/soap.asp HTTP/1.1
Host: soap.4s4c.com
Accept-Charset: UTF-8, UTF-16;q=0.8, iso-8859-1;q=0.8
Accept-Encoding: deflate, gzip
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://soapinterop.org/"
User-Agent: PocketSOAP/1.5.b1/PocketHTTP/1.2
Content-Length: 1209

<S:Envelope
	xmlns:Enc="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:a="http://soapinterop.org/"
	xmlns:XS="http://www.w3.org/2001/XMLSchema"
	xmlns:XI="http://www.w3.org/2001/XMLSchema-instance">
 <S:Body>
  <a:echoStructArray S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <inputStructArray XI:type="Enc:Array" Enc:arrayType="XS:anyType[3]">
      <x href="#3dd43e4"/>
      <x href="#3ddd48c"/>
      <x href="#3dd42bc"/>
    </inputStructArray>
   </a:echoStructArray>
   <x S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" Enc:root="0" id="3dd42bc">
    <varString XI:type="XS:string">String three</varString>
    <varInt XI:type="XS:int">3</varInt>
    <varFloat XI:type="XS:float">3.3</varFloat>
   </x>
   <x S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" Enc:root="0" id="3ddd48c">
    <varString XI:type="XS:string">String two</varString>
    <varInt XI:type="XS:int">2</varInt>
    <varFloat XI:type="XS:float">2.2</varFloat>
   </x>
   <x S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" Enc:root="0" id="3dd43e4">
    <varString XI:type="XS:string">String one</varString>
    <varInt XI:type="XS:int">1</varInt>
    <varFloat XI:type="XS:float">1.1</varFloat>
   </x>
 </S:Body>
</S:Envelope>
HTTP/1.1 200 OK
Date: Tue, 08 Jun 2004 03:23:52 GMT
Server: Microsoft-IIS/5.0
Content-Length: 1175
Content-Type: text/xml; charset=UTF-8
Expires: Tue, 08 Jun 2004 03:23:52 GMT
Cache-control: private
X-Cache: MISS from mayhem.pocketsoap.com

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <m:echoStructArrayResponse xmlns:m="http://soapinterop.org/">
   <outputStructArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns1:SOAPStruct[3]" xmlns:ns1="http://soapinterop.org/xsd">
    <SOAPStruct xsi:type="ns1:SOAPStruct">
     <varString xsi:type="xsd:string">String one</varString>
     <varInt xsi:type="xsd:int">1</varInt>
     <varFloat xsi:type="xsd:float">1.1</varFloat>
    </SOAPStruct>
    <SOAPStruct xsi:type="ns1:SOAPStruct">
     <varString xsi:type="xsd:string">String two</varString>
     <varInt xsi:type="xsd:int">2</varInt>
     <varFloat xsi:type="xsd:float">2.2</varFloat>
    </SOAPStruct>
    <SOAPStruct xsi:type="ns1:SOAPStruct">
     <varString xsi:type="xsd:string">String three</varString>
     <varInt xsi:type="xsd:int">3</varInt>
     <varFloat xsi:type="xsd:float">3.3</varFloat>
    </SOAPStruct>
   </outputStructArray>
  </m:echoStructArrayResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Saturday, June 5, 2004

Chris is looking for speakers for the next XML DevCon, I'm hoping I can get out to this one.

Thursday, June 3, 2004

Tomas is calling MS on their attempt to rewrite history of the MS SOAP Toolkit.

Wednesday, June 2, 2004

Ted Neward has a post about web service tools, and their magic wand approach of generating WSDL / services from class definitions (ala ,NET / Java ), and how that's evil etc. Then goes on to say that doc/literal is going to save us. Whilst I agree that doc/literal is generally better than rpc/encoded (assuming tools get around to supporting all of XSD, the current mismatch of partial XSD support is an interop nightmare for authoring service WSDLs) using doc/literal won't magically save you either, its just as easy in both .NET & Axis to build doc/lit services from class definitions as it is to build rpc/enc services. In fact Ted's .NET magic wand sample actually is a doc/literal service. Basically, as much as the tool vendors would like you to believe otherwise, 3 years on from the SOAP 1.1. spec, its still a tedious error prone job to build good web services.