Connected Services Framework 3.0 - Order Handling Standard Business Event Send comments on this topic.
Submitting Orders

To submit orders to the Order Handling Standard Business Event (OHSBE), you must create a client service or application that prepares input from your order management system. This input can come from a user interface or through a mechanism that captures information from your order management system. In either case, you must turn the input into text so that you can manipulate it as a string and submit the request to the OHSBE. The example in this topic assumes that you are using a Windows form to send the SubmitOrderRequest to the OHSBE.

Note. When you send an order message to the OHSBE with the default OHSBE message, such as the shared information data (SID) SubmitOrderRequest message, you must use the usernameOverTransportSecurity Web Services Enhancements (WSE) policy to secure it. Although the OHSBE uses the custom dynamicSecurity WSE policy, which enables the OHSBE to handle messages that are secured with either usernameOverTransportSecurity or kerberosSecurity, the default OrderManagerLibrary assumes that the default SID messages contain a UsernameToken in their message headers.

To use KerberosToken, you must create a custom OrderManagerLibrary that does not assume that the incoming message has a UsernameToken in its header.

The default SID-based SubmitOrderRequest message is designed to provide compatibility with the CSF 2.5 OHSBE SubmitOrderRequest message.

To submit an order to the OHSBE, perform the following steps:

  1. Create the types that are required to compose and send the SubmitOrderRequest message to the OHSBE:

    1. In the Windows Form designer, create a Windows form and add a text box control, m_input, and a button control, m_sendRequest (replace m_input and m_sendRequest to names that are appropriate for your application.)
    2. Add the following using directives to your code:

      using System;
      using System.Windows.Forms; 
      using System.Collections;
      using System.ComponentModel;
      using System.Data;
      using Microsoft.Web.Services3.Addressing;
      using Microsoft.Web.Services3.Messaging;
      using Microsoft.Web.Services3;
      using System.IO;
      using System.Text;


      using Microsoft.Web.Services3.Design;
      using Microsoft.ConnectedServices.Sdk.Messaging;

    3. Enclose the types in a namespace (replace OHSBEClientNameSpace with a namespace that meets your naming guidelines):

      namespace OHSBEClientNameSpace

    4. Declare a class that inherits the System.Windows.Forms.Form class:

      public class OHSBEClient : System.Windows.Forms.Form
      {
      // Replace and add to this section according to specific requirements.
      }

    5. Declare a class that inherits the Microsoft.ConnectedServices.Sdk.Messaging.CsfService class:

      public class OHSBESender : CsfService
      {
      // Replace and add to this section according to specific requirements.
      }

    6. Declare an internal class that contains methods that perform XML serialization and deserialization:

      internal class SerializationHelper
      {
      // Replace and add to this section according to specific requirements.
      }

  2. Add a method to the SerializationHelper class to turn an incoming string to XML that follows the SubmitOrderRequest schema:

    1. Add the following using declarations to your code:

      using Microsoft.ConnectedServices.Sbe.OrderHandling.Utilities;
      using Microsoft.ConnectedServices.Sbe.OrderHandling;
      using Microsoft.ConnectedServices.Sbe.OrderHandling.Messages;
      using Microsoft.ConnectedServices.Sbe.OrderHandling.SIDMessages;
      using Microsoft.ConnectedServices.Sbe.OrderHandling.Threading;
      using System.Xml;
      using System.Xml.Serialization;

    2. Declare a static method in the SerializationHelper class that deserializes an incoming string to the SubmitOrderRequest type and returns the SubmitOrderRequest.

      public static SubmitOrderRequest MakeSubmitRequest(string req)
      {
        StringReader sReader = new StringReader(req);
        XmlTextReader aReader = new XmlTextReader(sReader);
        XmlSerializer ser = new XmlSerializer(typeof(SubmitOrderRequest));
        SubmitOrderRequest sub = (SubmitOrderRequest)ser.Deserialize(aReader);
        return sub;
      }

  3. Add a method to the client class that captures the request information from the form and converts it to a SubmitOrderRequest object by using the method you defined in step 2.

    private  SubmitOrderRequest LoadSubmitRequest()
      return SerializationHelper.MakeSubmitRequest(m_input.Text);
    }

  4. Add a method to the sender class that constructs the message to send to the OHSBE.

    public void SendSubmitRequest(SubmitOrderRequest req)
    {
      try
      {
        Microsoft.ConnectedServices.Sdk.Header head = new Microsoft.ConnectedServices.Sdk.Header();
        head.Addressing = new Microsoft.ConnectedServices.Sdk.Addressing.AddressingHeaders();
        head.Addressing.To = new Uri(m_sc.m_to);
        head.Addressing.From = new Microsoft.ConnectedServices.Sdk.Addressing.EndpointReference(m_from);
        head.Addressing.Action = " http://Microsoft/ConnectedServices/2006/06/SBE/OrderHandling/SubmitOrderRequest";
        Microsoft.ConnectedServices.Sdk.Message m = Microsoft.ConnectedServices.Sdk.Message.CreateMessage(head, req);
        Microsoft.ConnectedServices.Sdk.Client.MessageSender ms = new Microsoft.ConnectedServices.Sdk.Client.MessageSender();
        provider = new SecurityPolicyProvider(m_sc.m_policyFile, m_sc.m_policyName);
        Policy policy = provider.GetServicePolicy(m_sc.m_policyName, new Microsoft.ConnectedServices.Sdk.Security.Tokens.UsernameToken(m_sc.m_userBox.Text, m_sc.m_passBox.Text, Microsoft.ConnectedServices.Sdk.Security.Tokens.PasswordOption.SendPlainText));
        if (policy != null)
          ms.SetPolicy(policy);
        ms.SendAsync(m);
      catch(Exception ex)
      {
        MessageBox.Show(ex.Message);
      }
    }

  5. Add an event handler method to the client class that calls the method defined in step 4.

    private void m_sendRequest_Click(object sender, System.EventArgs e)
    {
      m_fromBox.Enabled = false;
      m_cancelFromBox.Enabled = false;
      m_terminateFromBox.Enabled = false;
      m_from = m_fromBox.Text;
      m_to = m_toBox.Text;
      m_policyFile = PolicyFile.Text;
      m_policyName = PolicyName.Text;
      if(m_sender == null)
        m_sender = new TestSender(this);
      m_sender.SendSubmitRequest(LoadSubmitRequest());
    }

    For a complete working sample of the SubmitOrder action, see the MockOssClient sample installed in the OHSBE_Sample_Code directory.
Page view tracker