所以我在向我的 SOAP 请求添加 wsse header 时遇到了一些问题。
#!/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>
返回?
1
早些时候我曾尝试过 my $wss ... 代码...但那也没有用。
这是我尝试生成的实际请求
<?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>
也许有人知道我将如何添加 wsse header ?
更新
我可以生成 SOAP
<?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>
但是我尝试放入 wsse_Security 的所有内容都导致了这样的错误:
mistake: tag `foo' not used at {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security
其中 foo 等于我尝试的任何标签。
最佳答案
我已经在发行版中添加了示例,以展示如何执行此操作。此外,我添加了一种方法来帮助您生成这种特定的登录方式。发布为 XML-Compile-WSS版本 0.12 .
my $call = $wsdl->compileClient($operation);
my $security = $wss->wsseBasicAuth($username, $password);
my ($answer, $trace) = $call->
( wsse_Security => $security
, %payload
);
关于xml - 带有 XML::Compile::SOAP::WSS 和 Perl 的 WSSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7128316/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
使用rspec-rails3.0+,测试设置分为spec_helper和rails_helper我注意到生成的spec_helper不需要'rspec/rails'。这会导致zeus崩溃:spec_helper.rb:5:in`':undefinedmethod`configure'forRSpec:Module(NoMethodError)对thisissue最常见的回应是需要'rspec/rails'。但这是否会破坏仅使用spec_helper拆分rails规范和PORO规范的全部目的?或者这无关紧要,因为Zeus无论如何都会预加载Rails?我应该在我的spec_helper中做
Ruby是否有逐步调试器,类似于Perl的“perl-d”? 最佳答案 ruby-debug(对于ruby1.8),debugger(对于ruby1.9),byebug(对于ruby2.0)以及trepanning系列都有一个-x或--trace选项。在调试器内部,命令setlinetrace将打开或关闭线路跟踪。这是themanualforruby-debug原来的答案已经修改,因为数据噪声文章的链接,唉,不再有效了。还添加了ruby-debug的后继者 关于ruby-Ruby
假设我有一个类A,里面有一些方法。假设stringmethodName是这些方法之一,我已经知道我想给它什么参数。它们在散列中{'param1'=>value1,'param2'=>value2}所以我有:params={'param1'=>value1,'param2'=>value2}a=A.new()a.send(methodName,value1,value2)#callmethodnamewithbothparams我希望能够通过传递我的哈希以某种方式调用该方法。这可能吗? 最佳答案 确保methodName是一个符号,而
当我进入Rails控制台时,我已将pry设置为加载代替irb。我找不到该页面或不记得如何将其恢复为默认行为,因为它似乎干扰了我的Rubymine调试器。有什么建议吗? 最佳答案 我刚发现问题,pry-railsgem。忘记了它的目的是让“railsconsole”打开pry。 关于ruby-on-rails-带有Pry的Rails控制台,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/question
我了解instance_eval和class_eval之间的基本区别。我在玩弄时发现的是一些涉及attr_accessor的奇怪东西。这是一个例子:A=Class.newA.class_eval{attr_accessor:x}a=A.newa.x="x"a.x=>"x"#...expectedA.instance_eval{attr_accessor:y}A.y="y"=>NoMethodError:undefinedmethod`y='forA:Classa.y="y"=>"y"#WHATTT?这是怎么回事:instance_eval没有访问我们的A类(对象)然后它实际上将它添加到
我在一个简单的RailsAPI中有以下Controller代码:classApi::V1::AccountsControllerehead:not_foundendendend问题在于,生成的json具有以下格式:{id:2,name:'Simpleaccount',cash_flows:[{id:1,amount:34.3,description:'simpledescription'},{id:2,amount:1.12,description:'otherdescription'}]}我需要我生成的json是camelCase('cashFlows'而不是'cash_flows'