using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Translator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnTranslate_Click(object sender, EventArgs e)
{
string strTranslatedText = null;
try
{
TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();
client = new TranslatorService.LanguageServiceClient();
strTranslatedText = client.Translate("b86b637103504cd4bdd4e1388a56e039", txtTraslatedFrom.Text, "", "en");
txtTranslatedText.Text = strTranslatedText;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_LanguageService" />
<binding name="BasicHttpBinding_LanguageService1" />
<binding name="BasicHttpBinding_LanguageService2" />
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_LanguageService"
address="http://api.microsofttranslator.com/V1/soap.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_LanguageService"
contract="TranslatorService.LanguageService" />
</client>
</system.serviceModel>
</configuration>
http://www.dotnetcurry.com/ShowArticle.aspx?ID=357
上面是一个创建Bing翻译的链接,我按照完全相同的步骤,但我的应用程序永远不会工作。我不知道为什么它说我的AppID无效,我花了一个小时才得到这个ID。你们知道我为这个应用程序获取正确ID的方式和地点吗?
答案 0 :(得分:-1)
几年前,(免费)App ID机制已被弃用。
要访问Microsoft Translator API(无论是文本还是语音),您需要获得Azure订阅并使用其中提供的密钥。每月有2M字符的免费套餐。如果您需要更多,则每M字符10美元起。
开始使用:https://www.microsoft.com/en-us/translator/getstarted.aspx