DTN ProphetX® Web Services

Visual Basic

This section contains notes to help in accessing ProphetX Web Services from a standalone program written in Visual Basic.

The steps to prepare the access to the web services can be summarized as follows:

The proxy is the piece of code that does the actual access to the web services on behalf of the client application. This proxy can be generated automatically using tools that read and analyze the WSDL to create the needed code.

The easiest way to access PXWeb from MS Visual Studio is to add a Service Reference for any of the URLs given in the examples below and write the rest of the client code using that reference.  As an alternative to using Visual Studio, Microsoft provides the svcutil.exe tool to create the proxy in C# or Visual Basic, this tool is part of the Windows SDK that can be downloaded from the vendor site.

Example (DTO)

XML Element in Response

A basic method for creating the proxy that returns an XML element is the following:

    svcutil.exe -language:vb -config:Test.exe.config 'https://pxweb.dtn.com/PXWebSvc/PXServiceDtoXml.svc?wsdl'

The above call creates these elements:

The name of the configuration file was specified in the call to svcutil assuming that the final name of the application executable would be Test.exe.

An example of the code of a basic main program is the following:

    Imports pxweb.dtn.telvent.com
    Imports System.Xml;

    Class Test
    
      ' Main program
      Shared Sub Main()
    
        ' Get proxy to access PXWeb
        Dim client as PXServiceDtoXmlClient = New PXServiceDtoXmlClient( "BasicHttp" )

        ' Prepare request object
        Dim request as GetQuoteSnapDto = New GetQuoteSnapDto()
        request.UserID = "user"
        request.Password = "pswd"
        request.Type = "F"
        request.Symbol = "UIS,MSFT,IBM"
    
        ' Call GetQuoteSnap and print response as a string
        Dim xml as XmlElement = client.GetQuoteSnap( request )
        Console.WriteLine( xml.InnerXml )
    
        ' Close access to PXWeb
        client.Close()
    
      End Sub
    End Class

To compile and execute use the VisualBasic compiler as follows:

    vbc Test.vb PXServiceDtoXml.vb
    Test.exe

XML String in Response

A basic method for creating the proxy that returns an XML string is the following:

    svcutil.exe -language:vb -config:Test.exe.config 'https://pxweb.dtn.com/PXWebSvc/PXServiceDto.svc?wsdl'

The previous code example can be modified to access the URL that returns an XML string by just replacing all references to PXServiceDtoXml with PXServiceDto and, of course, modify the code to handle the XML string returned.  The call to PXWeb would look like this:

    ...
    ' Call GetQuoteSnap and print response as a string
    Dim xml as string = client.GetQuoteSnap( request )
    Console.WriteLine( xml )
    ...

Example (STD)

XML Element in Response

A basic method for creating the proxy that returns an XML element is the following:

    svcutil.exe -language:vb -config:Test.exe.config 'https://pxweb.dtn.com/PXWebSvc/PXServiceStdXml.svc?wsdl'

The above call creates these elements:

The name of the configuration file was specified in the call to svcutil assuming that the final name of the application executable would be Test.exe.

An example of the code of a basic main program is the following:

    Imports pxweb.dtn.telvent.com
    Imports System.Xml;

    Class Test
    
      ' Main program
      Shared Sub Main()
    
        ' Get proxy to access PXWeb
        Dim client as PXServiceStdXmlClient = New PXServiceStdXmlClient( "BasicHttp" )
    
        ' Call GetQuoteSnap and print response as a string
        Dim xml as XmlElement = client.GetQuoteSnap( "user", "pswd", "F", "UIS,MSFT,IBM" )
        Console.WriteLine( xml.InnerXml )
    
        ' Close access to PXWeb
        client.Close()
    
      End Sub
    End Class

To compile and execute use the VisualBasic compiler as follows:

    vbc Test.vb PXServiceStdXml.vb
    Test.exe

XML String in Response

A basic method for creating the proxy that returns an XML string is the following:

    svcutil.exe -language:vb -config:Test.exe.config 'https://pxweb.dtn.com/PXWebSvc/PXServiceStd.svc?wsdl'

The previous code example can be modified to access the URL that returns an XML string by just replacing all references to PXServiceStdXml with PXServiceStd and, of course, modify the code to handle the XML string returned.  The call to PXWeb would look like this:

    ...
    ' Call GetQuoteSnap and print response as a string
    Dim xml as string = client.GetQuoteSnap( "user", "pswd", "F", "UIS,MSFT,IBM" )
    Console.WriteLine( xml )
    ...

Notes

Result Volume

The svcutil.exe tool creates a client side configuration file with default values to handle communications and the data transfer with the web services.  Depending on the amount of information requested, it is possible that this configuration file may need to be modified to accept higher data volume.

Because of the data volume, It is always recommended to specify the selection of FIDs that are needed instead of just requesting all the values.  However, if a high volume is expected the following configuration parameters may need to be increased:

System.Xml.XmlElement vs. System.Xml.Linq.XElement

When calling PXWeb to request an XML element using either PXServiceDtoXml or PXServiceStdXml, there are at least two different classes that can be used on the client side to receive the result.  The two classes are these:

Class Notes
System.Xml.XmlElement This is the default class used by svcutil.exe from Windows SDK.
System.Xml.Linq.XElement This is the default class used by Visual Studio 2010.

Although any of the two classes can be used to hold the XML response from PXWeb, it must be noted that the example code shown above may present the following error in Visual Studio:

	Error 1 Cannot implicitly convert type 'System.Xml.Linq.XElement' to 'System.Xml.XmlElement'

There are two options here: