This is our code. It should run unmodified from the TWO database.
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
Public Class CustomerRetrieve
Public Function retrieveCustomer(ByVal strCustomerNumber As String) As String
'Instantiate an eConnectMethods object
Dim eConnectObject As New eConnectMethods
'**Create an eConnect requestor document that specifies a single customer**
'Create the requestor node
Dim myRequest As New eConnectOut()
With myRequest
.DOCTYPE = "Customer"
.OUTPUTTYPE = 1
.INDEX1FROM = strCustomerNumber
.INDEX1TO = strCustomerNumber
.FORLIST = 1
End With
'Create the requestor schema document type
'Since the eConnect document requires an array, create an
'array of RQeConnectOutType
Dim econnectOutType() As RQeConnectOutType = New RQeConnectOutType(0) {New RQeConnectOutType}
econnectOutType(0).eConnectOut = myRequest
'Create the eConnect document type
Dim eConnectDoc As New eConnectType()
eConnectDoc.RQeConnectOutType = econnectOutType
'**Serialize the eConnect document**
'Create a memory stream for the serialized eConnect document
Dim memStream As New MemoryStream()
'Create an Xml Serializer and serialize the eConnect document
'to the memory stream
Dim serializer As New XmlSerializer(GetType(eConnectType))
serializer.Serialize(memStream, eConnectDoc)
'Reset the position property to the start of the buffer
memStream.Position = 0
'**Load the serialized Xml into an Xml document**
Dim xmldoc As New XmlDocument()
xmldoc.Load(memStream)
'Create an eConnect connection string
Dim connectionString As String
connectionString = "data source=localhost; initial catalog=TWO;integrated security=SSPI; persist security info=False;packet size=4096"
'Retrieve the specified document
Dim oeConnectMethods As New eConnectMethods
Dim customerDoc = oeConnectMethods.GetEntity(connectionString, xmldoc.OuterXml)
Return customerDoc
End Function
End Class