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

  • <small id='ejAdE'></small><noframes id='ejAdE'>

    • <bdo id='ejAdE'></bdo><ul id='ejAdE'></ul>

      <legend id='ejAdE'><style id='ejAdE'><dir id='ejAdE'><q id='ejAdE'></q></dir></style></legend>
    1. <tfoot id='ejAdE'></tfoot>
      <i id='ejAdE'><tr id='ejAdE'><dt id='ejAdE'><q id='ejAdE'><span id='ejAdE'><b id='ejAdE'><form id='ejAdE'><ins id='ejAdE'></ins><ul id='ejAdE'></ul><sub id='ejAdE'></sub></form><legend id='ejAdE'></legend><bdo id='ejAdE'><pre id='ejAdE'><center id='ejAdE'></center></pre></bdo></b><th id='ejAdE'></th></span></q></dt></tr></i><div class="hh9tavq" id='ejAdE'><tfoot id='ejAdE'></tfoot><dl id='ejAdE'><fieldset id='ejAdE'></fieldset></dl></div>

      1. 如何使用 SoapClient 類進行 PHP SOAP 調用

        How to make a PHP SOAP call using the SoapClient class(如何使用 SoapClient 類進行 PHP SOAP 調用)

      2. <small id='wJzne'></small><noframes id='wJzne'>

        • <bdo id='wJzne'></bdo><ul id='wJzne'></ul>
            <tbody id='wJzne'></tbody>

                1. <tfoot id='wJzne'></tfoot>
                  <legend id='wJzne'><style id='wJzne'><dir id='wJzne'><q id='wJzne'></q></dir></style></legend>
                  <i id='wJzne'><tr id='wJzne'><dt id='wJzne'><q id='wJzne'><span id='wJzne'><b id='wJzne'><form id='wJzne'><ins id='wJzne'></ins><ul id='wJzne'></ul><sub id='wJzne'></sub></form><legend id='wJzne'></legend><bdo id='wJzne'><pre id='wJzne'><center id='wJzne'></center></pre></bdo></b><th id='wJzne'></th></span></q></dt></tr></i><div class="yrjtlrx" id='wJzne'><tfoot id='wJzne'></tfoot><dl id='wJzne'><fieldset id='wJzne'></fieldset></dl></div>
                2. 本文介紹了如何使用 SoapClient 類進行 PHP SOAP 調用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我習慣于編寫 PHP 代碼,但不經常使用面向對象的編碼.我現在需要與 SOAP(作為客戶端)交互,但無法正確使用語法.我有一個 WSDL 文件,它允許我使用 SoapClient 類正確設置新連接.但是,我實際上無法進行正確的調用并返回數據.我需要發送以下(簡化的)數據:

                  I'm used to writing PHP code, but do not often use Object-Oriented coding. I now need to interact with SOAP (as a client) and am not able to get the syntax right. I've got a WSDL file which allows me to properly set up a new connection using the SoapClient class. However, I'm unable to actually make the right call and get data returned. I need to send the following (simplified) data:

                  • 聯系人 ID
                  • 聯系人姓名
                  • 一般說明
                  • 金額

                  WSDL 文檔中定義了兩個函數,但我只需要一個(下面的FirstFunction").這是我運行的腳本以獲取有關可用函數和類型的信息:

                  There are two functions defined in the WSDL document, but I only need one ("FirstFunction" below). Here is the script I run to get information on the available functions and types:

                  $client = new SoapClient("http://example.com/webservices?wsdl");
                  var_dump($client->__getFunctions()); 
                  var_dump($client->__getTypes()); 
                  

                  這是它生成的輸出:

                  array(
                    [0] => "FirstFunction Function1(FirstFunction $parameters)",
                    [1] => "SecondFunction Function2(SecondFunction $parameters)",
                  );
                  
                  array(
                    [0] => struct Contact {
                      id id;
                      name name;
                    }
                    [1] => string "string description"
                    [2] => string "int amount"
                  }
                  

                  假設我想用數據調用 FirstFunction:

                  Say I want to make a call to the FirstFunction with the data:

                  • 聯系人 ID:100
                  • 聯系人姓名:約翰
                  • 一般描述:一桶油
                  • 數量:500

                  正確的語法是什么?我一直在嘗試各種選擇,但看起來肥皂結構非常靈活,因此有很多方法可以做到這一點.手冊上也查不到...

                  What would be the right syntax? I've been trying all sorts of options but it appears the soap structure is quite flexible so there are very many ways of doing this. Couldn't figure it out from the manual either...

                  更新 1:來自 MMK 的嘗試樣本:

                  UPDATE 1: tried sample from MMK:

                  $client = new SoapClient("http://example.com/webservices?wsdl");
                  
                  $params = array(
                    "id" => 100,
                    "name" => "John",
                    "description" => "Barrel of Oil",
                    "amount" => 500,
                  );
                  $response = $client->__soapCall("Function1", array($params));
                  

                  但我得到了這樣的回應:Object has no 'Contact' property.正如你在 getTypes() 的輸出中看到的,有一個 struct 叫做 Contact,所以我想我需要以某種方式明確我的參數包括聯系人數據,但問題是:如何?

                  But I get this response: Object has no 'Contact' property. As you can see in the output of getTypes(), there is a struct called Contact, so I guess I somehow need to make clear my parameters include the Contact data, but the question is: how?

                  更新 2:我也試過這些結構,同樣的錯誤.

                  UPDATE 2: I've also tried these structures, same error.

                  $params = array(
                    array(
                      "id" => 100,
                      "name" => "John",
                    ),
                    "Barrel of Oil",
                    500,
                  );
                  

                  還有:

                  $params = array(
                    "Contact" => array(
                      "id" => 100,
                      "name" => "John",
                    ),
                    "description" => "Barrel of Oil",
                    "amount" => 500,
                  );
                  

                  兩種情況下的錯誤:對象沒有聯系人"屬性`

                  Error in both cases: Object has no 'Contact' property`

                  推薦答案

                  這是你需要做的.

                  我試圖重現這種情況...

                  This is what you need to do.

                  I tried to recreate the situation...

                  • 對于本示例,我創建了一個 .NET 示例 WebService (WS),其中包含一個名為 Function1WebMethod,需要以下參數:
                  • For this example, I created a .NET sample WebService (WS) with a WebMethod called Function1 expecting the following params:

                  Function1(Contact Contact, string description, int amount)

                  Function1(Contact Contact, string description, int amount)

                  • 其中 Contact 只是一個具有 idname 的 getter 和 setter 的模型,就像您的情況一樣.

                    • Where Contact is just a model that has getters and setters for id and name like in your case.

                      您可以在以下位置下載 .NET 示例 WS:

                      You can download the .NET sample WS at:

                      https://www.dropbox.com/s/6pz1w94a52o5xah/11593623.zip

                      這是你在 PHP 端需要做的:

                      This is what you need to do at PHP side:

                      (經過測試和工作)

                      <?php
                      // Create Contact class
                      class Contact {
                          public function __construct($id, $name) 
                          {
                              $this->id = $id;
                              $this->name = $name;
                          }
                      }
                      
                      // Initialize WS with the WSDL
                      $client = new SoapClient("http://localhost:10139/Service1.asmx?wsdl");
                      
                      // Create Contact obj
                      $contact = new Contact(100, "John");
                      
                      // Set request params
                      $params = array(
                        "Contact" => $contact,
                        "description" => "Barrel of Oil",
                        "amount" => 500,
                      );
                      
                      // Invoke WS method (Function1) with the request params 
                      $response = $client->__soapCall("Function1", array($params));
                      
                      // Print WS response
                      var_dump($response);
                      
                      ?>
                      


                      測試整個事情.

                      • 如果您執行 print_r($params),您將看到以下輸出,正如您的 WS 所期望的:

                      • Testing the whole thing.

                        • If you do print_r($params) you will see the following output, as your WS would expect:
                        • Array ( [Contact] => Contact Object ( [id] => 100 [name] => John )[說明] =>每桶油 [數量] =>500)

                          Array ( [Contact] => Contact Object ( [id] => 100 [name] => John ) [description] => Barrel of Oil [amount] => 500 )

                          • 當我調試 .NET 示例 WS 時,我得到以下信息:
                          • (如您所見,Contact 對象既不是 null 也不是其他參數.這意味著您的請求已從 PHP 端成功完成)

                            (As you can see, Contact object is not null nor the other params. That means your request was successfully done from PHP side)

                            • 來自 .NET 示例 WS 的響應是預期的響應,這就是我在 PHP 方面得到的響應:

                            object(stdClass)[3] public 'Function1Result' =>字符串 '詳細您的請求信息!id:100,姓名:John,描述:桶油,數量:500'(長度=98)

                            object(stdClass)[3] public 'Function1Result' => string 'Detailed information of your request! id: 100, name: John, description: Barrel of Oil, amount: 500' (length=98)

                            這篇關于如何使用 SoapClient 類進行 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)

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

                          <tbody id='qBFrm'></tbody>
                        <legend id='qBFrm'><style id='qBFrm'><dir id='qBFrm'><q id='qBFrm'></q></dir></style></legend>

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

                          • 主站蜘蛛池模板: 专业生物有机肥造粒机,粉状有机肥生产线,槽式翻堆机厂家-郑州华之强重工科技有限公司 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 超声波气象站_防爆气象站_空气质量监测站_负氧离子检测仪-风途物联网 | 工业PH计|工业ph酸度计|在线PH计价格-合肥卓尔仪器仪表有限公司 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 上海璟文空运首页_一级航空货运代理公司_机场快递当日达 | 多功能真空滤油机_润滑油全自动滤油机_高效真空滤油机价格-重庆润华通驰 | 【连江县榕彩涂料有限公司】官方网站 | 耳模扫描仪-定制耳机设计软件-DLP打印机-asiga打印机-fitshape「飞特西普」 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 智慧农业|农业物联网|现代农业物联网-托普云农物联网官方网站 | 伺服电机维修、驱动器维修「安川|三菱|松下」伺服维修公司-深圳华创益 | 小型UV打印机-UV平板打印机-大型uv打印机-UV打印机源头厂家 |松普集团 | 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 光泽度计_测量显微镜_苏州压力仪_苏州扭力板手维修-苏州日升精密仪器有限公司 | 双工位钻铣攻牙机-转换工作台钻攻中心-钻铣攻牙机一体机-浙江利硕自动化设备有限公司 | 焊缝跟踪系统_激光位移传感器_激光焊缝跟踪传感器-创想智控 | 微波萃取合成仪-电热消解器价格-北京安合美诚科学仪器有限公司 | 智能监控-安防监控-监控系统安装-弱电工程公司_成都万全电子 | H型钢切割机,相贯线切割机,数控钻床,数控平面钻,钢结构设备,槽钢切割机,角钢切割机,翻转机,拼焊矫一体机 | 润东方环保空调,冷风机,厂房车间降温设备-20年深圳环保空调生产厂家 | 高压无油空压机_无油水润滑空压机_水润滑无油螺杆空压机_无油空压机厂家-科普柯超滤(广东)节能科技有限公司 | 郑州宣传片拍摄-TVC广告片拍摄-微电影短视频制作-河南优柿文化传媒有限公司 | 广东燎了网络科技有限公司官网-网站建设-珠海网络推广-高端营销型外贸网站建设-珠海专业h5建站公司「了了网」 | 写方案网_方案策划方案模板下载| 除甲醛公司-甲醛检测治理-杭州创绿家环保科技有限公司-室内空气净化十大品牌 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 | 合金耐磨锤头_破碎机锤头_郑州市德勤建材有限公司 | 胶泥瓷砖胶,轻质粉刷石膏,嵌缝石膏厂家,腻子粉批发,永康家德兴,永康市家德兴建材厂 | SRRC认证_电磁兼容_EMC测试整改_FCC认证_SDOC认证-深圳市环测威检测技术有限公司 | 大白菜官网,大白菜winpe,大白菜U盘装系统, u盘启动盘制作工具 | 字典-新华字典-在线字典查字-字典趣| 楼承板-钢筋楼承板-闭口楼承板-无锡优贝斯楼承板厂 | 专注氟塑料泵_衬氟泵_磁力泵_卧龙泵阀_化工泵专业品牌 - 梭川泵阀 | 英思科GTD-3000EX(美国英思科气体检测仪MX4MX6)百科-北京嘉华众信科技有限公司 | 热镀锌槽钢|角钢|工字钢|圆钢|H型钢|扁钢|花纹板-天津千百顺钢铁贸易有限公司 | 喷播机厂家_二手喷播机租赁_水泥浆洒布机-河南青山绿水机电设备有限公司 | 展厅设计-展馆设计-专业企业展厅展馆设计公司-昆明华文创意 | 紫外可见光分光度计-紫外分光度计-分光光度仪-屹谱仪器制造(上海)有限公司 | 整合营销推广|营销网络推广公司|石家庄网站优化推广公司|智营销 好物生环保网、环保论坛 - 环保人的学习交流平台 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 陶氏道康宁消泡剂_瓦克消泡剂_蓝星_海明斯德谦_广百进口消泡剂 |