---
title: "PHP【soap】"
author: "crizy"
date: "2012-03-12T19:02:57Z"
tags: ["PHP", "SOAP"]
categories: ["编程语言"]
slug: "php-soap"
draft: false
lastmod: "2012-03-12T19:02:56Z"
id: 1294170
url: "https://crizy.iteye.com/blog/1294170"
---

1.php.ini里开启php\_soap

```
extension=php_soap.dll
```

 

 

2.server.php

```
<?php

class test {
	public function hello() {
		return 'Hello World!';
	}
}

$options = array(
	'uri' => 'http://127.0.0.1/soap/test',
);

$server = new SoapServer(null, $options);

$server->setClass('test');

$server->handle();
```

 

3.client.php

```
<?php

$options = array(
	'uri' => 'http://127.0.0.1/soap/test',
	'location' => 'http://127.0.0.1/soap/server.php',
);

$client = new SoapClient(null, $options);

echo $client->hello();
```

 

4.测试

http://127.0.0.1/soap/client.php