Featured Post

SQL Query in SharePoint

The "FullTextSqlQuery" object's constructor requires an object that has context but don't be fooled. This context will no...

Wednesday, September 29, 2010

Word Research Pane Customisation Part 1

So you want to customise your research pane in word 2007? Here's how you do it:
  1. Create a webservice

    Your webservice should contain two web methods: "Registration" and "Query". They each accept and return a string. Please note that you will need to register the "Microsoft.Search" namespace in your webservice in order for this to work with word. This took a few hours of my time trying to figure it out :/

    Here is an example of the xml that your "Registration" method should return:

    <?xml version="1.0" encoding="utf-8"?>
    <ProviderUpdate xmlns="urn:Microsoft.Search.Registration.Response">
      <Status>SUCCESS</Status>
      <Providers>
        <Provider>
          <Message>Welcome to customising your research service</Message>
          <Id>{C37EE888-D74E-47e5-B113-BA613D87F0B2}</Id>
          <Name>My First Research Service</Name>
          <QueryPath>http://localhost:49375/Service1.asmx/Registration</QueryPath>
          <RegistrationPath>http://localhost:49375/Service1.asmx/Registration</RegistrationPath>
          <Type>SOAP</Type>
          <Services>
            <Service>
              <Id>{8DD063CA-94FC-4514-8D83-3B36B12432BE}</Id>
              <Name>My First Research Service</Name>
              <Description>My First Research Service</Description>
              <Copyright>(C) 2008</Copyright>
              <Display>On</Display>
              <Category>RESEARCH_GENERAL</Category>
            </Service>
          </Services>
        </Provider>
      </Providers>
    </ProviderUpdate>


    And here is an example of the xml that your "Query" method should return:

    <?xml version="1.0"?>
    <ResponsePacket providerRevision="1" xmlns="urn:Microsoft.Search.Response">
      <Response domain="{8DD063CA-94FC-4514-8D83-3B36B12432BE}">
        <QueryID>{AAF43E6E-FF3D-4F20-BE8C-7ED18546E7DB}</QueryID>
        <Range>
          <Results>
            <Document xmlns="urn:Microsoft.Search.Response.Document">
              <Title>Amy Kins Gardiner</Title>
              <DisplayUrl>http://amykinsgardiner.blogspot.com/</DisplayUrl>
              <Description>a blogspot from a kinners</Description>
            </Document>
            <Content xmlns="urn:Microsoft.Search.Response.Content">
              <Heading>
                <Text>Some Test Actions</Text>
                <Actions>
                  <Text>Do Action</Text>
                  <Insert />
                  <Copy />
                  <Data>Some Data</Data>
                </Actions>
              </Heading>
            </Content>
          </Results>
        </Range>
        <Status>SUCCESS</Status>
      </Response>
    </ResponsePacket>
  2.  Register your new webservice with word

    So once you have this webservice up and running and returning the correct xml data you can register your service with word. You can do this by going to the "Review" tab and clicking on the "Research" button. At the bottom of the Research Pane which has now just popped up there is a link called "Research Options". Click on this link and it should popup a dialog which has another button to "Add Services". Click on this button and you will be able to specify the url for your new webservice. It should then register your service and you will now be able to choose "My First Research Service" in the drop down list under the search box. You can now search from your service. Enjoy :)
     
So I was asked to check out some extra things around this research service and this is what I have discovered:

  1. Q: Can I use the Actions to insert word documents into the current document that is open?
    A: I think you can :) I saw two ways that could work. Firstly you could create VB smart tag COM object and reference these objects in your XML. But I hear the words COM and VB and my hair stands up sooo I didn't look any further there. Second option is to create Smart Tags inside a word add-in. Now this looks a lot cleaner and could be quite fun but we are trying to get around not installing add ons so until we decide to go this route I don't have anymore information on how to do this as of yet.
  2. Q: Could I send the contents of a word document through the XML to allow it to be inserted?
    A: Yes you could but there are some limitations that will stop you from wanting to do this. The limitation is that only plain text can be inserted. So no formatting, not even carriage returns can be send through :/ And from what I can tell there is a 65 000 character limitation - but this might not be accurate.
Happy research servicing :)

Thursday, September 23, 2010