'ECGridOSSearchECGridID by Loren Data Corp.
'
'This public domain code demonstrates how to use ECGridOS to find the ECGridID
'on ECGrid(r) for a specified Qualifier/ID (QID)
'
'See ECGridOS documentation at http://ecgridos.net
'Request ECGridOS credentials at http://ecgridos.com
'
'The following ECGridOS calls are used:
' Login()
' Logout()
' TPSearchEx()
'
'The syntax of this function is:
'
'ECGridOSSearchECGridID <UserID> <Password> <Qualifier*ID>
'
' UserID - must be previously registered on ECGridOS
' Password - must be previously registered on ECGridOS
' Qualifier*ID - must include * separator, start with * if no Qualifier
'
'ECGrid is a registered service mark of Loren Data Corp.
'ECGridOS is a service mark of Loren Data Corp.
Imports System.Web.Services.Protocols
Imports System.Xml
Module Module1
'ECGRIDOS: Set up an Object for the Web Service;
' this requires a Web Reference
to ' https://ecgridos.net/v2.1/prod/ecgridosv0201.asmx
Public ecgridos As New net.ecgridos.ECGridOSAPIv2
'ECGRIDOS: Have a place to store the SessionID
Public SessionID As String
Sub Main()
If My.Application.CommandLineArgs.Count <> 3 Then
Syntax()
Else
Dim UserID As String = My.Application.CommandLineArgs(0)
Dim Password As String = My.Application.CommandLineArgs(1)
Dim QID As String = My.Application.CommandLineArgs(2).ToUpper
Console.WriteLine(My.Application.Info.ProductName)
Try
'ECGRIDOS: Always Login first
SessionID = ecgridos.Login(UserID, Password)
Dim Qualifier As String
Dim ID As String
'TPSearchEX returns an Array of ECGridIDInfo objects
Dim ECGridIDInfo() As net.ecgridos.ECGridIDInfo
Qualifier = QID.Split("*")(0)
ID = QID.Split("*")(1)
'NetworkID:=-1 and MailboxID:=-1 means to search entire directory
ECGridIDInfo = ecgridos.TPSearchEx(SessionID:=SessionID, _
NetworkID:=-1, _
MailboxID:=-1, _
Qualifier:=Qualifier, _
ID:=ID, _
ShowInactive:=False)
Console.WriteLine()
Console.WriteLine([String].Format(
_ "Found {0} matching records for {1}.", _
ECGridIDInfo.Length, QID))
Console.WriteLine()
For Each ecID As net.ecgridos.ECGridIDInfo In ECGridIDInfo
Console.WriteLine([String].Format(
_ "Description: {0}", ecID.Description))
Console.WriteLine([String].Format(
_ " ECGridID: {0}", ecID.ECGridID))
Console.WriteLine([String].Format(
_ " Network: ({0}) {1}", ecID.NetworkID, _
ecID.NetworkName))
Console.WriteLine()
Next
Catch ex As SoapException
'There is good data in the InnerXML
'which can be parsed and used to processes specific exceptions
Dim doc As New XmlDocument
Dim Node As XmlNode
doc.LoadXml(ex.Detail.OuterXml)
Node = doc.DocumentElement.SelectSingleNode("ErrorInfo")
If Not Node Is Nothing Then
Console.WriteLine([String].Format("SOAP Exception: ({0}) {1}", _
Node.SelectSingleNode("ErrorCode").InnerText, _
Node.SelectSingleNode("ErrorString").InnerText))
Console.WriteLine([String].Format(" Error Item: {0}", _
Node.SelectSingleNode("ErrorItem").InnerText))
Console.WriteLine([String].Format(" Msg: {0}", _
Node.SelectSingleNode("ErrorMessage").InnerText))
Else
Console.WriteLine("ERROR: " & ex.Message.ToString)
End If
Catch ex As Exception
Console.WriteLine("ERROR: " & ex.ToString)
Finally
'ECGRIDOS: Make sure to Logout when done.
ecgridos.Logout(SessionID)
End Try
End If
ecgridos = Nothing
End Sub
Private Sub Syntax()
Console.WriteLine("ECGridOSSearchECGridID <UserID>
<Password>" &
_ " <Qualifier*ID>")
Console.WriteLine(" UserID - must be previously registered on ECGridOS")
Console.WriteLine(" Password - must be previously registered on ECGridOS")
Console.WriteLine( " Qualifier*ID - must include * separator, start" & _
" with * if no Qualifier")
End Sub
End Module
|