我们正在尝试测试联合包裹服务公司(UPS)“Quantum”接口(interface)测试获取订单状态信息。我们的跟踪号 API 可以正常工作,但在使用 QVEvents 时遇到了问题。
UPS“出境订阅账户”已设置、激活并链接到我的帐号。用户访问 Quantum View 数据 View 在用户设置屏幕中被勾选。顺便说一句,我已经使用类似的代码获得了 Tracking API,因此我认为我可以排除用户名或密码问题。这两个 API 在操作上有什么不同吗? (例如:SSL 要求、HTTP header 设置?)
这是对我有用的跟踪 API(“Tack by Waybill”)代码:
<?php
// UPS Tracker API - track specfic Waybill
// DEV server
$access = '99999999399999999';
$userid = '9999999';
$passwd = '999999999999';
$endpointUrl = 'https://www.ups.com/ups.app/xml/Track';
$outFileName = './XOLTResult.xml';
// Note: you need at least a UPS DEV account to test this
$data ="<?xml version=\"1.0\"?><AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>$access</AccessLicenseNumber>
<UserId>$userid</UserId>
<Password>$passwd</Password>
</AccessRequest>
<?xml version=\"1.0\"?>
<TrackRequest>
<Request>
<TransactionReference>
<CustomerContext>
<InternalKey>hello</InternalKey>
</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<RequestAction>Track</RequestAction>
</Request>
<TrackingNumber>9999999999999999</TrackingNumber>
</TrackRequest>";
$ch = curl_init("https://www.ups.com/ups.app/xml/Track");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$result=curl_exec ($ch);
$data = strstr($result, '<?');
$xml=simplexml_load_string($data);
echo "<pre>";
print_r($xml);
这是给出错误消息的 Quantum API 代码...
<?php
// UPS Quantum API ("Show list of recent tracking information")
// DEV server
$access = '99999999399999999';
$userid = '9999999';
$passwd = '999999999999';
$endpointUrl = 'https://wwwcie.ups.com/ups.app/xml/QVEvents'; // URL for testing Quantum
$outFileName = './XOLTResult.xml';
try
{
$data ="<?xml version=\"1.0\"?>
<AccessRequest xml:lang=\"en-US\">
<AccessLicenseNumber>$access</AccessLicenseNumber>
<UserId>$userid</UserId>
<Password>$passwd</Password>
</AccessRequest>
<?xml version=\"1.0\"?>
<QuantumViewRequest xml:lang=\"en-US\">
<Request>
<TransactionReference>
<CustomerContext>Test XML</CustomerContext>
<XpciVersion>1.0007</XpciVersion>
</TransactionReference>
<RequestAction>QVEvents</RequestAction>
<IntegrationIndicator></IntegrationIndicator>
</Request>
</QuantumViewRequest>";
$postData = array
(
'content' => $data
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL,$endpointUrl);
curl_setopt($ch, CURLOPT_VERBOSE, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // disable SSL verification if not installed
//curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSLVERSION, 3); // use Secure Socket v3 SSL3
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postData);
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
echo $result;
$data = strstr($result, '<?');
$xml=simplexml_load_string($data);
echo "<pre>";
print_r($xml);
}
catch(Exception $ex)
{
echo ($ex . "!");
}
curl_close($ch);
这是实际发送给 UPS 的 XML... [注意双 xml header 是他们要求的,它适用于所有其他 API,所以不要怪我]
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>999</AccessLicenseNumber>
<UserId>999</UserId>
<Password>999</Password>
</AccessRequest>
<?xml version="1.0"?>
<QuantumViewRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Test XML</CustomerContext>
<XpciVersion>1.0007</XpciVersion>
</TransactionReference>
<RequestAction>QVEvents</RequestAction>
<IntegrationIndicator></IntegrationIndicator>
</Request>
</QuantumViewRequest>
错误信息如下所示:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Fri, 25 Jul 2014 22:50:57 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/xml
<QuantumViewResponse><Response><TransactionReference><XpciVersion>1.0</XpciVersion>
</TransactionReference><ResponseStatusCode>0</ResponseStatusCode>
<ResponseStatusDescription>Failure</ResponseStatusDescription><Error>
<ErrorSeverity>Hard</ErrorSeverity><ErrorCode>10001</ErrorCode>
<ErrorDescription>The XML document is not well formed</ErrorDescription></Error>
</Response></QuantumViewResponse><pre>
我没有使用 UPS SCA_SDO 库,因为它不会安装在我的 PC 上。也许我应该再看一遍,但我的程序员向我保证这不是必需的,也与这个问题无关。双层 XML 看起来很可疑,但手册上说这是 UPS 想要的方式。我猜 UPS 会根据请求运行预处理器。
最佳答案
根据 2014 年 7 月的 Quantum View Developers Guide ,未使用 IntegrationIndicator。
从您的 Request 节点中删除它,它应该按您预期的那样运行:
<Request>
<TransactionReference>
<CustomerContext>Test XML</CustomerContext>
<XpciVersion>1.0007</XpciVersion>
</TransactionReference>
<RequestAction>QVEvents</RequestAction>
</Request>
关于php - 尝试测试 UPS "Quantum"接口(interface) - XML 文档格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24945613/
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
我有一个围绕一些对象的包装类,我想将这些对象用作散列中的键。包装对象和解包装对象应映射到相同的键。一个简单的例子是这样的:classAattr_reader:xdefinitialize(inner)@inner=innerenddefx;@inner.x;enddef==(other)@inner.x==other.xendenda=A.new(o)#oisjustanyobjectthatallowso.xb=A.new(o)h={a=>5}ph[a]#5ph[b]#nil,shouldbe5ph[o]#nil,shouldbe5我试过==、===、eq?并散列所有无济于事。
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/