Calling an XML Web Service from an AIC

Calling an XML Web Service from an AIC

This section describes the steps required for an AIC to call an XML Web service.

Update the resource file

Create a C# class project in Microsoft Visual Studio .NET for the AIC that calls the XML Web service. View the Reference.cs file to ensure that the XMLRoot information contained in this class is correct, and that the structure matches the class in the original .cs file created for the XML Web service.

To view and update the Reference.cs file

  1. In the Solution Explorer, click Show All Files.
  2. Expand Web References, expand the name of the XML Web service host, expand, and then double-click Reference.cs.
  3. Every element in the XML file has been converted to a public class. Search for the root element in the XML file.

    The root element appears as:

    [System.Xml.Serialization.XmlAttribute( Namespace= )] public class RootElementName { 
  4. Change this to the following:
    [System.Xml.Serialization.XmlRoot( RootElementName )] public class RootElementName { 

    Where RootElementName is the name of the document s root element.

  5. Repeat steps 3 and 4 for every element in the document.
Add a reference to the XML Web service

The AIC project must contain a reference to access the XML Web service remotely. After this reference is made, the project acts as a client to that XML Web service. For example:

// Reference to the hub XML Web service using Supp_send_invoice.localhost; 
Implement the IBTSAppIntegration.ProcessMessage method

To indicate that the project is an AIC, the code must implement the ProcessMessage method on the IBTSAppIntegration interface.

The following example is from the supplier's client code that sends an invoice to the hub XML Web service:

string IBTSAppIntegration.ProcessMessage(string strDocument) { // The incoming string is CommonInvoice, convert the // xml string into an object by deserializing it     CommonInvoice invoice;     XmlSerializer serializer = new XmlSerializer(typeof(CommonInvoice));     TextReader stringstream = new StringReader(strDocument);     invoice = ((CommonInvoice)serializer.Deserialize(stringstream)); // Open up the hub XML Web service     Hub_services web_service = new Hub_services(); // Process the order     string result = web_service.Process_invoice(invoice);     web_service = null;     return result; }
Register the AIC for use with COM

When creating your AIC project in Microsoft Visual Studio .NET, you might want to use a fixed GUID value to maintain binary compatibility. Otherwise, the GUID for the component changes every time you compile the code. In that case, any references to this component would have to be rebound in your XLANG schedules.

The following procedure assigns a static GUID value to the component and registers the AIC for COM interoperability:

  1. Add the following reference to your project:
    using System.Runtime.InteropServices; 
  2. Just before the class declaration in your project, add the GUID declaration (shown in bold):
    [Guid( )] public class AIC_name : IBTSAppIntegration 

    Note   The "Guid" literal string shown above is case-sensitive.

  3. On the Tools menu, click Create GUID.

    The Create GUID dialog box appears.

  4. Select option 4, Registry Format, click Copy, and then click Exit.
  5. Place your cursor between the quotes in the [Guid( )] declaration and paste in the GUID value.
  6. In the Solution Explorer pane, right-click the project and then click Properties.

    The project Property Pages dialog box appears.

  7. Click the Configuration Properties folder in the left pane.
  8. On the Configuration drop-down menu, click All Configurations.
  9. Change the value of the Register for COM interop property to True.
Previous  Next

Microsoft Corporation - Microsoft. Net Server Solutions for the Enterprise
Microsoft .NET Server Solutions for the Enterprise
ISBN: 0735615691
EAN: 2147483647
Year: 2002
Pages: 483 © 2008-2017.
If you may any questions please contact us: