Lotus Notes / Domino Sonstiges > Help-Desk Applikation !!Help!!

Help Application demo at Lotusphere

<< < (4/34) > >>

flaite:
Ulrich,

es macht aus meiner Sicht keinen Sinn, NotesDocumentCollection zu übergeben.
Blackberry hat keinen Notes Client und da gibt es überhaupt keine NotesDocumentCollection.
Vielleicht ist das schon so in Domino Webservices vorgesehen, dass da keine Domino-proprietären Objekte übertragen werden können.
Das ist, was ich mit Document-Style Webservices meine.

Was für einen Client nimmst du?
Eclipse Web Tools Platform?
Ich versuch morgen mal !!!Help!!! auf Domino 7 zu installieren. 

Gruß Axel

flaite:
Im Grunde genommen hat das mit dem Complex Type Kapitel (ziemlich weit unten) von hier zu tun:
http://www-128.ibm.com/developerworks/lotus/library/nd7-webservices/index.html
Du kannst einfach nicht beliebige Datentypen über RPC-style übergeben. D.h. sie dürfen nur aus den genannten in RPC erlaubten Datentypen bestehen.
Du kannst zwar Klassen, Arrays, evtl. sogar Listen (noch nicht genau angeschaut) übertragen, aber eben keine komplexen, in Lotus eingebauten Objekte (z.B. NotesDocumentCollection).
Intern wird das in die SOAP-Datentypen, enkodiert als xml übersetzt.
Ganz hilfreich wars bei meinem ersten Webservices Projekt, als ich einen Proxy dazwischengeschaltet habe (gibts im apache-axis Projekt). Dann kann man nämlich sehen *wie* das Zeugs per xml-message zwischen Consumer und Producer hin-und-hergeschickt wird.
Kann ich mal zeigen.
Damit sieht man besser, was unter der Haube abläuft.
Du müßtest die Document Collection in eine eigene Klasse mappen. Irgendwann werden dann Document-style Webservices einfacher.

Gruß Axel

eknori (retired):
@Axel:

Zum Testen nehme ich Eclipse mit Web Services Explorer Plugin.
Ja, ich weiß, daß man keine Collection übergeben kann.  Habe gestern mal Julian angemailt und ihn gefragt, wie man das lösen könnte; hier seine Antwort:

Ulrich -

There are a few ways to accomplish what you want.

One thing you will NOT be able to do is return an actual NotesDocumentCollection. You can return a custom class, or an array of a custom class, but not a Notes class.

The easiest way to do it in LotusScript is to create a custom class that is something like this:

========= CODE =========

Class TicketCollection
    Public Tickets() As Ticket
    Public Count As Integer
End Class

========= CODE =========


And then you'd have a function in your web service like:


========= CODE =========

Public Function GetAllTickets () As TicketCollection
    Dim session as new NotesSession
    Dim db as NotesDatabase
    Dim dc as NotesDocumentCollection
    Dim doc as NotesDocument
    Dim count as integer

    set db = session.CurrentDatabase
    set dc = db.AllDocuments()
    count = dc.Count
   
    set GetAllTickets = new TicketCollection
    GetAllTickets.Count = count
    If (count = 0) then
        Redim GetAllTickets.Tickets(count)
    Else
        Redim GetAllTickets.Tickets(count - 1)
    End If
   
    count = 0
    set doc = dc.GetFirstDocument
    do until (doc is nothing)
        '** write some kind of function that converts a NotesDocument
        '** to an object of type Ticket
        set GetAllTickets.Tickets(count) = GetTicketInfo(doc)
        count = count + 1
        set doc = db.GetNextDocument(doc)
    loop
   
End Function

========= CODE =========

When something calls the web service, it will have to read the WSDL file to understand how to parse both a TicketCollection and a Ticket, but that's pretty trivial at this point. All you have to do is have the calling code get the TicketCollection, check to see if there are any tickets in it, and if there are, read through the TicketCollection.Ticket() array.

It's useful to have the TicketCollection.Count variable in there, because it's safer to check for TicketCollection.Count == 0 than it is to start reading a possibly null array.

By the way, all the code above was typed directly into this e-mail, so there are likely some errors. But it should give you the idea, anyway.

Hope that helps!

- Julian

Das mit  Public Tickets() As Ticket hatte ich auch schon, aber irgendwie hat das nicht hingehauen; jetzt weiß ich auch warum: Public Count As Integer ist das fehlende Puzzle Teil.

flaite:
Hmm. Von der Klasse ist es jetzt in Ordnung.
Ein Ticketobjekt besteht ja nun lediglich aus den in SOAP erlaubten Datentypen.
Ich halte nach wie vor doc-Style als sinnvoller.
Hast du es einmal ausprobiert.
Ich kann mal versuchen das hier nachzuvollziehen.

