是否可以通过研究窗格将自定义Web服务添加到Word 2010? [英] Is there a way to add custom web services to Word 2010 via the Research Pane?

查看:73
本文介绍了是否可以通过研究窗格将自定义Web服务添加到Word 2010?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道是否可以通过Microsoft Word 2010中的研究窗格"添加具有wsdl或asmx文件扩展名的自定义Web服务.我几乎搜索了具有这些服务的每个站点,但没有找到相应的说明.如果不是要在这里问一个人,我会比尝试和尝试更自信.

I have been wondering if I can add custom web services with the wsdl or asmx file extension via the Research Pane in Microsoft Word 2010. I have searched just about every site that has those services, but no luck finding instructions. Rather than trial and error, I felt more confident if I were to ask someone here.

基本上,我想做的是添加一个 http这样的网站://www.ebi.ac.uk/Tools/webservices/wsdl 或其他来源,并且能够通过研究窗格发送查询.

Basically, what I would like to be able to do is add a site like http://www.ebi.ac.uk/Tools/webservices/wsdl or some other source and be able to send queries via the research pane.

推荐答案

首先阅读本然后是下面的快捷方式(它并不完美,并且实际搜索未实现,但希望对您有所帮助)

Then the shortcut bellow (it's not perfect, and the actual search is not implemented, but I hope it helps)

1个服务界面

namespace CustomResearchServiceWCF {

[ServiceContract(Namespace="urn:Microsoft.Search")]
public interface IOfficeResearchService
{
    [OperationContract(Action = "urn:Microsoft.Search/Registration")]
    string Registration(string regXML);

    [OperationContract(Action = "urn:Microsoft.Search/Query")]
    string Query(string queryXml);
}

}

2实施

namespace CustomResearchServiceWCF
{

public class OfficeResearchService : IOfficeResearchService
{


    public string Registration(string regXML)
    {
        var providerUpdate = new ProviderUpdate();

        var writerSettings = new XmlWriterSettings {OmitXmlDeclaration = true,Indent=true};
        var stringWriter = new StringWriter();
        var serializer = new XmlSerializer(typeof(ProviderUpdate));
        using (var xmlWriter = XmlWriter.Create(stringWriter, writerSettings))
        {
            serializer.Serialize(xmlWriter, providerUpdate);
        }
        return stringWriter.ToString();

    }

    public string Query(string queryXml)
    {
        throw new NotImplementedException();
    }
  }}

3 ProviderUpdate,ResearchService和许可

3 ProviderUpdate, ResearchService and License

namespace CustomResearchServiceWCF
{

public class License
{
    [XmlAttribute(AttributeName = "acceptRequired")]
    public bool AcceptRequired;
    public string LicenseText { get; set; }

    public License()
    {
        LicenseText = "some licensing information";
        AcceptRequired = true;
    }
}

public class Provider
{
    public string Message { get; set; }
    public License License { get; set; }
    public string Id { get; set; }
    public string Name { get; set; }
    public string QueryPath { get; set; }
    public string RegistrationPath { get; set; }
    public string Type { get; set; }
    public string AboutPath { get; set; }
    [XmlAttribute]
    public string Action { get; set; }

    [DataMember]
    public List<ResearchService> Services;

    public Provider()
    {
        Type = "SOAP";
        License = new License();
        Services = new List<ResearchService>
                       {
                           new ResearchService
                               {
                                   Id = "{942F685E-0935-42c8-80C5-95DB0D129910}",
                                   Name = "Service",
                                   Description = "Custom Research Service",
                                   Copyright = "All content Copyright (c) 2003",
                                   Display = "ON"
                               }
                       };
    }
}



[XmlType("Service")]
public class ResearchService
{
    /// <summary>
    /// The GUID that is used when the Query function is called to differentiate a response from your Research service from a response from another Research service
    /// </summary>
    public string Id { get; set; }


    /// <summary>
    /// The name displayed in the Research task pane's Show Results From dropdown
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// //The description displayed in the Properties dialog box for the service
    /// </summary>
    public string Description { get; set; }

    public string Copyright { get; set; }

    //Either On or Off; indicates whether the service should be displayed in the Show Results From dropdown.
    public string Display { get; set; }


    /// <summary>
    /// The category with which the service should be grouped in the Show Results From dropdown and the Research options dialog box. See the Microsoft.Search.Registration.Response schema for a list of all the choices.
    /// </summary>
    public string Category { get; set; }

    public ResearchService()
    {
        Category = "RESEARCH_GENERAL";
    }
}


[XmlRoot(Namespace = "urn:Microsoft.Search.Registration.Response")]
public class ProviderUpdate
{
    public string Status { get; set; }

    public List<Provider> Providers;

    public ProviderUpdate()
    {
        Status = "SUCCESS";
        Providers = new List<Provider>
                        {
                            new Provider
                                {
                                    Message = "Congratulations! You've registered Research Pane Examples!",
                                    Action = "UPDATE",
                                    Id = "{942F685E-0935-42c8-80C5-95DB0D129910}",
                                    Name = "Wiktionary",
                                    QueryPath = "http://services.highbeam.com/office/office.asmx",
                                    RegistrationPath = "http://services.highbeam.com/office/office.asmx",
                                    AboutPath = "http://www.highbeam.com"
                                }
                        };
    }
}
}

这篇关于是否可以通过研究窗格将自定义Web服务添加到Word 2010?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