Create an Interconnect


Request an Interconnect between two ECGridIDs.

Visual Basic
'ECGridOSAddInterconnect by Loren Data Corp.
 
'This public domain code demonstrates how to use ECGridOS add an Interconnect
'to ECGrid(r)
 
'See ECGridOS documentation at http://ecgridos.net
'Request ECGridOS credentials at http://ecgridos.com
 
'The following ECGridOS calls are used:
' Login()
' Logout()
' InterconnectAdd()
 
'The syntax of this function is:
'ECGridOSAddInterconnect <UserID> <Password> <ECGridID1> <ECGridID2> <ContactName> <ContactEMail>
' UserID - must be previously registered on ECGridOS
' Password - must be previously registered on ECGridOS
' ECGridID1 - the ECGridID in the User's Network/Mailbox
' ECGridID2 - the ECGridID for the Trading Partner on the VAN
' ContactName - the name of the person to receive e-mail notices for this Interconnect
' ContactEMail - the contact's e-mail address
 
'** NOTE **
'ECGridIDs must be set up using TPAdd(), TPAddVAN() or otherwise already exist
'in the ECGrid Directory. See ECGridOSNewQID for example code.
 
'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 <> 6 Then
         Syntax()
      Else
         Dim UserID As String = My.Application.CommandLineArgs(0)
         Dim Password As String = My.Application.CommandLineArgs(1)
         Dim ECGridID1 As Integer = CInt(My.Application.CommandLineArgs(2))
         Dim ECGridID2 As Integer = CInt(My.Application.CommandLineArgs(3))
         Dim ContactName As String = My.Application.CommandLineArgs(4)
         Dim ContactEMail As String = My.Application.CommandLineArgs(5)
 
         'InterconnectAdd returns an InterconnectIDInfo object
        
Dim
InterconnectIDInfo As net.ecgridos.InterconnectIDInfo
 
         Console.WriteLine(
My.Application.Info.ProductName)
 
         Try
            'ECGRIDOS: Always Login first
            SessionID = ecgridos.Login(UserID, Password)
 
            InterconnectIDInfo = ecgridos.InterconnectAdd(SessionID:=SessionID, _
             ECGridID1:=ECGridID1, _
             ECGridID2:=ECGridID2, _
             Reference:=
"", _
             ContactName:=ContactName, _
             ContactEMail:=ContactEMail, _
             NotifyContact:=
True, _
             Note:=
"")
 
            Console.WriteLine([String].Format( _
            
"InterconnectRequest #{0} created with status {1}", _
             InterconnectIDInfo.InterconnectID, _
             [Enum].GetName(InterconnectIDInfo.Status.GetType, _
             InterconnectIDInfo.Status).ToUpper))
 
            Console.WriteLine([String].Format( _
            
" TP1: {0}*{1} ({2}) on {3} ({4}).", _
             InterconnectIDInfo.TP1.Qualifier, _
             InterconnectIDInfo.TP1.ID.Trim, _
             InterconnectIDInfo.TP1.Description, _
             InterconnectIDInfo.TP1.NetworkName, _
             InterconnectIDInfo.TP1.NetworkID))
 
            Console.WriteLine([String].Format( _
            
" TP2: {0}*{1} ({2}) on {3} ({4}).", _
             InterconnectIDInfo.TP2.Qualifier, _
             InterconnectIDInfo.TP2.ID.Trim, _
             InterconnectIDInfo.TP2.Description, _
             InterconnectIDInfo.TP2.NetworkName, _
             InterconnectIDInfo.TP2.NetworkID))
 
            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(
"ECGridOSAddInterconnect <UserID> <Password>" & _
       " <ECGridID1> <ECGridID2> <ContactName> <ContactEMail>"
)
      Console.WriteLine(
" UserID - must be previously registered on ECGridOS")
      Console.WriteLine(
" Password - must be previously registered on ECGridOS")
      Console.WriteLine(
" ECGridID1 - the ECGridID in the User's Network/Mailbox")
      Console.WriteLine(
" ECGridID2 - the ECGridID for the Trading Partner on" & _
       " the VAN"
)
      Console.WriteLine(
" ContactName - the name of the person to receive" & _
       " e-mail notices for this Interconnect"
)
      Console.WriteLine(
" ContactEMail - the contact's e-mail address")
   End Sub
 
End
Module

See Also

Login()
Logout()
InterconnectAdd()

© 2008-2011, Loren Data Corp.
All rights reserved.
ECGrid is a registered service mark of Loren Data Corp.
ECGridOS is a service mark of Loren Data Corp.