The saga of creating Web Services with Domino R6

I think I have officially bitten off more than I can chew. I am trying to convert a simple URL-triggered agent that returns XML into a real SOAP web service in Domino R6. I am almost positive that the data I am returning is in the proper format, but I cannot seem to get the WSDL file to match up with the output.

I am using a very cool Web Service testing tool called .NET WebService Studio which evaluates my WSDL file, and prompts me for the proper parameters to make the call. It makes the call and returns the data to client which formats the response in the format that the WSDL tells it to. This is where I am near my breaking point. The SOAP client seems to have an issue with casting the data it receives into the format/class that I define in my WSDL. SO I am going to walk myself through this to see if I spot any patterns and any help would be appreciated.


Since everything else seems to work, I will only post the TYPES and MESSAGES sections since I think that is where the issue is:

<definitions name="urn:addressMessage"
	targetNamespace="http://172.21.33.215/test/remotemethods.nsf/wsdl"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns="http://schemas.xmlsoap.org/wsdl/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:xsd1="http://172.21.33.215/test/remotemethods.nsf/schema"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:tns="http://172.21.33.215/test/remotemethods.nsf/wsdl"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" >
<types>
	<schema
		targetNamespace="http://172.21.33.215/test/remotemethods.nsf/schema"
		xmlns="http://www.w3.org/2001/XMLSchema"
		xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
	<complexType name="ArrayOfemployee">
		<complexContent>
			<restriction base="soapenc:Array">
				<attribute ref="soapenc:arrayType" xsdl:arrayType="xsd1:employee[]"/>
			</restriction>
		</complexContent>
	</complexType>
	<complexType name="employee">
		<sequence>
			<element name="lastName" type="string" />
			<element name="firstName" type="string" />
			<element name="notesName" type="string" />
			<element name="emailAddress" type="string" />
		</sequence>
		</complexType>
	</schema>
</types>
<message name="getAddressBookNamesRequest">
	<part name="starts_with" type="xsd:string" />
</message>
<message name="getAddressBookNamesResponse">
	<part name="return" type="xsd1:ArrayOfemployee" />
</message>

So it is relatively straight forward in that the user sends the first few characters of a users last name, and the web service returns an array of employees that match the search criteria. Here is what the response text looks like:

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:ns1="urn:addressMessage"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <soap:Body>
    <ns1:getAddressBookNamesResponse>
      <return xsi:type="ns1:ArrayOfemployee[2]">
        <item xsi:type="ns1:employee">
          <lastName xsi:type="xsd:string">Crossett</lastName>
          <firstName xsi:type="xsd:string">Jeff</firstName>
          <notesName xsi:type="xsd:string">CN=Jeff Crossett/O=MyDomain</notesName>
          <emailAddress xsi:type="xsd:string">[email protected]</emailAddress>
        </item>
        <item xsi:type="ns1:employee">
          <lastName xsi:type="xsd:string">Crossett</lastName>
          <firstName xsi:type="xsd:string">Other</firstName>
          <notesName xsi:type="xsd:string">CN=Other Crossett/O=MyDomain</notesName>
          <emailAddress xsi:type="xsd:string"></emailAddress>
        </item>
      </return>
    </ns1:getAddressBookNamesResponse>
  </soap:Body>
</soap:Envelope>

All seems OK with this response, the SOAP client does not return any errors in the parsing of the response, but throws this error:

System.InvalidCastException: Cannot assign object of type System.Xml.XmlNode[] to an object of type employee[].

AAAARRRRGHHH!!! Looking at that error gives me a headache. I will most likely have to go back to the drawing board and see if returning only one result can be done. I know that arrays can be tricky to begin with, and arrays of complex data types even worse, but it should not be this difficult.

2 Responses to “The saga of creating Web Services with Domino R6”

  1. Jerry Carter Says:

    Get it sorted yet?

    Some completely novice, zero experience XML “schema” obserations / Quesitons.

    return xsi:type=”ns1:ArrayOfemployee[2]”
    …… not a 0 based index?

    item xsi:type=”ns1:employee”
    …… not item xsi:type=”ns1:employee[4]” as there are 4 contained elements?

  2. Administrator Says:

    Yes I finally did get it Jerry! Humbly submitted here: http://www.crossedconnections.org/w/?p=51

    As for your questions:
    return xsi:type=”ns1:ArrayOfemployee[2]”
    …… not a 0 based index?
    -> According to the W3C specs, this is not an upper bound but a collection count. It is not explicitly stated in the spec, but the examples show the detail:
    http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383522

    item xsi:type=”ns1:employee”
    …… not item xsi:type=”ns1:employee[4]” as there are 4 contained elements?
    -> “employee” is declared as a data type, something like a List in LotusScript. Each element is actually a property of the “employee” data type.