第一次发帖,如有违反论坛规则等,请见谅。 我正在尝试使用 DHL api 来跟踪 cargo 。
这是我目前的代码
$client = new SoapClient("https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl");
//$header = new SoapHeader("https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl", "APICredentials", $auth, false);
//$client->__setLocation('https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl');
$header_part = '<soapenv:Envelope xmlns:rat="https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-5" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-
wss-wssecurity-utility-1.0.xsd">
<wsse:Username>myusername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-
1.0#PasswordText">mypassword</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-
1.0#Base64Binary">eUYebYfsjztETJ4Urt8AJw==</wsse:Nonce>
<wsu:Created>2010-02-12T17:40:39.124Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>';
$soap_var_header = new SoapVar( $header_part, XSD_ANYXML, null, null, null );
$soap_header = new SoapHeader( 'https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack', 'wsse', $soap_var_header, true );
$client->__setSoapHeaders($soap_header);
如果我这样做
var_dump($client->__getFunctions())
我得到以下信息:
array(1) { [0]=> string(83) "trackShipmentRequestResponse trackShipmentRequest(trackShipmentRequest $parameters)" }
我的问题真的是有人知道如何格式化 trackShipmentRequest
$client->trackShipmentRequest(what goes here);
这里是DHL给我的xml的例子,要在soapui中使用
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trac="http://scxgxtt.phx-dc.dhl.com/glDHLExpressTrack/providers/services/trackShipment" xmlns:dhl="http://www.dhl.com">
<soapenv:Header/>
<soapenv:Body>
<trac:trackShipmentRequest>
<trackingRequest>
<dhl:TrackingRequest>
<Request>
<ServiceHeader>
<MessageTime>2013-05-13T10:17:20Z</MessageTime>
<MessageReference>c68d7150bbd611e2b09ad103c98eed12</MessageReference>
</ServiceHeader>
</Request>
<!--Optional:-->
<AWBNumber>
<!--1 or more repetitions:-->
<ArrayOfAWBNumberItem>2786552086</ArrayOfAWBNumberItem>
</AWBNumber>
<!--Optional:-->
<LPNumber>
<!--1 or more repetitions:-->
<ArrayOfTrackingPieceIDItem>?</ArrayOfTrackingPieceIDItem>
</LPNumber>
<LevelOfDetails>ALL_CHECK_POINTS</LevelOfDetails>
<!--Optional:-->
<PiecesEnabled>B</PiecesEnabled>
</dhl:TrackingRequest>
</trackingRequest>
</trac:trackShipmentRequest>
</soapenv:Body>
</soapenv:Envelope>
我发现这个网站上有类似的主题,但似乎没有帮助。
最佳答案
您在第一行中使用的 WSDL 端点
new SoapClient("https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl");
甚至没有解决。我不认为它会工作。通常如果你只是粘贴 https://wsbuat.dhl.com:8300/gbl/glDHLExpressTrack?wsdl在您的浏览器中,您应该能够看到我所知道的大多数 SOAP 服务的定义。
根据 user555 的评论,端点可能已被弃用,因此您应该联系 DHL。
关于php - DHL 跟踪装运请求 - WSDL - PHP - SOAP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16860991/
我正在尝试使用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请求没有正确的命名空间。任何人都可以建议我
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
我是Ruby的新手。我试过查看在线文档,但没有找到任何有效的方法。我想在以下HTTP请求botget_response()和get()中包含一个用户代理。有人可以指出我正确的方向吗?#PreliminarycheckthatProggitisupcheck=Net::HTTP.get_response(URI.parse(proggit_url))ifcheck.code!="200"puts"ErrorcontactingProggit"returnend#Attempttogetthejsonresponse=Net::HTTP.get(URI.parse(proggit_url)
在我的路线文件中我有:match'graphs/(:id(/:action))'=>'graphs#(:action)'如果是GET请求(工作)或POST请求(不工作),我想匹配它我知道我可以使用以下方法在资源中声明POST请求:post'/'=>:show,:on=>:member但是我怎样才能为比赛做到这一点呢?谢谢。 最佳答案 如果你同时想要POST和GETmatch'graphs/(:id(/:action))'=>'graphs#(:action)',:via=>[:get,:post]编辑默认值可以设置如下match'g
我试图像这样在我的测试用例中执行获取:request.env['CONTENT_TYPE']='application/json'get:index,:application_name=>"Heka"虽然,它失败了:ActionView::MissingTemplate:Missingtemplatealarm_events/indexwith{:handlers=>[:builder,:haml,:erb,:rjs,:rhtml,:rxml],:locale=>[:en,:en],:formats=>[:html]尽管在我的Controller中我有:respond_to:html,
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它
如果使用rspec请求花费的时间太长,我该如何测试行为?我正在考虑使用线程来模拟这个:describe"Test"doit"shouldtimeoutiftherequesttakestoolong"dolambda{thread1=Thread.new{#net::httprequesttogoogle.com}thread2=Thread.new{sleep(xxseconds)}thread1.jointhread2.join}.shouldraise_errorendend我想确保在第一次发出请求后,另一个线程“启动”,在这种情况下只是休眠xx秒。然后我应该期望请求超时,因为执
我有一堆要清理的URL。它们都包含UTM参数,在这种情况下不是必需的,或者是有害的。示例:http://houseofbuttons.tumblr.com/post/22326009438?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+HouseOfButtons+%28House+of+Buttons%29所有可能的参数都以utm_开头。如何使用ruby脚本/结构轻松删除它们而不破坏其他潜在的“好”URL参数? 最佳答案 您可以将正则表达式应用于url以清
假设我有:get'/'do$random=Random.rand()response.body=$randomend如果我每秒有数千个请求到达/,$random是否会被共享并“泄漏”到上下文之外,或者它会像getblock的“本地”变量一样?我想如果它是在get'/'do的上下文之外定义的,它确实会被共享,但我想知道在ruby中是否有我不知道的$机制。 最佳答案 ThispartoftheSinatraREADMEaboutscopeisalwayshelpfultoread但是,如果您只需要为请求保留变量,那么我认为我建议使用