Web Services array input

How do I code a LotusScript web service to accept a multivalued (array) input? I have a web service that simply sends an email given recipient, subject, and body text. This works as written but I want to modify it to accept multiple recipients. Not sure how to approach this? Any hints appreciated. Here’s the code…

Dim s As NotesSession

Class SendEmail

    Sub NEW 

            Set s = New NotesSession 

    End Sub 

     

    Function SendEmail(UserName As String, Password As String, SendTo As String, Subject As String, Body As String) As String 

             

            On Error Goto oops 

             

            Dim db As NotesDatabase 

            Dim doc As NotesDocument 

            Dim rtitem As NotesRichTextItem 

            Dim msg As String 

             

            If UserName <> "Username" Or Password <> "Password" Then 

                    SendEmail = "Login credentials incorrect.  User not authenticated." 

                    Exit Function 

            End If 

             

            If Subject = "" Then 

                    SendEmail = "Subject is required" 

                    Exit Function 

            End If 

             

            If Body = "" Then 

                    SendEmail = "Body is required" 

                    Exit Function 

            End If 

             

            If Not s.CurrentDatabase.IsOpen Then 

                    SendEmail = "Couldn't open database" 

                    Exit Function 

            End If 

             

            Set doc = s.CurrentDatabase.CreateDocument 

            doc.Form = "Memo" 

            doc.Principal = "no-reply@company.com" 

            doc.InetFrom = "no-reply@company.com" 

            doc.From = "no-reply@company.com" 

            doc.Subject = Subject 

            Set rtitem = New NotesRichTextItem(doc, "Body") 

            rtitem.AppendText(Body) 

            On Error Goto sendoops 

            Call doc.Send(False, SendTo) 

            On Error Goto oops 

            SendEmail = "Message successfully sen!" 

             

            Exit Function 

oops:

            msg = Error$ & " on " & Cstr(Erl) 

            Msgbox  msg 

            SendEmail = msg 

            Resume done 

sendoops:

            msg= "Couldn't send message: " & Error$ 

            Msgbox  msg 

            SendEmail = msg 

            Resume done 

done:

    End Function     

End Class

Subject: Other option

You can do

sendTo() as String

in the arguments. After that use UBOUND and LBOUND to determine the size of the array to process.

Subject: if you have used %INCLUDE “lsxsd.lss”

If you developed this web service provider in 8.5.1, then you probably included the lsxsd.lss library.In this case, there is a class, STRINGARRAY_HOLDER that should do what you want.

Using this class, your subroutine parameters would be like (…, SendTo as STRINGARRAY_HOLDER, Subject As String…)

This is a fairly limiting class, but it does have a property (called Value) that you can use to test and get the values passed for processing.

To test that the SendTo array does have values, even if it is only one, use code similar to:-

If Not Isarray ( SendTo.Value ) Then

  Call throwFault(returnFault, "ERROR email list is not an array" )

  Exit Function

End If

To process the values in this array, use code similar to:-

Forall email_address In SendTo.Value

		itemCount = itemCount + 1

                    .....test for validity

                   ....do something with email_address

End Forall

I have a web service provider as follows

Public Function scrubDescriptionsMulti (user_memberid As String, input_DescriptionArray As STRINGARRAY_HOLDER, returnFault As WS_FAULT ) As scrubberResultItemArray

which accepts input including an array of descriptions to be processed, and returns a complex array of processed values.

This works very reliably between our 8.5.1 Domino server and numerous dot.Net systems, the facilitator being that this consumer service is defined as “Wrapped” soap.

While the STRINGARRAY_HOLDER class works OK, I want to replace it with a class of my own design so I can set the names of the values that appear in the wsdl. I have not been successful so far.

For me, the holy grail is to be able to define a class which will accept an array of multiple values, ie a 2-D array. I have never seen any examples of this, though clearly it can be done.

I hope the above is of help and not too off-beam. If you need more help, LMK

Subject: Complex Data Types

This is a very good Thread and gives me hope.

I’m creating a Lotus Notes Web service Provider and would like to know how to map the complex data types in the WSDL to a string in the function.

The following code seems to work (Testing with SOAPUI 3.6.1), although it’s only returning the value of the first element of each complex data type eg, ‘IDOC’ and ‘MessageFunction’.

I’m not sure how to pull any of the values from the DocHead and Per classes into a Notes string.

