MicrosoftTranslator API - Soap-Translate,-GetTranslations,-GetLanguageNames于2015年9月停止工作 [英] Microsofttranslator API - Soap-Translate, -GetTranslations, -GetLanguageNames ceased working in Sept 2015
问题描述
请求帮助
我的问题:
我的VBA申请表使用各种SOAP方法翻译文章文本的Excel在2015年9月之后在适当的情况下工作了大约2年后仍然停止工作 - 问题在至少2种不同的配置上是相同的 - W7 / O2013(32),
XP / O2003
SOAP方法不再适用于即将出现的错误消息:
(从德语自由翻译的错误文本)
wsm_Translate - 将文本字符串从一种语言转换为另一种语言。
$
错误:-2147221504(80040000)客户端:SOAP请求的参数数量错误
wsm_GetTranslations - 返回给定文本的替代翻译数组。
错误:-2147221504(80040000)SoapMapper:保存SoapMapper时出错"选项"
$
wsm_GetLanguageNames - 获取翻译服务支持的语言名称列表。错误:2147221504(80040000)SOAP请求的参数数量错误。
仍在使用的SOAP方法(其他未提及的 - >未使用):
wsm_BreakSentences - 返回给定文本的每个句子的句子长度数组
wsm_Detect - 检测所选文本的语言。
wsm_DetectArray - 检测字符串数组的语言。
wsm_GetLanguagesForSpeak - 获取Speech Synthesis支持的语言代码列表。
wsm_GetLanguagesForTranslate - 获取语言代码列表翻译服务支持。
"翻译"通过HTTP访问工作!
我现在正在工作的SOAP翻译程序:
Private Sub TestXtranslate()
Dim Str As String
  Str = Xtranslate("Dies ist einzuübersetzenderText","de","fr"))
结束子
$
函数Xtranslate(textToTranslate As String,FromLanguage As String,ToLanguage As String)_
                 作为字符串
'翻译" textToTranslate"判刑_
Dim s As New clsws_SoapService
Dim Sentences()As Long,i As Long,StrBeg As Long,StrLen As Long
Dim Temp1 As String,Temp2 As String,Temp3 As String,AccessToken As String
'退出空字符串以翻译
 如果textToTranslate =""然后退出功能
'获取"旧的"永久或未过期的新访问令牌
  AppID = GetAppID
''替换网址编码保留字符,例如&&"按"%26"为"
" textToTranslate = URLEncode(textToTranslate)
'使用"textToTranslate"中的句子长度获取Long-Array
  Sentences = s.wsm_BreakSentences(AppID,textToTranslate,FromLanguage)
'每句话翻译
 因为i = LBound(句子)到UBound(句子)
     如果i = 0则StrBeg = 1 Else StrBeg = StrBeg + Sentences(i - 1)
      StrLen =句子(i)
      Temp1 = Mid(textToTranslate,StrBeg,StrLen)
      AppID = GetAppID
      Temp2 = s.wsm_Translate(AppID,Temp1,FromLanguage,ToLanguage,_
" text / plain"," general")
  '组装原始的完整字符串
      Temp3 = Temp3& Temp2
 接下来我是
'对翻译的句子串做一些处理
  Xtranslate = Temp3
''替换网址编码保留字符,例如"%26""通过"&"按
'' Xtranslate = URLDecode(Xtranslate)
'替换字符串,如"& gt; "由翻译人员为数学运算符返回,例如">"和
  Xtranslate = CharEntityRefToChar(Xtranslate)
'将第一个String字母设置为大写
  Xtranslate = UCase(左(Xtranslate,1))& Mid(Xtranslate,2)
