初めての質問者です。.NET上のベンダーAPIにインタフェースするPerl SOAP :: Lite
私は、Perlと私たちのベンダーの1つであるLogRhythmが提供するSOAP APIとのインターフェースに取り組んでおり、少しのロードブロックを打ったようです。
私はAPIとのインターフェイスができており、もともと遭遇した認証の問題を克服しました。 SOAP呼び出しにパラメータを渡す必要があるときに、SOAP Envelope Bodyで名前空間のタグ付けに問題が発生しています。
ベンダーが提供するAPIは、.NETとWCFをベースにしています。
私のプロトタイプのコードは、現在、以下のようになります。
SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.logrhythm.com/webservices"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>reporting</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tns:GetClassificationsByType>
<classificationType xsi:type="xsd:int">2000</classificationType>
<classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
</tns:GetClassificationsByType>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
結果を返しません:
use strict;
no strict "refs";
use Data::Dumper;
use IO::Socket::SSL qw (SSL_VERIFY_NONE) ;
use SOAP::Lite;
use Tie::IxHash;
# Username and Password
my $sUID = "<API UserID>";
my $sPWD = "<API Password>";
# WSDL definition URI. Using a cached local copy using file:/... also works
my $LookupService_wsdl = 'https://melcapi01.soc.ipsec.net.au/LogRhythm.API/Services/LookupServiceBasicAuth.svc?singleWsdl';
my $lrns = 'http://www.logrhythm.com/webservices';
# Ensure that a consistent xmlns:soap value is used, without this we get inconsistent results.
$SOAP::Constants::PREFIX_ENV = 'SOAP-ENV';
# Don't validate SSL Certificate while testing
IO::Socket::SSL::set_defaults(SSL_verify_mode => "SSL_VERIFY_NONE");
# Construct the security header
my %authHash;
tie %authHash, "Tie::IxHash";
%authHash = (
Username => SOAP::Data->type('' => $sUID)->prefix('wsse'),
Password => SOAP::Data->type('' => $sPWD)->prefix('wsse'),
);
my $wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
my $securityHeader = SOAP::Header->new(
name => 'Security',
uri => $wsse,
prefix => 'wsse',
value => \SOAP::Data->new(
name => 'UsernameToken',
prefix => 'wsse',
value => \%authHash,
)
);
# Error handling
on_fault => sub { my($soap, $res) = @_;
die ref $res ? $res->faultstring : $soap->transport->status;
};
# Define the SOAP Instance
my $lrapi = SOAP::Lite
-> readable (1)
-> service($LookupService_wsdl)
-> on_action(sub {return $action});
# Set the default Namespace
$lrapi->default_ns($lrns);
# Actually get data from the LookupService
my $result;
# Build up the parameters
my @classificationType = (SOAP::Data->new(name =>'classificationType', value => 2000));
$result = $lrapi->GetClassificationsByType($securityHeader);
print Dumper $result;
これは、次のSOAPリクエストになります。 .NET WebService Studioを使用してDoctorとRequest Doctorを行ったところ、問題がSOAP Bodyの要素のxmlns識別子が見つからないことが原因であることが判明しました。
SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.logrhythm.com/webservices"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>reporting</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tns:GetClassificationsByType xmlns="http://www.logrhythm.com/webservices">
<classificationType xsi:type="xsd:int">2000</classificationType>
<classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
</tns:GetClassificationsByType>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
様々なサポートリクエストは、これは、手動でSOAP :: Liteのオブジェクトにdefault_ns
を設定することによって解決されるべきであることを示している、しかし、これは私のために働いていません。
SOAPリクエストは、次のようになります。 。
私は何が起こっているかを確認するためにSOAP::Lite(1.20)のソースを掘り行っている、そしてSOAPメソッド呼び出しを行う前に1
に設定されている{'_use_default_ns'}
プロパティは、処理中に0
にリセットされますように見えるようですコールの
また、call()
メソッドを使用して目的の結果を得るために、手動でSOAP :: Liteオブジェクトを作成しようとしましたが、私は自動ネームスペースの数に問題があります。現在使用しているservice()
のメカニズムの結果として追加されました。 call()
メソッドを使用する場合は、service()
を使用してオブジェクトを設定できないようです。
私はこの時点で迷っているので、私は誰か他の提案をしていますか?
ご協力いただければ幸いです。
免責事項:私はプログラマー/デベロッパーではなく、プログラミング能力のあるシニアセキュリティエンジニア/コンサルタント/アーキテクトですので、コードがひどく構成されている場合は事前にお詫びします。これはSOAPを手に入れた最初の試みです。
これは顧客のためのものですか?ソリューションの汚れはどれくらい快適でしょうか?あなたのコードは 'use warnings'を持っていませんが、私の評価は非常に乱雑ではないということです。それは単にSOAP :: Liteであり、現実のPerlのようには見えません。 – simbabque
LogRhythm APIのドキュメントはひどいだけではなく、まったく誤解を招くものです。いくつかの関数が、文書化されたものとは全く異なる順序で引数を取ることを期待する。 –