{"id":48500,"date":"2024-12-02T09:33:19","date_gmt":"2024-12-02T01:33:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48500\/"},"modified":"2024-12-02T09:33:19","modified_gmt":"2024-12-02T01:33:19","slug":"php-%e5%87%bd%e6%95%b0%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-soap-%e8%b0%83%e7%94%a8%e5%a4%96%e9%83%a8%e5%87%bd%e6%95%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48500\/","title":{"rendered":"PHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f<\/h1>\n<p>\u76ee\u524d\u7c73\u4e91\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u6587\u7ae0\u4e86\uff0c\u81ea\u5df1\u5728\u521d\u6b21\u9605\u8bfb\u8fd9\u4e9b\u6587\u7ae0\u4e2d\uff0c\u4e5f\u89c1\u8bc6\u5230\u4e86\u5f88\u591a\u5b66\u4e60\u601d\u8def\uff1b\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f\u300b<\/span>\uff0c\u4e5f\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff0c\u5982\u679c\u9605\u8bfb\u5b8c\u540e\u771f\u7684\u5bf9\u4f60\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u6709\u5e2e\u52a9\uff0c\u6b22\u8fce\u52a8\u52a8\u624b\u6307\uff0c\u8bc4\u8bba\u7559\u8a00\u5e76\u5206\u4eab~<\/p>\n<p>\u4f7f\u7528 PHP SoapClient \u7c7b\u8c03\u7528 SOAP \u670d\u52a1\u7684\u6b65\u9aa4\uff1a\u4f7f\u7528 $wsdl \u548c $options \u521b\u5efa SoapClient \u5bf9\u8c61\u3002\u4f7f\u7528 $functionName \u548c $parameters \u8c03\u7528 SOAP \u51fd\u6570\u3002\u89e3\u6790 SOAP \u51fd\u6570\u7684\u54cd\u5e94\u6570\u636e\u5b58\u50a8\u4e8e $result \u4e2d\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241027\/1730038232671e49d840c3f.jpg\" class=\"aligncenter\" title=\"PHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f\u63d2\u56fe\" alt=\"PHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\uff1a\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570<\/strong><\/p>\n<p>SOAP\uff08\u7b80\u5355\u5bf9\u8c61\u8bbf\u95ee\u534f\u8bae\uff09\u662f\u4e00\u79cd XML \u534f\u8bae\uff0c\u7528\u4e8e\u901a\u8fc7\u7f51\u7edc\u4ea4\u6362\u4fe1\u606f\u548c\u8c03\u7528\u8fdc\u7a0b\u51fd\u6570\u3002\u5728 PHP \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684 <code>SoapClient<\/code> \u7c7b\u6765\u8c03\u7528 SOAP \u670d\u52a1\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>$client = new SoapClient($wsdl, $options);\n$result = $client-&gt;functionName($parameters);<\/pre>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li><code>$wsdl<\/code> \u662f SOAP \u670d\u52a1\u7684 WSDL\uff08Web \u670d\u52a1\u63cf\u8ff0\u8bed\u8a00\uff09\u6587\u4ef6\u7684\u8def\u5f84\u6216 URL\u3002<\/li>\n<li><code>$options<\/code> \u662f\u4e00\u4e2a\u5305\u542b\u914d\u7f6e\u9009\u9879\u7684\u6570\u7ec4\uff0c\u4f8b\u5982 SOAP \u7248\u672c\u3001\u9a8c\u8bc1\u7b49\u3002<\/li>\n<li><code>$functionName<\/code> \u662f\u8981\u8c03\u7528\u7684 SOAP \u51fd\u6570\u7684\u540d\u79f0\u3002<\/li>\n<li><code>$parameters<\/code> \u662f\u4f20\u9012\u7ed9 SOAP \u51fd\u6570\u7684\u53c2\u6570\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 <code>SoapClient<\/code> \u7c7b\u8c03\u7528\u5916\u90e8\u5929\u6c14\u670d\u52a1\u6765\u83b7\u53d6\u5b9e\u65f6\u5929\u6c14\u6570\u636e\uff1a<\/p>\n<pre>&lt;?php\n\/\/ \u521b\u5efa SoapClient \u5bf9\u8c61\n$client = new SoapClient('http:\/\/www.webservicex.net\/globalweather.asmx?wsdl');\n\n\/\/ \u8c03\u7528 getWeather \u51fd\u6570\n$parameters = array('CityName' =&gt; 'New York', 'CountryName' =&gt; 'United States');\n$response = $client-&gt;getWeather($parameters);\n\n\/\/ \u89e3\u6790\u54cd\u5e94\n$weather = $response-&gt;getWeatherResult;\n\n\/\/ \u8f93\u51fa\u5929\u6c14\u6570\u636e\necho \"Weather for New York, United States: {$weather}\";\n?&gt;<\/pre>\n<p>\u901a\u8fc7\u8fd0\u884c\u6b64\u811a\u672c\uff0c\u60a8\u5c06\u83b7\u5f97\u7ebd\u7ea6\u7684\u5b9e\u65f6\u5929\u6c14\u6570\u636e\u3002<\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd <code>$wsdl<\/code> URL \u6b63\u786e\u5e76\u4e14 SOAP \u670d\u52a1\u53ef\u7528\u3002<\/li>\n<li>\u53c2\u6570\u6570\u7ec4\u7684\u952e\u5fc5\u987b\u4e0e SOAP \u51fd\u6570\u671f\u671b\u7684\u53c2\u6570\u540d\u79f0\u5339\u914d\u3002<\/li>\n<li><code>$result<\/code> \u53d8\u91cf\u5c06\u5305\u542b SOAP \u51fd\u6570\u7684\u54cd\u5e94\u6570\u636e\uff0c\u53ef\u80fd\u9700\u8981\u8fdb\u4e00\u6b65\u89e3\u6790\u3002<\/li>\n<\/ul>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f \u76ee\u524d\u7c73\u4e91\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u6587\u7ae0\u4e86\uff0c\u81ea\u5df1\u5728\u521d\u6b21\u9605\u8bfb\u8fd9\u4e9b\u6587\u7ae0\u4e2d\uff0c\u4e5f\u89c1\u8bc6\u5230\u4e86\u5f88\u591a\u5b66\u4e60\u601d\u8def\uff1b\u90a3\u4e48\u672c\u6587\u300aPHP \u51fd\u6570\u5982\u4f55\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570\uff1f\u300b\uff0c\u4e5f\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff0c\u5982\u679c\u9605\u8bfb\u5b8c\u540e\u771f\u7684\u5bf9\u4f60\u5b66\u4e60\u6587\u7ae0\u6709\u5e2e\u52a9\uff0c\u6b22\u8fce\u52a8\u52a8\u624b\u6307\uff0c\u8bc4\u8bba\u7559\u8a00\u5e76\u5206\u4eab~ \u4f7f\u7528 PHP SoapClient \u7c7b\u8c03\u7528 SOAP \u670d\u52a1\u7684\u6b65\u9aa4\uff1a\u4f7f\u7528 $wsdl \u548c $options \u521b\u5efa SoapClient \u5bf9\u8c61\u3002\u4f7f\u7528 $functionName \u548c $parameters \u8c03\u7528 SOAP \u51fd\u6570\u3002\u89e3\u6790 SOAP \u51fd\u6570\u7684\u54cd\u5e94\u6570\u636e\u5b58\u50a8\u4e8e $result \u4e2d\u3002 PHP \u51fd\u6570\uff1a\u4f7f\u7528 SOAP \u8c03\u7528\u5916\u90e8\u51fd\u6570 SOAP\uff08\u7b80\u5355\u5bf9\u8c61\u8bbf\u95ee\u534f\u8bae\uff09\u662f\u4e00\u79cd XML \u534f\u8bae\uff0c\u7528\u4e8e\u901a\u8fc7\u7f51\u7edc\u4ea4\u6362\u4fe1\u606f\u548c\u8c03\u7528\u8fdc\u7a0b\u51fd\u6570\u3002\u5728 PHP \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684 SoapClient \u7c7b\u6765\u8c03\u7528 SOAP \u670d\u52a1\u3002 \u8bed\u6cd5\uff1a $client = new SoapClient($wsdl, $options); $result = $client-&gt;functionName($parameters); \u5176\u4e2d\uff1a $wsdl \u662f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48500","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48500"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48500\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}