Welcome to Office Zealot Sign in | Join | Help

Building a Simple IBF solution - For Beginners, Part 5

This is the final article in the series of articles on "Building a simple IBF application - For Beginners". Here I wrap up this series of articles on demystifying IBF solution development by discussing the creation of smart document and developing the UI to render the results returned by our IBF compliant Web Service.

 

STEP 5: Develop the SmartTag Recognizer component to enable Office applications to recognize the name of our friends.

To keep this application simple, given below is a Word document (saved as XML) containing the smart tag recognizer for a Friend named “Harry”. The lines that distinguish this Word document from normal ones, have been formatted in bold italics. These are the lines, which can be added to a Word document that has been saved as XML and used to speed up the testing for the IBF applications, without the need to write a Smart tag recognizer.


To create a similar Word document, open a New Word doc, enter the name of a Friend say “Harry” and save it as XML. Close Word, add the lines in bold italics shown below into your document at the appropriate places and you are ready with the document containing the smart tag that can be used to invoke our GreetingService. When you reopen this document in Word, you should be able to see a smart-tag associated with the Friend name "Harry" .

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<?mso-application progid="Word.Document"?>

<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://schemas.microsoft.com/InformationBridge/2004" xmlns:st1="http://schemas.microsoft.com/InformationBridge/2004" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">

            <o:SmartTagType o:namespaceuri="http://schemas.microsoft.com/InformationBridge/2004" o:url="http://InformationBridge/CRM/SmartTag/" o:name="reference"/>

            <o:DocumentProperties>

            </o:DocumentProperties>

            <w:fonts>

                        <w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/>

            </w:fonts>

            <w:styles>

                        <w:versionOfBuiltInStylenames w:val="4"/>

                        <w:latentStyles w:defLockedState="off" w:latentStyleCount="156"/>

                        <w:style w:type="paragraph" w:default="on" w:styleId=" Normal ">

                                    <w:name w:val=" Normal "/>

                                    <w:rPr>

                                                <wx:font wx:val="Times New Roman"/>

                                                <w:sz w:val="24"/>

                                                <w:sz-cs w:val="24"/>

                                                <w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/>

                                    </w:rPr>

                        </w:style>

                        <w:style w:type="character" w:default="on" w:styleId="DefaultParagraphFont">

                                    <w:name w:val="Default Paragraph Font"/>

                                    <w:semiHidden/>

                        </w:style>

                        <w:style w:type="table" w:default="on" w:styleId="TableNormal">

                                    <w:name w:val="Normal Table"/>

                                    <wx:uiName wx:val="Table Normal"/>

                                    <w:semiHidden/>

                                    <w:rPr>

                                                <wx:font wx:val="Times New Roman"/>

                                    </w:rPr>

                                    <w:tblPr>

                                                <w:tblInd w:w="0" w:type="dxa"/>

                                                <w:tblCellMar>

                                                            <w:top w:w="0" w:type="dxa"/>

                                                            <w:left w:w="108" w:type="dxa"/>

                                                            <w:bottom w:w="0" w:type="dxa"/>

                                                            <w:right w:w="108" w:type="dxa"/>

                                                </w:tblCellMar>

                                    </w:tblPr>

                        </w:style>

                        <w:style w:type="list" w:default="on" w:styleId="NoList">

                                    <w:name w:val="No List"/>

                                    <w:semiHidden/>

                        </w:style>

            </w:styles>

            <w:docPr>

                        <w:view w:val="web"/>

                        <w:zoom w:percent="100"/>

                        <w:displayBackgroundShape/>

                        <w:doNotEmbedSystemFonts/>

                        <w:proofState w:spelling="clean" w:grammar="clean"/>

                        <w:attachedTemplate w:val=""/>

                        <w:defaultTabStop w:val="720"/>

                        <w:punctuationKerning/>

                        <w:characterSpacingControl w:val="DontCompress"/>

                        <w:optimizeForBrowser/>

                        <w:validateAgainstSchema/>

                        <w:saveInvalidXML w:val="off"/>

                        <w:ignoreMixedContent w:val="off"/>

                        <w:alwaysShowPlaceholderText w:val="off"/>

                        <w:compat>

                                    <w:breakWrappedTables/>

                                    <w:snapToGridInCell/>

                                    <w:wrapTextWithPunct/>

                                    <w:useAsianBreakRules/>

                                    <w:dontGrowAutofit/>

                        </w:compat>

            </w:docPr>

            <w:body>

                        <wx:sect>

                                    <w:p>

                                                <ns0:reference data="&lt;?xml version=&quot;1.0&quot;?&gt;&lt;ContextInformation xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; MetadataScopeName=&quot;http://InformationBridge/SayHello&quot; EntityName=&quot;Friend&quot; ViewName=&quot;GreetingMessage&quot; xmlns=&quot;http://schemas.microsoft.com/InformationBridge/2004/ContextInformation&quot;&gt;&lt;Reference&gt;&lt;Friend xmlns=&quot;urn-GreetingService-Data&quot; Name=&quot;Harry&quot; iwb:MetadataScopeName=&quot;http://InformationBridge/SayHello&quot; xmlns:iwb=&quot;http://schemas.microsoft.com/InformationBridge/2004&quot; iwb:EntityName=&quot;Friend&quot; iwb:ViewName=&quot;GreetingMessage&quot; /&gt;&lt;/Reference&gt;&lt;/ContextInformation&gt;" w:st="on">

                                                            <w:r>

                                                                        <w:t>Harry</w:t>

                                                            </w:r>

                                                </ns0:reference>

                                    </w:p>

                                    <w:sectPr>

                                                <w:pgSz w:w="12240" w:h="15840"/>

                                                <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="720" w:footer="720" w:gutter="0"/>

                                                <w:cols w:space="720"/>

                                                <w:docGrid w:line-pitch="360"/>

                                    </w:sectPr>

                        </wx:sect>

            </w:body>

