Creating a WebService consumer. This can be done in many ways, depending of the platform:
Notes 8: Builtin functionality - Create a new Lotus Script library and click the 'Import WSDL' button below
Notes 7: Use Stubby to create a Java agent. Also check this error page. If your WSDL file is version 1.2 you can try downgrading the file (download, edit and remove all the version 1.2 stuff), then use Stubby
Notes 7 and Notes 8:
Java can be a problem. It's platform independent, but only runs in specific releases of Notes. You can create 2 agents - one for each release?
Or use LotusScript with the MSSOAP.SoapClient:
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
strVersionNumber = WshShell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
If strVersionNumber = "5.1" Then
Objname = "MSSOAP.SoapClient"
Elseif strVersionNumber = "5.0" Then
Objname = "MSSOAP.SoapClient30"
Else
Msgbox "Your Operating System is not Windows XP or Windows 2000, this demo will not run."
Exit Function
End If
Set SoapObj = CreateObject(objname)
Call SoapObj.mssoapinit (wsdl) ''Initialize connection to the WSDL file and get WSDL structure
(You can find this code in my (danish) sample WebService consumer & provider database)
Unfortunately this will only run on XP. The MSSOAP.SoapClient is not supported on Vista. Instead you can use the Msxml2.ServerXMLHTTP.3.0. With this you are down to the basic's - you must create the XML/SOAP yourself, and send it with a HTTP POST request to the server. I used the Altova XMLSpy to create the SOAP request and to test the response data. You just import the WSDL file and Altova does the rest. Great tool - and they have a 30 day free trial version.
The final code could look like this (well, almost - there is a bug in the code below. I just receive an error message in the response text. Will keep you posted when I find the solution)
Dim http As Variant
Set http = CreateObject("Msxml2.ServerXMLHTTP.3.0")
Dim xmlStr As String
xmlStr = {<?xml version="1.0" encoding="UTF-8" standalone="no"?>} & Chr( 13 ) & Chr( 10 )
xmlStr = xmlStr & {<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<SOAP-ENV:Body>
<m:GETNUM xmlns:m="urn:DefaultNamespace" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ID xsi:type="xsd:string">TEST</ID>
</m:GETNUM>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> }
Call http.Open( "POST", "http://www.notesnet.dk/majkilde/ws.nsf/number?wsdl", False )
Call http.setRequestHeader( "Content-Type", "text/xml; charset=UTF-8" )
Call http.send( (xmlStr) )
Print http.responseText
Tuesday, November 4, 2008
Subscribe to:
Post Comments (Atom)


2 comments:
More WebService info here:
- http://www.wohill.com/index.php?id=339
Finn Knudsen (the best programmer I know) found the solution. Sample code updated...
Post a Comment