Quantcast
Channel: Microsoft Translator User Forum (Including Bing Translator) forum
Viewing all articles
Browse latest Browse all 529

Bing Translation Api access via SOAP interface from Perl SOAP::Lite

$
0
0

Hello all!

I write perl module for access to Bing Translation Api - Lingua::Translate::Bing. I want to use SOAP interface, but i can't it do. I already read this page "How to Call a .NET-based Web Service Using the SOAP::Lite Perl Library" , but it did't help me.

For example, i tried code:

sub getLanguagesForTranslate {
    my ($self) = @_; 
    my $token = $self->getAccessToken();
     $SOAP::Constants::DO_NOT_USE_CHARSET = 1;
    my $soap = SOAP::Lite->ns('http://api.microsofttranslator.com', 'tns')
                         ->readable(1)
                         ->proxy('http://api.microsofttranslator.com/V2/Soap.svc')
                         ->on_action(sub {return '"http://api.microsofttranslator.com/V2/LanguageService/GetLanguagesForTranslate"'});

    $soap->transport->http_request->header("Authorization" => $token);
    my $method = SOAP::Data->name('GetLanguagesForTranslate')->attr({xmlns => 'http://api.microsofttranslator.com/V2/LanguageService'});
    my @params = ( SOAP::Data->name("appId")->type("string")->value("")); 
    my $answer = $soap->call($method => @params);
    return $answer->result;
}

but it return "Unhandled Service Exception".

My SOAP request with this code is:

POST http://api.microsofttranslator.com/V2/Soap.svc HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Authorization: Bearer http%253a%252f%252fschemas.xmlsoap.org%252fws%252f2005%252f05%252fidentity%252fclaims%252fnameidentifier%3DBingTranslationTest%26http%253a%252f%252fschemas.microsoft.com%252faccesscontrolservice%252f2010%252f07%252fclaims%252fidentityprovider%3Dhttps%253a%252f%252fdatamarket.accesscontrol.windows.net%252f%26Audience%3Dhttp%253a%252f%252fapi.microsofttranslator.com%26ExpiresOn%3D1359415215%26Issuer%3Dhttps%253a%252f%252fdatamarket.accesscontrol.windows.net%252f%26HMACSHA256%3Dog2suDViN3n7NCNakgXBjco%252f5OKhxSMNXvm8Ti4Q73U%253d
Content-Length: 622
Content-Type: text/xml
SOAPAction: "http://api.microsofttranslator.com/V2/LanguageService/GetLanguagesForTranslate"

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="http://api.microsofttranslator.com" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetLanguagesForTranslate xmlns="http://api.microsofttranslator.com/V2/LanguageService">
      <appId xsi:type="xsd:string" />
          </GetLanguagesForTranslate>
  </soap:Body>
</soap:Envelope>

Where i was wrong?

Thanks for you attention!


Viewing all articles
Browse latest Browse all 529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>