结束功能
$
Soap Translate Call with parameters
      Temp2 = s.wsm_Translate(AppID,Temp1,FromLanguage,ToLanguage,_
" text / plain"," general")
AppID =" Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier = Swisscom_Switzerland_GBS-SCM-SOP- DVC&安培; HTTP%3A%2F%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider = HTTPS%3A%2F%2fdatamarket.accesscontrol.windows.net%2F&安培;观众= HTTP%3A%2F%2fapi。 microsofttranslator.com& ExpiresOn = 1443791609& Issuer = https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f& HMACSHA256 = 0QHT6eYz98gcL1YU30%2fwN%2bcWMcKbrgdj0m2a3%2fDVc8U%3d" b
Temp1 =" Dies ist einzuübersetzenderText"
FromLanguage =" de" b $ b $ toLanguage =" fr"
P5 =" text / plain" b $ b P6 =" general"
(上面的AppID工作到现在为止 - 我也是取代了现在使用的客户名称"Swisscom_Switzerland_GBS-SCM-SOP-DVC"。使用7738a85e -...形式的较新Client-ID但没有任何影响)
更正10月23日 - 20:00 :上述括号 - 备注完全不正确 - 凭证永远不会改变。在申请注册时收到的那些仍然有效,从未改变,仍然可以正常工作。
这里出现错误的Translate-SOAP函数:
公共函数wsm_Translate(ByVal str_appId As String,ByVal str_text作为String,_
ByVal str_from As String,ByVal str_to As String,ByVal str_contentType As String,_
ByVal str_category As String)As字符串
'**************************************** *************************
'从http://api.microsofttranslator.com/V2/创建的代理功能SOAP.svc。
'************************************* ****************************
  '错误陷阱
  On Error GoTo wsm_TranslateTrap
  wsm_Translate = sc_SoapService.Translate(str_appId,str_text,str_from,str_to,_
str_contentType,str_category)
退出功能
wsm_TranslateTrap:
  SoapServiceErrorHandler" wsm_Translate"