An example would be appreciated or at least show where the code is failing.

Lotus Notes Web Provider:

'Options:

Option Public

%INCLUDE “lsxsd.lss”

'Declarations:

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim newDoc As NotesDocument

Dim s As String

Class DocHead As STRINGARRAY_HOLDER

  Public CreationDate() As XSD_STRING

  Public CreationTime() As XSD_STRING      

  Public IDOC() As XSD_STRING

  Public SenderPort() As XSD_STRING

  Public Sender() As XSD_STRING

  

  Public Sub NEW

  End Sub

End Class

Class Per As STRINGARRAY_HOLDER

  Public MessageFunction() As XSD_STRING

  Public PersonnelNumber() As XSD_STRING

  Public Surname() As XSD_STRING

  Public Firstname() As XSD_STRING

  

  Public Sub NEW

  End Sub

End Class

Class PersonnelUpdate_MasterData

  Public Function PersonnelUpdate(DocumentHeader As DocHead, Personnel As Per, returnfault As WS_FAULT) As String

        On Error Goto processError

        

        Dim session As New NotesSession

        Set db = session.CurrentDatabase 

        Set newdoc = New NotesDocument ( db )

        

        'Notes document processing........

        

        Exit Function

processError:

        Call returnFault.setFault(True)

        Call returnFault.setFaultString(Error$)

        Messagebox "Logging to console: " & Error$

        Exit Function

  End Function

End Class

WSDL:

<?xml version="1.0" encoding="UTF-8" ?>

<wsdl:definitions name=“PersonnelUpdate_Inb” targetNamespace=“http://companyname/masterdata/hr” xmlns:p1=“http://companyname/masterdata/hr” xmlns:wsp=“Web Services Policy Framework (WS-Policy) and Web Services Policy Attachment (WS-PolicyAttachment)” xmlns:wsu=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/”>

<wsdl:documentation />

<wsp:UsingPolicy wsdl:required=“true” />

<wsp:Policy wsu:Id=“OP_PersonnelUpdate_Async” />

wsdl:types

<xsd:schema targetNamespace=“http://companyname/masterdata/hr” xmlns=“http://companyname/masterdata/hr” xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>

<xsd:element name=“PersonnelUpdate” type=“Personnel” />

<xsd:complexType name=“Personnel”>

xsd:sequence

<xsd:element name=“DocumentHeader”>

xsd:complexType

xsd:sequence

<xsd:element name=“IDOC” type=“xsd:string” />

<xsd:element name=“Sender” type=“xsd:string” />

<xsd:element name=“SenderPort” type=“xsd:string” />

<xsd:element name=“CreationDate” type=“xsd:string” />

<xsd:element name=“CreationTime” type=“xsd:string” />

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name=“Personnel”>

xsd:complexType

xsd:sequence

<xsd:element name=“MessageFunction” type=“xsd:string” />

<xsd:element name=“PersonnelNumber” type=“xsd:string” />

<xsd:element name=“Surname” type=“xsd:string” />

<xsd:element name=“Firstname” type=“xsd:string” />

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:schema>

</wsdl:types>

<wsdl:message name=“PersonnelUpdate”>

<wsdl:documentation />

<wsdl:part name=“PersonnelUpdate” element=“p1:PersonnelUpdate” />

</wsdl:message>

<wsdl:portType name=“PersonnelUpdate_Inb”>

<wsdl:documentation />

<wsdl:operation name=“PersonnelUpdate_Async”>

<wsdl:documentation />

wsp:Policy

<wsp:PolicyReference URI=“#OP_PersonnelUpdate_Async” />

</wsp:Policy>

<wsdl:input message=“p1:PersonnelUpdate” />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name=“PersonnelUpdate_InbBinding” type=“p1:PersonnelUpdate_Inb”>

<soap:binding style=“document” transport=“http://schemas.xmlsoap.org/soap/http” xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/” />

<wsdl:operation name=“PersonnelUpdate_Async”>

<soap:operation soapAction=“loading... | SAP Help Portal” xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/” />

wsdl:input

<soap:body use=“literal” xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/” />

</wsdl:input>

</wsdl:operation>

</wsdl:binding>

</wsdl:definitions>

Subject: any news on this

Hi, its been 2 years now. Did you end up solving this? I’ve a similar problem.

Subject: Most obvious answer

In your SendTo variable have a comma delimited string of the recipients.