Есть ли способ добавить пользовательские веб-службы в Word 2010 через область исследований? - PullRequest
1 голос
/ 01 июня 2011

Мне было интересно, могу ли я добавить пользовательские веб-сервисы с расширением файлов wsdl или asmx через панель исследований в Microsoft Word 2010. Я искал практически каждый сайт, на котором есть эти сервисы, но безрезультатно найти инструкции. Вместо проб и ошибок я чувствовал себя более уверенно, если бы спросил кого-то здесь.

По сути, я хотел бы добавить такой сайт, как http://www.ebi.ac.uk/Tools/webservices/wsdl или другой источник, и иметь возможность отправлять запросы через область исследований. Research Pane in Microsoft Word 2010 after unsuccessful addition

1 Ответ

2 голосов
/ 15 сентября 2011

Начните с прочтения этого http://msdn.microsoft.com/en-us/library/bb226691(v=office.11).aspx

Тогда ярлык ниже (он не идеален, и сам поиск не реализован, но я надеюсь, что это поможет)

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 и 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"
                                }
                        };
    }
}
}
...