结束功能
$
任何帮助非常非常感谢
亲切的问候
Hans-Ulrich Bartlome
您好Hans-Ulrich,
您说得对,我们已添加API中的一些可选 参数。
- 翻译:reservedFlags
- GetLanguageNames:UseSpokenVariant
您现在应该在这些参数中包含默认值(reservedFlags - > null和UseSpokenVariant - > false)。
我们向后兼容。即如果你一直在使用旧的/现有代理,它将继续工作。
Olivier
Request for Help
My Problem:
My VBA-application for Excel using various SOAP-methods for the translation of article-texts ceased working for some methods during Sept 2015 after working properly for approx 2 years - the problem is the same on at least 2 different configurations - W7/O2013(32),
XP/O2003
The SOAP methods not working anymore with the upcoming error messages are:
(Error texts freely translated from German)
wsm_Translate - Converts a text string from one language to another.
Error: -2147221504 (80040000) Client: wrong number of parameters for SOAP-request
wsm_GetTranslations - Returns an array of alternative translations of the given text.
Error: -2147221504 (80040000) SoapMapper: Error at saving of SoapMapper "options"
wsm_GetLanguageNames - Get list of language names supported by the Translator Service. Error: 2147221504 (80040000) wrong number of parameters for SOAP-request.
Still working SOAP methods (other not mentioned ones -> not used):
wsm_BreakSentences - Returns an array of sentence lengths for each sentence of the given text
wsm_Detect - Detects the language of a selection of text.
wsm_DetectArray - Detects the language of an array of strings.
wsm_GetLanguagesForSpeak - Get list of language codes supported by Speech Synthesis.
wsm_GetLanguagesForTranslate - Get list of language codes supported by the Translator Service.
"Translate" works via HTTP access!
My up-to-now-working-SOAP-Translation procedures:
Private Sub TestXtranslate()
Dim Str As String
Str = Xtranslate("Dies ist ein zu übersetzender Text", "de", "fr")
End Sub
Function Xtranslate(textToTranslate As String, FromLanguage As String, ToLanguage As String) _
As String
'Translates "textToTranslate" sentence-wise
Dim s As New clsws_SoapService
Dim Sentences() As Long, i As Long, StrBeg As Long, StrLen As Long
Dim Temp1 As String, Temp2 As String, Temp3 As String, AccessToken As String
'Exit on empty string to translate
If textToTranslate = "" Then Exit Function
'Get "old" everlasting or not expired new access token
AppID = GetAppID
''Replace URL-encoding reserved characters like "&" by "%26"
' textToTranslate = URLEncode(textToTranslate)
'Get Long-Array with lengths of sentences within "textToTranslate"
Sentences = s.wsm_BreakSentences(AppID, textToTranslate, FromLanguage)
'Do translation per sentence
For i = LBound(Sentences) To UBound(Sentences)
If i = 0 Then StrBeg = 1 Else StrBeg = StrBeg + Sentences(i - 1)
StrLen = Sentences(i)
Temp1 = Mid(textToTranslate, StrBeg, StrLen)
AppID = GetAppID
Temp2 = s.wsm_Translate(AppID, Temp1, FromLanguage, ToLanguage, _
"text/plain", "general")
'Assemble back the original full string
Temp3 = Temp3 & Temp2
Next i
'Do some processing on translated string of sentences
Xtranslate = Temp3
''Replace URL-encoding reserved characters like "%26" by "&"
'' Xtranslate = URLDecode(Xtranslate)
'Replace strings like "> " returned by translator for mathematical operators like ">"
Xtranslate = CharEntityRefToChar(Xtranslate)
'Set first Letter of String to uppercase
Xtranslate = UCase(Left(Xtranslate, 1)) & Mid(Xtranslate, 2)
End Function
Soap Translate Call with parameters
Temp2 = s.wsm_Translate(AppID, Temp1, FromLanguage, ToLanguage, _
"text/plain", "general")
AppID = "Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=Swisscom_Switzerland_GBS-SCM-SOP-DVC&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&Audience=http%3a%2f%2fapi.microsofttranslator.com&ExpiresOn=1443791609&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=0QHT6eYz98gcL1YU30%2fwN%2bcWMcKbrgdj0m2a3%2fDVc8U%3d"
Temp1 = "Dies ist ein zu übersetzender Text"
FromLanguage = "de"
ToLanguage = "fr"
P5 = "text/plain"
P6 = "general"
(the above AppID was working till now - I also replaced the up-to-now-used Client-Name "Swisscom_Switzerland_GBS-SCM-SOP-DVC" with the newer Client-ID in the form 7738a85e-... but without having any impact)
Correction Oct 23 - 20:00: the above parenthesis-remark is simply incorrect - the credentials never changed. The ones received at application-registration-time are still valid, never changed and still work fine.
Here the Translate-SOAP function where the error occurs:
Public Function wsm_Translate(ByVal str_appId As String, ByVal str_text As String, _
ByVal str_from As String, ByVal str_to As String, ByVal str_contentType As String, _
ByVal str_category As String) As String
'*****************************************************************
'Proxy function created from http://api.microsofttranslator.com/V2/SOAP.svc.
'*****************************************************************
'Error Trap
On Error GoTo wsm_TranslateTrap
wsm_Translate = sc_SoapService.Translate(str_appId, str_text, str_from, str_to, _
str_contentType, str_category)
Exit Function
wsm_TranslateTrap:
SoapServiceErrorHandler "wsm_Translate"
End Function
Any help very much appreciated
Kind regards
Hans-Ulrich Bartlome
Hi Hans-Ulrich,
You are right, we added a few optional parameters in the APIs.
- Translate: reservedFlags
- GetLanguageNames: UseSpokenVariant
You should now include the default values (reservedFlags ->null and UseSpokenVariant -> false) to these parameters.
We are backwards compatible. i.e. if you have been using the old/existing proxy it would continue to work.
Olivier
这篇关于MicrosoftTranslator API - Soap-Translate,-GetTranslations,-GetLanguageNames于2015年9月停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!