</w:wordDocument>

 

Save the document as FriendTest.xml

 

STEP 6: Develop the UI to render the results returned by the IBF compliant Web service.

1) Create a new Windows Control Library project as shown below.



2) Rename UserControl1.cs to GreetingMessage.cs.


3) Drop a textbox in the form view for GreetingMessage.cs and name it “textBoxGreetingMessage”.


4) Right click the References folder and add the following references to the project as shown below



5) Switch to the code view and replace all occurrences of “UserControl1” with “GreetingMessage”.


6) At the top of the file add the following code to let the control know the namespaces that we will be using.

//Added for IBF

using System.Text;

using System.Xml;

using System.Xml.Serialization;

using Microsoft.InformationBridge.Framework.UI.Interop;

using Microsoft.InformationBridge.Framework.Interfaces;

 

7) Have the class GreetingMessage inherit from the interface IRegion as shown below

 

public class GreetingMessage : System.Windows.Forms.UserControl, IRegion

 

8) Add the following variable definitions

 

// Variables added for IBF.

private IVisualStyles _visualStyles;

private IRegionFrameProxy _frameProxy;

private FrameType _hostType;

 

9) Implement the interfaces defined in IRegion as shown below. For a detailed discussion of what these properties mean and their importance, please refer to the article “Building User Interfaces with the Information Bridge Framework”.

 

#region IRegion Members

 

/// <summary>

/// Load the dataNode and display it in the UserInterface.

/// </summary>

public XmlNode Data

{

      get

      {

            return null;

      }

      set

      {

            XmlNode dataNode = value;

            LoadXmlData(dataNode);

      }

}

 

/// <summary>

/// Gets/Sets a proxy to the Host of the AccountDetails region.

/// </summary>

public IRegionFrameProxy HostProxy

{

      set

      {

            this._frameProxy = value;

      }

      get

      {

            return this._frameProxy;

      }

}

 

/// <summary>

/// Gets/Sets the HostType

/// </summary>

public FrameType HostType

{

      set

      {

            this._hostType = value;

      }

      get

      {

            return this._hostType;

      }

}

 

/// <summary>

/// Gets/Sets the VisualStyle

/// </summary>

public IVisualStyles VisualStyle

{

      set

      {

            if (null != value)

            {

                  this._visualStyles = value;

            }

      }

      get

      {

            return this._visualStyles;

      }

}

#endregion

 

10) Finally, we provide the implementation for the function LoadXmlData referenced in the definition of Data property. Data property is set with the XML data returned by the IBF engine and it is here that we extract the data and give a call to LoadXmlData to place this data in the textbox element of our control. Given below is the implementation for our LoadXmlData function.

 

#region Loading XML Data

/// <summary>

/// Loads the Text into the User Interface

/// </summary>

/// <param name="aGreetingMessage">The XmlNode which holds the information to be displayed</param>

private void LoadXmlData(XmlNode aGreetingMessage)

{

      try

      {

            if (null != aGreetingMessage["EmptyResult"])

            {

                  textBoxGreetingMessage.Text = aGreetingMessage["EmptyResult"].InnerText;

            }

            else

            {

                  string salutation = (null == aGreetingMessage["Salutation"]) ? string.Empty : aGreetingMessage["Salutation"].InnerText;

                  string name = (null == aGreetingMessage["Name"]) ? string.Empty : aGreetingMessage["Name"].InnerText;

                  textBoxGreetingMessage.Text = salutation + " " + name;

            }

      }

      catch(XmlException ex)

      {

            Console.WriteLine ( ex.Message );

      }

     

}

#endregion

 

