Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Push data to a web services provider using Lotusscript for Notes 8?

Posted on 2007-03-22
5
634 Views
Last Modified: 2013-11-17
Does anyone have a sample script showing how to push data to a web services provider using Lotusscript for Notes 8?

I was able to get the exchange rate web service calc to work on Notes 8.  I have been playing with IBM helpdesk.nsf sample web service.  I successfully imported the WSDL file, but I am uncertain on how to write to the database.

-Brian-
0
Comment
Question by:bmcdowell540
  • 2
5 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 18775988
Haven't had a chance to test the beta yet, but it does sound interesting.

0
 
LVL 19

Accepted Solution

by:
madheeswar earned 500 total points
ID: 18778798
check below link: Register for free:
http://searchdomino.techtarget.com/tip/1,289483,sid4_gci1176810,00.html
Content of the link:
If you don't want to use the IBM SOAP Connect examples, this class uses the Microsoft XMLHTTP parser to invoke and return values from a Web service. This was developed for and used with C# Web services.

Here's a LotusScript example, followed by the class code. I like to keep my class in a script library. If you choose to do the same, don't forget the using statement in your agent or form. This particular example is passing a parameter to the Web service -- but you don't have to do this. If you don't want to pass parameters, just omit the ws.wsParams line.

Dim ws As New WebService("http://localhost/pathToWebService/",_
"CSharpWebService.asmx", "HelloWorld")
ws.wsParams("param1") = "testing parameters"
ws.Invoke

%REM
Title: Web Service Invoker Script Library
Version: 1.0 Alpha
Author: Giles Hinton
Last Updated: 17-Mar-2006
%END REM

Public Const ERROR_CONNECTION = 20001
Public Const ERROR_XMLPARSER_NOT_INSTALLED =
20002 Public Const ERROR_WEBSERVICE_SERVER_ERROR =
20003

'
' Begin Class declaration

Public Class MonitorWebService
 Public wsParams List As String
 
 Private wsSoapFault As SOAPFault
 Private wsSession As NotesSession
 Private wsXMLResponse As String
 Private wsSoapEnvelope As String
 Private wsURL As String
 Private wsFileName As String
 Private wsMethod As String
 Private wsRunSuccess As Boolean
 
 ' Constructor
 Public Sub New(WebServiceURL As String,
WebServiceFileName As String,_
 WebServiceMethod As String)
  Set wsSession = New NotesSession
  wsURL = WebServiceURL
  wsFileName = WebServiceFileName  
  wsMethod = WebServiceMethod
 End Sub
 
 Public Sub Invoke()
  Dim objHttp As Variant, objResponse As Variant
  Dim soapRequest As String
 
  ' Open syntax is Http Method, URL, async, username and password
  Set objHttp = CreateObject("Microsoft.XMLHTTP")
  objHttp.open "POST", wsURL & wsFileName, False
  If objHttp Is Nothing Then Error ERROR_XMLPARSER_NOT_INSTALLED,
"XML Parser is not installed."
 
  objHttp.setRequestHeader "Content-Type", "text/xml"
  objHttp.setRequestHeader "SOAPAction", wsURL + wsMethod  
 
  soapRequest = Me.BuildSoapEnvelope()
 
  objHttp.setRequestHeader "Content-Length", Len(soapRequest)
  objHttp.send(soapRequest)
 
  ' Soap Fault
  If Instr(1, objHttp.ResponseText, "<soap:fault>", 5)
<> 0 Then
   Set wsSoapFault = BuildSoapFault(Strleft(Strright
(objHttp.ResponseText, "<soap:fault>", 5), "</soap:fault>", 5))
   wsRunSuccess = False
   Error ERROR_WEBSERVICE_SERVER_ERROR,
"Soap Error Encountered."
  ' Server not found
  Elseif objHttp.Status <> 200 Then
   Error ERROR_CONNECTION,
"Could not connect to web service provider."
   wsRunSuccess = False
  Else  
   Set objResponse = CreateObject("Msxml2.DOMDocument")
   Call objResponse.loadXML(objHttp.ResponseText)
   wsXMLResponse = objResponse.xml
   wsRunSuccess = True
  End If
  Set objHttp = Nothing
  Set objResponse = Nothing
 End Sub
 
 Private Function BuildSoapFault
(SoapFaultXML As String) As SoapFault
  Dim faultcode As String,
faultstring As String, faultActor As String
  faultCode = GetTagContent("faultcode", SoapFaultXML)
  faultString = GetTagContent("faultstring", SoapFaultXML)
  faultActor = GetTagContent("faultactor", SoapFaultXML)
  Set BuildSoapFault = New SoapFault
(faultActor, faultCode, faultString)
 End Function
 
 Private Function GetTagContent(TagName As String,
Source As String) As String
  GetTagContent = Strleft(Strright(Source, "<" & TagName & ">", 5),
"</" & TagName & ">", 5)
 End Function
 
 Private Function BuildSoapEnvelope() As String
  Dim tmpEnv As String
  tmpEnv = |<?xml version="1.0" encoding="utf-8"?>| &_
  |<soap:Envelope xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" | &_
  |xmlns:xsd="http://www.w3.org/2001/XMLSchema" | &_
  |xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">| &_
  |<soap:Body>| &_
  |<| & wsMethod & | xmlns="| & wsURL & |">|
 
  ' If parameters have been specified for the web service add them now
  If Islist(wsParams) Then
   Dim paramTag As String
   Forall params In wsParams
    paramTag = Listtag(params)
    tmpEnv = tmpEnv & |<| & paramTag & |>|
& params & |</| & paramTag & |>|
   End Forall
  End If
  tmpEnv = tmpEnv & |</| & wsMethod & |>| &_
  |</soap:Body>| &_
  |</soap:Envelope>|
  BuildSoapEnvelope= tmpEnv
 End Function
 
 ' ********* Properties ************
 Public Property Get Successful As Boolean
  Successful = wsRunSuccess
 End Property
 
 Public Property Get XmlResponse As String
  XmlResponse = wsXMLResponse
 End Property
 
 Public Property Get ServiceURL As String
  ServiceURL = wsURL
 End Property
 
 Public Property Set ServiceURL As String
  wsURL = ServiceURL
 End Property
 
 Public Property Get ServiceFileName As String
  ServiceFileName = wsFileName
 End Property
 
 Public Property Set ServiceFileName As String
  wsFileName = ServiceFileName
 End Property
 
 Public Property Get ServiceMethodName As String
  ServiceMethodName = wsMethod
 End Property
 
 Public Property Set ServiceMethodName As String
  wsMethod = ServiceMethodName
 End Property
 
 Public Property Get ServiceSoapFaults As SoapFault
  Set ServiceSoapFaults = wsSoapFault
 End Property
End Class

Class SOAPFault
 Private fActor As String
 Private fCode As String
 Private fString As String
 
 Public Sub New(a As String, c As String, s As String)
  fActor = a
  fCode = c
  fString = s
 End Sub
 
 Public Property Get FaultActor As String
  FaultActor = fActor
 End Property
 
 Public Property Get FaultCode As String
  FaultCode = fCode
 End Property
 
 Public Property Get FaultString As String
  FaultString = fString
 End Property
End Class

Thanks to Giles Hinton.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 18778832
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to access Names.nsf DB from a C# application 14 1,591
Text over two lines in VBA for email 26 167
How do I delete a user in IBM Lotus Notes 2 206
attaching a file lotus notes 4 113
For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question