ウェブサーバーの 2 つのモード
PHP 使用soap有两种方式。 一、用wsdl文件 服务器端。 <?php class service { public function HelloWorld() { return "Hello"; } public function Add($a,$b) { return $a+$b; } } $server=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2)); $server->setClass("service"); $server->handle(); ?> 资源描述文件,可以用工具(zend studio)生成。其实就是一个xml文件。 <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost/interface/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="soap" targetNamespace="http://localhost/interface/"> <wsdl:types> <xsd:schema targetNamespace="http://localhost/interface/"> <xsd:element name="HelloWorld"> <xsd:complexType> <xsd:sequence> <xsd:element name="in" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="HelloWorldResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="out" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Add"> <xsd:complexType> <xsd:sequence> <xsd:element name="in" type="xsd:int"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="AddResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="out" type="xsd:int"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types> <wsdl:message name="AddRequest"> <wsdl:part name="a" type="xsd:int"></wsdl:part> <wsdl:part name="b" type="xsd:int"></wsdl:part> </wsdl:message> <wsdl:message name="AddResponse"> <wsdl:part name="c" type="xsd:int"></wsdl:part> </wsdl:message> <wsdl:portType name="TestSoap"> <wsdl:operation name="Add"> <wsdl:input message="tns:AddRequest"></wsdl:input> <wsdl:output message="tns:AddResponse"></wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="soapSOAP" type="tns:TestSoap"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="Add"> <soap:operation soapAction="http://localhost/interface/Add" /> <wsdl:input> <soap:body use="literal" namespace="http://localhost/interface/" /> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="http://localhost/interface/" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="TestSoap"> <wsdl:port binding="tns:soapSOAP" name="soapSOAP"> <soap:address location="http://localhost/interface/myservice.php"/> </wsdl:port> </wsdl:service> </wsdl:definitions> 客户端调用 <?php $soap = new SoapClient('http://localhost/interface/soap.wsdl'); echo $soap->Add(1,2); ?> 二、不用wsdl文件 服务器端 <?php class service { public function HelloWorld() { return "Hello"; } public function Add($a,$b) { return $a+$b; } } $server=new SoapServer(null,array('uri' => "abcd")); $server->setClass("service"); $server->handle(); ?> 客户端 <?php try{ $soap = new SoapClient(null,array( "location" => "http://localhost/interface/soap.php", "uri" => "abcd", //资源描述符服务器和客户端必须对应 "style" => SOAP_RPC, "use" => SOAP_ENCODED )); echo $soap->Add(1,2); }catch(Exction $e){ echo print_r($e->getMessage(),true); } ?>
著作権表示: この記事はブロガーによるオリジナルの記事であり、ブロガーの許可なく複製することはできません。
上記は、Web サーバーの 2 つのモードを内容も含めて紹介しましたが、PHP チュートリアルに興味のある友人に役立つことを願っています。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









Laravelは、直感的なフラッシュメソッドを使用して、一時的なセッションデータの処理を簡素化します。これは、アプリケーション内に簡単なメッセージ、アラート、または通知を表示するのに最適です。 データは、デフォルトで次の要求のためにのみ持続します。 $リクエスト -

PHPクライアントURL(CURL)拡張機能は、開発者にとって強力なツールであり、リモートサーバーやREST APIとのシームレスな対話を可能にします。尊敬されるマルチプロトコルファイル転送ライブラリであるLibcurlを活用することにより、PHP Curlは効率的なexecuを促進します

Laravelは簡潔なHTTP応答シミュレーション構文を提供し、HTTP相互作用テストを簡素化します。このアプローチは、テストシミュレーションをより直感的にしながら、コード冗長性を大幅に削減します。 基本的な実装は、さまざまな応答タイプのショートカットを提供します。 Illuminate \ support \ facades \ httpを使用します。 http :: fake([[ 'google.com' => 'hello world'、 'github.com' => ['foo' => 'bar']、 'forge.laravel.com' =>

顧客の最も差し迫った問題にリアルタイムでインスタントソリューションを提供したいですか? ライブチャットを使用すると、顧客とのリアルタイムな会話を行い、すぐに問題を解決できます。それはあなたがあなたのカスタムにより速いサービスを提供することを可能にします

記事では、PHP 5.3で導入されたPHPの後期静的結合(LSB)について説明し、より柔軟な継承を求める静的メソッドコールのランタイム解像度を可能にします。 LSBの実用的なアプリケーションと潜在的なパフォーマ

この記事では、フレームワークにカスタム機能を追加し、アーキテクチャの理解、拡張ポイントの識別、統合とデバッグのベストプラクティスに焦点を当てています。

PHP開発でPHPのCurlライブラリを使用してJSONデータを送信すると、外部APIと対話する必要があることがよくあります。一般的な方法の1つは、Curlライブラリを使用して投稿を送信することです。