11) Right click the project and click on Build.


12) A successful build will generate the file “SayHello.UserInterface.dll” in the folder <Root>/SayHello.UserInterface/bin/Debug, where <Root> refers to the absolute path for the parent folder of your project.


13) Now we need to get back to Step 5 in the Part 4 of this series. This was the step where we had created a new operation named “ShowRegion”. Now that we have created the Assembly that will render the UI, we shall associate this assembly with the Port property of the operation ShowRegion. Double click the node [Add Port …] to open the Add Port dialog box and enter the values as show below.




Click OK to complete the port definition.


14) Expand the operations node, right click ShowRegion and open up the Properties page. From the dropdown list associated with “PortName” property select the recently created port “UIAssembly”. In this manner the IBF engine will understand that Assembly associated with the port “UIAssembly” needs to be used in the ShowRegion operation to render the output.


15) Publish the metadata to the IBF Metadata Service.


16)  Open FriendTest.xml and click “Show Details” menu item associated with the smart-tagged Friend name. This should open up the IBF task pane and send out the Greeting Message with the Friend name as shown below.



Finally, I would like to thank all the readers for providing positive and constructive feedback on these articles, which motivated me to continue and complete this series. Do let me know your comments, suggestions and corrections related to this series of articles. I will work on making these articles available as a single document for the ease of reading. So keep watching this space!!!

Published Sunday, August 29, 2004 12:47 AM by desai

Comments

# re: Building a Simple IBF solution - For Beginners, Part 5

Tuesday, August 31, 2004 3:44 PM by Anonymous
Great sample, with new releases like IBF each sample is a valuable resource !!

It would also be helpful if you would publish the final metadata xml file for this sample.

# re: Building a Simple IBF solution - For Beginners, Part 5

Tuesday, September 07, 2004 1:22 AM by Anonymous
truly helpful example !!
could you please add some explanations
on how i can run same scenario from attached schema document as an entry point and instead of smart tag.

# Error help?

Tuesday, October 26, 2004 10:43 PM by Anonymous
I tried this solution and I'm getting this error when I try to show details of the smart tag:

Error Message:
OperationInstance[ActionCommand(#1)|http://InformationBridge/SayHello|Friend|GreetingMessage|Display Greeting Messages|3(:ShowRegion)]: An error occurred when executing the input TransformationInstance for this Operation. TransformationInstance index: 1.


Any help would be greatly appreciated.

# Error while publishing

Wednesday, October 27, 2004 1:46 AM by Anonymous
I get the same error .. And publishing is also failing ... im getting

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/InformationBridge/2004/MetadataService/UpdateMetadata.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

can someone tell me what seems to be the problem

10x
Edi

# re: Building a Simple IBF solution - For Beginners, Part 5

Sunday, January 16, 2005 3:36 PM by Anonymous
I am getting a similar error. Let me execute it and post the error.

MessageBox

"Errors detected while executing the action: Display Greeting Message. Please look in the output window for details"

1:30:38 PM Error Message:
OperationInstance[ActionCommand(#1)|http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello|Friend|GreetingMessage|ViewLocator(FriendSchema)|1(:GetGreetingMessage)]: SoapException

Stack Trace:
Microsoft.InformationBridge.Framework.ExecutionEngine.EngineException: OperationInstance[ActionCommand(#1)|http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello|Friend|GreetingMessage|ViewLocator(FriendSchema)|1(:GetGreetingMessage)]: SoapException ---> System.Web.Services.Protocols.SoapException: Server was unable to process request. --> Object reference not set to an instance of an object.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult)
at Microsoft.InformationBridge.Framework.ExecutionEngine.EngineSoapClient.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.InformationBridge.Framework.ExecutionEngine.SoapOperation.ResponseCallback(IAsyncResult asynchronousResult)
--- End of inner exception stack trace ---

ERROR MESSAGE:

Error Message:
OperationInstance[ActionCommand(#1)|http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello|Friend|GreetingMessage|ViewLocator(FriendSchema)|1(:GetGreetingMessage)]: SoapException

Stack Trace:
Microsoft.InformationBridge.Framework.ExecutionEngine.EngineException: OperationInstance[ActionCommand(#1)|http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello">http://InformationBridge/SayHello|Friend|GreetingMessage|ViewLocator(FriendSchema)|1(:GetGreetingMessage)]: SoapException ---> System.Web.Services.Protocols.SoapException: Server was unable to process request. --> Object reference not set to an instance of an object.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult asyncResult)
at Microsoft.InformationBridge.Framework.ExecutionEngine.EngineSoapClient.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.InformationBridge.Framework.ExecutionEngine.SoapOperation.ResponseCallback(IAsyncResult asynchronousResult)
--- End of inner exception stack trace ---
Anonymous comments are disabled