pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<tfoot id='kz6ch'></tfoot>

<small id='kz6ch'></small><noframes id='kz6ch'>

      <i id='kz6ch'><tr id='kz6ch'><dt id='kz6ch'><q id='kz6ch'><span id='kz6ch'><b id='kz6ch'><form id='kz6ch'><ins id='kz6ch'></ins><ul id='kz6ch'></ul><sub id='kz6ch'></sub></form><legend id='kz6ch'></legend><bdo id='kz6ch'><pre id='kz6ch'><center id='kz6ch'></center></pre></bdo></b><th id='kz6ch'></th></span></q></dt></tr></i><div class="5x7bzhr" id='kz6ch'><tfoot id='kz6ch'></tfoot><dl id='kz6ch'><fieldset id='kz6ch'></fieldset></dl></div>
      • <bdo id='kz6ch'></bdo><ul id='kz6ch'></ul>

        <legend id='kz6ch'><style id='kz6ch'><dir id='kz6ch'><q id='kz6ch'></q></dir></style></legend>

        如何創建具有多個命名空間的 PHP SOAP 請求

        How to create PHP SOAP request with multiple namespaces(如何創建具有多個命名空間的 PHP SOAP 請求)
        <i id='b1M14'><tr id='b1M14'><dt id='b1M14'><q id='b1M14'><span id='b1M14'><b id='b1M14'><form id='b1M14'><ins id='b1M14'></ins><ul id='b1M14'></ul><sub id='b1M14'></sub></form><legend id='b1M14'></legend><bdo id='b1M14'><pre id='b1M14'><center id='b1M14'></center></pre></bdo></b><th id='b1M14'></th></span></q></dt></tr></i><div class="t5hnznh" id='b1M14'><tfoot id='b1M14'></tfoot><dl id='b1M14'><fieldset id='b1M14'></fieldset></dl></div>
        <legend id='b1M14'><style id='b1M14'><dir id='b1M14'><q id='b1M14'></q></dir></style></legend>
        • <bdo id='b1M14'></bdo><ul id='b1M14'></ul>
          1. <small id='b1M14'></small><noframes id='b1M14'>

            1. <tfoot id='b1M14'></tfoot>
                    <tbody id='b1M14'></tbody>
                  本文介紹了如何創建具有多個命名空間的 PHP SOAP 請求的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試從 SOAP 服務獲取運輸報價.我已經能夠成功創建身份驗證標頭并使用不需要正文參數的基本請求來查詢 SOAP 服務.

                  I'm attempting to get a shipping quote from an SOAP service. I've been able to successfully create authentication headers and query the SOAP service with basic requests that require no body parameters.

                  我能夠為請求創建正確的結構,但命名空間值沒有顯示在請求輸出中.

                  I'm able to create the proper structure for the request but the namespace values are not showing up in the request output.

                  示例代碼:

                  $client = new SoapClient("http://demo.smc3.com/AdminManager/services/RateWareXL?wsdl",
                                     array('trace' => TRUE));
                  
                  $headerParams = array('ns1:licenseKey'    => $key,
                                        'ns1:password'      => $pass,
                                        'ns1:username'      => $user);
                  
                  $soapStruct = new SoapVar($headerParams, SOAP_ENC_OBJECT);
                  $header = new SoapHeader($ns, 'AuthenticationToken', $soapStruct, false);
                  $client->__setSoapHeaders($header);
                  
                  // Check if shipping is ready - base call
                  $ready_to_ship = $client->isReady();
                  

                  以上工作正常,如果運輸服務可用,則返回 true.

                  The above works just fine and returns true if the shipping service is available.

                  所以我使用以下代碼來構建請求正文(僅填寫必填字段):我還嘗試將所有內容放入數組并將其轉換為 SoapVar,我嘗試在正文請求創建中包含 ns1: 和 ns2: 但這也不起作用.我相信在請求創建中需要調整一些東西......不確定最好的方法..

                  So I use the following code to build the request body (only filling required fields): I've also tried putting everything into an array and converting that to a SoapVar, I've tried including ns1: and ns2: in the body request creation but that hasn't worked either. I believe something needs to be adjusted in the request creation... not sure of the best approach..

                  $rate_request = $client->LTLRateShipment;
                  $rate_request->LTLRateShipmentRequest->destinationCountry = $destination_country;
                  $rate_request->LTLRateShipmentRequest->destinationPostalCode = $destination_postal_code;
                  $rate_request->LTLRateShipmentRequest->destinationPostalCode = $destination_postal_code;
                  $rate_request->LTLRateShipmentRequest->details->LTLRequestDetail->nmfcClass = $ship_class;
                  $rate_request->LTLRateShipmentRequest->details->LTLRequestDetail->weight = $ship_weight;
                  $rate_request->LTLRateShipmentRequest->originCountry = $origin_country;
                  $rate_request->LTLRateShipmentRequest->originPostalCode = $origin_postal_code;
                  $rate_request->LTLRateShipmentRequest->shipmentDateCCYYMMDD = $ship_date; 
                  $rate_request->LTLRateShipmentRequest->tariffName = $tariff; 
                  

                  它生成以下 XML:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservices.smc.com">
                          <SOAP-ENV:Header>
                              <ns1:AuthenticationToken>
                                  <ns1:licenseKey>xxxxxxxx</ns1:licenseKey>
                                  <ns1:password>xxxxxxxx</ns1:password>
                                  <ns1:username>xxxxxxxxm</ns1:username>
                                      </ns1:AuthenticationToken>
                      </SOAP-ENV:Header>
                      <SOAP-ENV:Body>
                          <ns1:LTLRateShipment>
                              <LTLRateShipmentRequest>
                                  <destinationCountry>USA</destinationCountry>
                                  <destinationPostalCode>10001</destinationPostalCode>
                          <details>
                                <LTLRequestDetail>
                            <nmfcClass>60</nmfcClass>
                            <weight>300</weight>
                                            </LTLRequestDetail>
                          </details> 
                                            <originCountry>USA</originCountry>
                                  <originPostalCode>90210</originPostalCode>
                                  <shipmentDateCCYYMMDD>20110516</shipmentDateCCYYMMDD>
                                  <tariffName>DEMOLTLA</tariffName>
                              </LTLRateShipmentRequest>
                          </ns1:LTLRateShipment>
                      </SOAP-ENV:Body>
                      </SOAP-ENV:Envelope>
                  

                  但是輸出應該包括命名空間(web: 和 web1: 在適當的地方).上述請求返回缺少關稅名稱的錯誤代碼.

                  But the output should include the namespaces (web: and web1: where appropriate). The above request returns an error code of missing tariffName.

                  以下是 xml 請求的示例:

                  Here's an example of what the xml request should look like:

                      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:web="http://webservices.smc.com" xmlns:web1="http://web.ltl.smc.com"> 
                     <soapenv:Header> 
                        <web:AuthenticationToken> 
                           <web:licenseKey> string </web:licenseKey> 
                           <web:password> string </web:password> 
                           <web:username> string </web:username> 
                        </web:AuthenticationToken> 
                     </soapenv:Header> 
                     <soapenv:Body> 
                        <web:LTLRateShipment> 
                           <web:LTLRateShipmentRequest> 
                              <web1:LTL_Surcharge> string </web1:LTL_Surcharge> 
                              <web1:TL_Surcharge> string </web1:TL_Surcharge> 
                              <web1:destinationCity> string </web1:destinationCity> 
                              <web1:destinationCountry> string </web1:destinationCountry> 
                              <web1:destinationPostalCode> string </web1:destinationPostalCode> 
                              <web1:destinationState> string </web1:destinationState> 
                              <web1:details> 
                                 <!--Zero or more repetitions:--> 
                                 <web1:LTLRequestDetail> 
                                    <web1:nmfcClass> string </web1:nmfcClass> 
                                    <web1:weight> string </web1:weight> 
                                 </web1:LTLRequestDetail> 
                              </web1:details> 
                              <web1:discountApplication> string </web1:discountApplication> 
                              <web1:mcDiscount> string </web1:mcDiscount> 
                              <web1:orgDestToGateWayPointFlag> string </web1:orgDestToGateWayPointFlag> 
                              <web1:originCity> string </web1:originCity> 
                              <web1:originCountry> string </web1:originCountry> 
                              <web1:originPostalCode> string </web1:originPostalCode> 
                              <web1:originState> string </web1:originState> 
                              <web1:rateAdjustmentFactor> string </web1:rateAdjustmentFactor> 
                              <web1:shipmentDateCCYYMMDD> string </web1:shipmentDateCCYYMMDD> 
                              <web1:shipmentID> string </web1:shipmentID> 
                              <web1:stopAlternationWeight> string </web1:stopAlternationWeight> 
                              <web1:surchargeApplication> string </web1:surchargeApplication> 
                              <web1:tariffName> string </web1:tariffName> 
                              <web1:weightBreak_Discount_1> string </web1:weightBreak_Discount_1> 
                           </web:LTLRateShipmentRequest> 
                        </web:LTLRateShipment> 
                     </soapenv:Body> 
                  </soapenv:Envelope>
                  

                  感謝任何建議/方向!

                  推薦答案

                  好的...經過太多小時的測試我終于有了解決方案...

                  Ok... After too many hours of testing I finally have a solution..

                  我將授權令牌重新創建為一個類并構建了 Soap 請求,而無需處理任何命名空間、SoapVars 等.這非常簡單.

                  I recreated the Authorization Token as a class and built the Soap Request without having to deal with any namespaces, SoapVars etc. it's surprisingly easy.

                  /* Object for holding authentication info 
                     this could probably be accomplished using stdClass too */
                  class AuthHeader {
                      var $licenseKey;
                      var $password;
                      var $username;
                  
                      function __construct($loginInfo) {
                        $this->licenseKey = $loginInfo['licenseKey'];
                        $this->password   = $loginInfo['password'];
                        $this->username   = $loginInfo['username'];
                      }
                  }
                  
                  // set current soap header with login info
                  $client = new SoapClient("http://demo.smc3.com/AdminManager/services/RateWareXL?wsdl",
                                       array('trace' => TRUE
                                          ));
                  // create header params array
                  $headerParams = array('licenseKey'        => $key,
                                        'password'          => $pass,
                                        'username'          => $user);
                  // create AuthHeader object
                  $auth = new AuthHeader($headerParams);
                  
                  // Turn auth header into a SOAP Header
                  $header = new SoapHeader($ns, 'AuthenticationToken', $auth, false);
                  
                  // set the header
                  $client->__setSoapHeaders($header);
                  
                  // Check if shipping is ready - base call
                  $ready_to_ship = $client->isReady();
                  // $last_request = $client->__getLastRequest();
                  $last_response = $client->__getLastResponse();
                  
                  //print $last_request;
                  if ($last_response == true) {
                  
                    print "Ready to ship
                  ";
                  
                  // Create the shipping request
                  $d = new stdClass;
                  $d->nmfcClass = $ship_class;
                  $d->weight    = $ship_weight;
                  
                  $p = new stdClass;
                  $p->LTLRateShipmentRequest->destinationCountry       = $destination_country;
                  $p->LTLRateShipmentRequest->destinationPostalCode    = $destination_postal_code;
                  $p->LTLRateShipmentRequest->details                  = array($d);
                  $p->LTLRateShipmentRequest->originCountry            = $origin_country;
                  $p->LTLRateShipmentRequest->originPostalCode         = $origin_postal_code;
                  $p->LTLRateShipmentRequest->shipmentDateCCYYMMDD     = $ship_date;
                  $p->LTLRateShipmentRequest->tariffName               = $tariff;
                  
                  $quote = $client->LTLRateShipment($p);
                  
                  $last_request = $client->__getLastRequest();
                  $last_response = $client->__getLastResponse();
                  
                  print "Request: " . $last_request;
                  print "
                  Response: " . $last_response;
                  
                  }
                  

                  這篇關于如何創建具有多個命名空間的 PHP SOAP 請求的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機)
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實現)
                  Sending a byte array from PHP to WCF(將字節數組從 PHP 發送到 WCF)
                  <legend id='bw5xd'><style id='bw5xd'><dir id='bw5xd'><q id='bw5xd'></q></dir></style></legend>

                        <tbody id='bw5xd'></tbody>

                      <small id='bw5xd'></small><noframes id='bw5xd'>

                      <i id='bw5xd'><tr id='bw5xd'><dt id='bw5xd'><q id='bw5xd'><span id='bw5xd'><b id='bw5xd'><form id='bw5xd'><ins id='bw5xd'></ins><ul id='bw5xd'></ul><sub id='bw5xd'></sub></form><legend id='bw5xd'></legend><bdo id='bw5xd'><pre id='bw5xd'><center id='bw5xd'></center></pre></bdo></b><th id='bw5xd'></th></span></q></dt></tr></i><div class="r7vj7lh" id='bw5xd'><tfoot id='bw5xd'></tfoot><dl id='bw5xd'><fieldset id='bw5xd'></fieldset></dl></div>
                        <bdo id='bw5xd'></bdo><ul id='bw5xd'></ul>

                        <tfoot id='bw5xd'></tfoot>
                          1. 主站蜘蛛池模板: 淄博不锈钢无缝管,淄博不锈钢管-鑫门物资有限公司 | 步入式高低温测试箱|海向仪器| 旋振筛|圆形摇摆筛|直线振动筛|滚筒筛|压榨机|河南天众机械设备有限公司 | U拓留学雅思一站式服务中心_留学申请_雅思托福培训 | 沈阳网站建设_沈阳网站制作_沈阳网页设计-做网站就找示剑新零售 沈阳缠绕膜价格_沈阳拉伸膜厂家_沈阳缠绕膜厂家直销 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 免联考国际MBA_在职MBA报考条件/科目/排名-MBA信息网 | 干粉砂浆设备-干粉砂浆生产线-干混-石膏-保温砂浆设备生产线-腻子粉设备厂家-国恒机械 | 微型气泵-真空-蠕动-水泵-厂家-深圳市品亚科技有限公司 | 变色龙PPT-国内原创PPT模板交易平台 - PPT贰零 - 西安聚讯网络科技有限公司 | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 加中寰球移民官网-美国移民公司,移民机构,移民中介,移民咨询,投资移民 | 游动电流仪-流通式浊度分析仪-杰普仪器(上海)有限公司 | 航空障碍灯_高中低光强航空障碍灯_民航许可认证航空警示灯厂家-东莞市天翔航天科技有限公司 | 锌合金压铸-铝合金压铸厂-压铸模具-冷挤压-誉格精密压铸 | 农业仪器网 - 中国自动化农业仪器信息交流平台 | 广州市哲铭油墨涂料有限公司,水性漆生产研发基地 | 精密机械零件加工_CNC加工_精密加工_数控车床加工_精密机械加工_机械零部件加工厂 | 哈希余氯测定仪,分光光度计,ph在线监测仪,浊度测定仪,试剂-上海京灿精密机械有限公司 | 垃圾处理设备_餐厨垃圾处理设备_厨余垃圾处理设备_果蔬垃圾处理设备-深圳市三盛环保科技有限公司 | RTO换向阀_VOC高温阀门_加热炉切断阀_双偏心软密封蝶阀_煤气蝶阀_提升阀-湖北霍科德阀门有限公司 | 噪声治理公司-噪音治理专业隔音降噪公司 | 管理会计网-PCMA初级管理会计,中级管理会计考试网站 | 钢木实验台-全钢实验台-化验室通风柜-实验室装修厂家-杭州博扬实验设备 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 重庆监控_电子围栏设备安装公司_门禁停车场管理系统-劲浪科技公司 | 搜活动房网—活动房_集装箱活动房_集成房屋_活动房屋 | 踏板力计,制动仪,非接触多功能速度仪,逆反射系数测试仪-创宇 | 翅片管散热器价格_钢制暖气片报价_钢制板式散热器厂家「河北冀春暖气片有限公司」 | 昆山新莱洁净应用材料股份有限公司-卫生级蝶阀,无菌取样阀,不锈钢隔膜阀,换向阀,离心泵 | 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 金属雕花板_厂家直销_价格低-山东慧诚建筑材料有限公司 | 铝箔袋,铝箔袋厂家,东莞铝箔袋,防静电铝箔袋,防静电屏蔽袋,防静电真空袋,真空袋-东莞铭晋让您的产品与众不同 | 世纪豪门官网 世纪豪门集成吊顶加盟电话 世纪豪门售后电话 | 集装箱箱号识别_自重载重图像识别_铁路车号自动识别_OCR图像识别 | 昆山PCB加工_SMT贴片_PCB抄板_线路板焊接加工-昆山腾宸电子科技有限公司 | 硬度计_影像测量仪_维氏硬度计_佛山市精测计量仪器设备有限公司厂家 | 德国UST优斯特氢气检漏仪-德国舒赐乙烷检测仪-北京泽钏 | 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 | 金刚网,金刚网窗纱,不锈钢网,金刚网厂家- 河北萨邦丝网制品有限公司 |