flaite:
Ok. Ich habs jetzt für meinen Land/Hauptstadt Webservice ausprobiert.
Ich glaub das Problem ist weniger das mit der 0-Collection, sondern mehr dem WSDL zu erklären, was man unter einem Array von Custom-Objekten versteht.
Genau das muss aber im WSDL stehen, würd ich sagen.
Du kannst in einer LotusScript ja nicht einmal deklarieren, dass du einen bestimmten Array zurückgeben willst sondern nur Variant. IMHO muss das Custom Objekt (in meinem Fall LandInst mit den Membern name und Hauptstacdt) aber im WSDL beschrieben werden, damit das funktioniert.


Ohne mir ganz sicher zu sein, sehe ich 2 Möglichkeiten:
a) Irgendwie das wsdl-File customizen (auch nicht einfach) oder
b) Doc-Lit Style Webservices.

Ich versuch das erstmal mit dem Land-Webservices, mach aber heute längere Pausen.

Neuer Land webservice mit neuer Funktion getAllLands()

--- Code: ---Class Land
Private ses As NotesSession
Private db As NotesDatabase
Private vwLand As NotesView


Public Sub New
Set ses = New NotesSession()
Set db = ses.currentDatabase
Set vwLand = db.getView("land")
End Sub


Public Function getHauptstadt (land As String) As String
Dim docLand As NotesDocument
Set docLand = vwLand.GetDocumentByKey(land)
If docLand Is Nothing Then
getHauptstadt = "LAND <" & land & "> kann in der Datenbank nicht gefunden werden."
Else
getHauptstadt = docLand.Hauptstadt(0)
End If

End Function

Public Function getAllLands() As Variant

Dim retVal() As LandInst
Dim aCounter As Long
aCounter = -1
Dim aLandInst As LandInst


Dim docLand As NotesDocument
Set docLand = vwLand.getFirstDocument

Do Until docLand Is Nothing
aCounter = aCounter + 1
Set aLandInst = New LandInst()
aLandInst.name = docLand.land(0)
aLandInst.hauptStadt = docLand.hauptStadt(0)
Redim Preserve retVal(aCounter)
Set retVal(aCounter) = aLandInst
Set docLand = vwLand.GetNextDocument(docLand)
Loop
If aCounter > - 1 Then
getAllLands = retVal
Else
getAllLands = retVal
End If

End Function

End Class

--- Ende Code ---

erzeugt dieses WSDL:

--- Code: ---<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:DefaultNamespace" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:DefaultNamespace" xmlns:intf="urn:DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <wsdl:message name="GETHAUPTSTADTResponse">
  <wsdl:part name="GETHAUPTSTADTReturn" type="xsd:string"/>
 </wsdl:message>
 <wsdl:message name="GETALLLANDSRequest">
 </wsdl:message>
 <wsdl:message name="GETHAUPTSTADTRequest">
  <wsdl:part name="LAND" type="xsd:string"/>
 </wsdl:message>
 <wsdl:message name="GETALLLANDSResponse">
  <wsdl:part name="GETALLLANDSReturn" type="xsd:anyType"/>
 </wsdl:message>
 <wsdl:portType name="Land">
  <wsdl:operation name="GETHAUPTSTADT" parameterOrder="LAND">
   <wsdl:input message="impl:GETHAUPTSTADTRequest" name="GETHAUPTSTADTRequest"/>
   <wsdl:output message="impl:GETHAUPTSTADTResponse" name="GETHAUPTSTADTResponse"/>
  </wsdl:operation>
  <wsdl:operation name="GETALLLANDS">
   <wsdl:input message="impl:GETALLLANDSRequest" name="GETALLLANDSRequest"/>
   <wsdl:output message="impl:GETALLLANDSResponse" name="GETALLLANDSResponse"/>
  </wsdl:operation>
 </wsdl:portType>
 <wsdl:binding name="DominoSoapBinding" type="impl:Land">
  <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <wsdl:operation name="GETHAUPTSTADT">
   <wsdlsoap:operation soapAction="GETHAUPTSTADT"/>
   <wsdl:input name="GETHAUPTSTADTRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded"/>
   </wsdl:input>
   <wsdl:output name="GETHAUPTSTADTResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded"/>
   </wsdl:output>
  </wsdl:operation>
  <wsdl:operation name="GETALLLANDS">
   <wsdlsoap:operation soapAction="GETALLLANDS"/>
   <wsdl:input name="GETALLLANDSRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded"/>
   </wsdl:input>
   <wsdl:output name="GETALLLANDSResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded"/>
   </wsdl:output>
  </wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="LandService">
  <wsdl:port binding="impl:DominoSoapBinding" name="Domino">
   <wsdlsoap:address location="http://localhost"/>
  </wsdl:port>
 </wsdl:service>
</wsdl:definitions>


--- Ende Code ---

Dieser Teil sieht für mich nicht sonderlich ermutigend aus:

--- Code: ---<wsdl:message name="GETALLLANDSResponse">
  <wsdl:part name="GETALLLANDSReturn" type="xsd:anyType"/>
 </wsdl:message>

--- Ende Code ---

Vielleicht hat Julian Lust sich an der Diskussion zu beteiligen?
Der Land-Webservice wäre ein einfaches Beispiel als Modell, um Domino-Webservices dazu zu bringen, komplexere Datentypen herauszugeben.

Gruß Axel

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln