WSSE与XML::Compile::SOAP::WSS和Perl
因此,我在向SOAP请求添加wsse头时遇到了一些问题WSSE与XML::Compile::SOAP::WSS和Perl,xml,perl,soap,Xml,Perl,Soap,因此,我在向SOAP请求添加wsse头时遇到了一些问题 #!/usr/bin/perl use 5.010; use strict; use warnings; use Env qw( CYBS_ID CYBS_KEY ); use XML::Compile::Util qw( pack_type ); use XML::Compile::WSDL11; use XML::Compile::SOAP::WSS; use XML::Compile::SOAP11; use XML::Compile
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use Env qw( CYBS_ID CYBS_KEY );
use XML::Compile::Util qw( pack_type );
use XML::Compile::WSDL11;
use XML::Compile::SOAP::WSS;
use XML::Compile::SOAP11;
use XML::Compile::Transport::SOAPHTTP;
my $soap = XML::Compile::SOAP11::Client->new;
my $wsdl = XML::Compile::WSDL11->new(
'CyberSourceTransaction_1.62.wsdl'
);
$wsdl->importDefinitions('CyberSourceTransaction_1.62.xsd');
my $call = $wsdl->compileClient( operation => 'runTransaction');
my ( $answer, $trace ) = $call->(
wsse_Security => {
version => '1.1',
schema => {
Username => $CYBS_ID,
}
},
merchantID => $CYBS_ID,
merchantReferenceCode => '42',
);
say $trace->printRequest;
这是我得到的输出
mistake: tag `wsse_Security' not used at {urn:schemas-cybersource-com:transaction-data-1.62}requestMessage
warning: Internal Server Error
Request:
POST https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor HTTP/1.1
User-Agent: libwww-perl/6.02
Content-Length: 381
Content-Type: text/xml; charset="utf-8"
SOAPAction: "runTransaction"
X-LWP-Version: 6.02
X-XML-Compile-Cache-Version: 0.991
X-XML-Compile-SOAP-Version: 2.24
X-XML-Compile-Version: 1.22
X-XML-LibXML-Version: 1.84
以及生成的xml
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><data:requestMessage xmlns:data="urn:schemas-cybersource-com:transaction-data-1.62"><data:merchantID>obfuscated</data:merchantID><data:merchantReferenceCode>42</data:merchantReferenceCode></data:requestMessage></SOAP-ENV:Body></SOAP-ENV:Envelope>
早些时候,我尝试了一个my$wss…
code。。。但这也不起作用
这是我试图生成的实际请求
<?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"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">obfuscated</wsse:Password>
<wsse:Username>obfuscated</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.61">
<merchantID>obfuscated</merchantID>
<merchantReferenceCode>404</merchantReferenceCode>
</requestMessage>
</soap:Body>
</soap:Envelope>
其中
foo
等于我尝试使用的任何标记。我在发行版中添加了示例,以演示如何做到这一点。此外,我还添加了一个方法,可以帮助您生成这种特定的登录方式。作为版本发布
最后更新:soap信封标签没有关闭。@Wivani哦,是的。。那是我剪下身体的时候说的。。。因为从理论上讲,它不应该与我试图在头中执行的操作相关。。你试过在SoapUI这样的客户机上使用它吗?@wivani我有一个实际工作的SOAP::Lite实现,但是SOAP::Lite没有我想要的一些好东西。很好,你设法与Mark取得了联系。我将删除我的答案和评论,以避免混乱。干杯请注意,$wss对象必须使用
(…,schema=>$wsdl)
构造,或者在调用wsseBasicAuth
之前必须调用$wss->loadSchemas($wsdl)
<?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"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">obfuscated</wsse:Password>
<wsse:Username>obfuscated</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.61">
<merchantID>obfuscated</merchantID>
<merchantReferenceCode>404</merchantReferenceCode>
</requestMessage>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/></SOAP-ENV:Header>
mistake: tag `foo' not used at {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security
my $call = $wsdl->compileClient($operation);
my $security = $wss->wsseBasicAuth($username, $password);
my ($answer, $trace) = $call->
( wsse_Security => $security
, %payload
);