sub getLanguagesForTranslate {
my ($self) = @_;
my $token = $self->getAccessToken();
my $soap = SOAP::Lite->proxy('http://api.microsofttranslator.com/V2/Soap.svc');
$soap->transport->http_request->header('Authorization' => $token);
my $answer = $soap->GetLanguagesForTranslate("appId" => "");
return $answer->result;
}
####
SOAP::Transport::HTTP::Client::send_receive: 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%3D1359323697%26Issuer%3Dhttps%253a%252f%252fdatamarket.accesscontrol.windows.net%252f%26HMACSHA256%3Dd4RTa2yAxgndSazm3Ikg0H%252bs3k24wua4rXqZvrUP90Y%253d
Content-Length: 505
Content-Type: text/xml; charset=utf-8
SOAPAction: "#GetLanguagesForTranslate"
appId
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error
Date: Sun, 27 Jan 2013 21:44:55 GMT
Content-Length: 723
Content-Type: text/xml; charset=utf-8
Client-Date: Sun, 27 Jan 2013 21:44:56 GMT
Client-Peer: 131.253.14.99:80
Client-Response-Num: 1
a:ActionNotSupportedThe message with Action '#GetLanguagesForTranslate' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
####
POST /V2/soap.svc HTTP/1.1
Host: api.microsofttranslator.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.10
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=BingTranslationTest&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=1359395243&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=a7cPdve2lE7kF5n3ZMMY8byf3p5SIMfrFpJpZird2Vw%3d Content-Type: text/xml; charset=utf-8
SOAPAction: "http://api.microsofttranslator.com/V2/LanguageService/GetLanguagesForTranslate"
Content-Length: 1462
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=BingTranslationTest&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=1359395243&Issuer=https%3a%2f%2fdatamarket.accesscontrol.windows.net%2f&HMACSHA256=a7cPdve2lE7kF5n3ZMMY8byf3p5SIMfrFpJpZird2Vw%3d
####
use SOAP::Lite;
$SOAP::Constants::DO_NOT_USE_CHARSET = 0;
$SOAP::Constants::PREFIX_ENV= "s";
$SOAP::Constants::DEFAULT_XML_SCHEMA = undef;
#Other code
sub getLanguagesForTranslate {
my ($self) = @_;
my $token = $self->getAccessToken();
my $soap = SOAP::Lite->proxy('http://api.microsofttranslator.com/V2/Soap.svc')
->on_action(sub {return '"http://api.microsofttranslator.com/V2/LanguageService/GetLanguagesForTranslate"'})
->readable(1)
->encodingStyle("")
->encoding(undef);
$soap->transport->http_request->header("Authorization" => $token);
my $method = SOAP::Data->name('GetLanguagesForTranslate')->attr({xmlns => 'http://api.microsofttranslator.com/V2'});
my @params = ( SOAP::Data->name("appId")->type("string")->value("")->type(""));
my $answer = $soap->call($method => @params);
return $answer->result->{string};
}