|
użytkowników online: 59
|
OPINIE UŻYTKOWNIKÓW
|
Uważam, że serwis jest najlepszy na świecie. Wykonany rzetelnie, a wszystkie skrypty sa dopracowane. Zamieszczony materiał godny mistrza. Jestem programistą od wielu lat i bez tego serwisu nie istnieje. Upraszacza życie każdemu programiście. Imponujący jest fakt, że do twórcy serwisu zawsze można się zwrócić z prośbą o pomoc i uzyskuje się ją w bardzo krótkim czasie. Najważniejsze w tym wszystkim jest to, że można korzystać z witryny za symboliczną opłatą.
Marcin Kowalski Multinet Polska
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
CXV. SOAP Functions
The SOAP extension can be used to write SOAP Servers and Clients. It supports
subsets of SOAP 1.1, SOAP 1.2 and WSDL 1.1 specifications.
This extension makes use of the GNOME xml
library. Download and install this library. You will need at
least libxml-2.5.4.
This extension is only available if PHP was configured with
--enable-soap.
Na działanie tych funcji wpływają ustawienia zawarte w pliku
php.ini.
Tabela 1. SOAP Configuration Options | Name | Default | Changeable | Changelog |
|---|
| soap.wsdl_cache_enabled | "1" | PHP_INI_ALL | Available since PHP 5.0.0. | | soap.wsdl_cache_dir | "/tmp" | PHP_INI_ALL | Available since PHP 5.0.0. | | soap.wsdl_cache_ttl | "86400" | PHP_INI_ALL | Available since PHP 5.0.0. |
Szczegóły i definicje dotyczące stałych
PHP_INI_* znajdują się w rozdziale Dodatek H.
Oto krótkie wyjaśnienie dyrektyw
konfiguracji.
- soap.wsdl_cache_enabled
boolean
Enables or disables the WSDL caching feature.
- soap.wsdl_cache_dir
string
Sets the directory name where the SOAP extension will put cache files.
- soap.wsdl_cache_ttl
int
Sets the number of seconds (time to live) that cached files will be used
instead the originals.
SoapHeader is a special low-level class for passing
or returning SOAP headers. It's just a data holder and it does not have any
special methods except its constructor. It can be used in the SoapClient->__soapCall() method to pass a SOAP header or
in a SOAP header handler to return the header in a SOAP response.
SoapParam is a special low-level class for naming
parameters and returning values in non-WSDL mode.
It's just a data holder and it does not have any special methods except
its constructor.
SoapVar is a special low-level class for encoding
parameters and returning values in non-WSDL mode. It's
just a data holder and does not have any special methods except the constructor.
It's useful when you want to set the type property in SOAP request or response.
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy
rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
User Contributed NotesMatthew Glubb
20-Jan-2006 05:05
For anyone wondering why they are getting a "DTD are not supported by SOAP" fault string. It is because you are probably being returned an HTML page due to an internal server error, 404, etc.
Refer to the documentation for SoapClient->__getLastResponse in order to see what returned by the server.
ckl at ecw dot de
17-Jan-2006 08:54
To debug a SOAP service using SoapServer(), a WSDL file and Zend Studio Client/Server, you have to append ?start_debug=1&debug_port=10000 to the service location:
--- snip ---
... method / service definition ....
<service name="SOAPService">
<port
name="SOAPServicePort"
binding="typens:SOAPServiceBinding">
<soap:address
location="$URL?start_debug=1&debug_port=10000"/>
</port>
</service>
--- snap ---
Rui Martins
18-Dec-2005 05:33
Here's an example on how to pass ArrayOfAnyType arguments
containing complex types.
Suppose your WSDL file defines "http://any.url.com/" as the default namespace and a complex type "SomeComplexType".
If you want to call a WebServices which takes an ArrayOfAnyType argument of "SomeComplexType"s you need to perform the following:
<?php
myWSParameter = array();
foreach (complexTypes as ct)
{
myWSParameter []= new SoapVar(ct, 0, "SomeComplexType", "http://any.url.com/");
}
?>
On the other hand, when a WebService returns an ArrayOfAnyType you have to do the following to access each of its elements.
<?php
$res = $someWS->myFunction($myArgs)
if (is_array(myFunctionResult->anyType))
{
foreach (myFunctionResult->anyType as $soapVar)
{
echo $soapVar->enc_value;
}
}
else
{
echo myFunctionResult->anyType->enc_value;
}
?>
This has all been tested using a .NET WebService.
ChrisB
24-Oct-2005 08:03
Heads up for anyone using PHP Soap + Sessions + PEAR DB classes.
Every time you make a call, via the soap client to your web service, your PEAR DB session is put to sleep and it doesnt by default wake upon the next request.
To fix this I simply called my particular database close call ifx_close() below my $soap->handle();
Bob
11-Oct-2005 10:17
If you are scratching your head why NuSOAP not working on PHP 5.x , the reason is this built-in SOAP Extenstion uses same soapclient() class name as Nusoap.
replace 'soapclient' with 'soapclient_xxx' in nusoap.php and you are good to go...
john
29-Sep-2005 06:32
johnjawed at gmail dot com
22-Sep-2005 06:29
For those wondering on how to set attributes on nodes with PHP5 SOAP, it would be done as such:
<... soap env/header>
<foo bar="blah">12345</foo>
array("foo" => array("_" => 12345, "bar" => "blah"));
Darryl
20-Jul-2005 08:46
Having trouble passing complex types over SOAP using a PHP SoapServer in WSDL mode? Not getting decoded properly? This may be the solution you're looking for!
When using ComplexType in the schema portion of the WSDL file, You need use an additional step to tell PHP SOAP how to encode the objects. The first method would be to explicitely encapsulate the object in a SoapVar object - telling PHP to use generalized SOAP encoding rules (which encodes all ComplexTypes as Structs). This won't work, though, if the client is expecting the objects to be encoded according to the WSDL's schema. So, The actual way to do this is:
* First, define a specific PHP class which is actually just a data structure holding the various properties, and the appropriate ComplexType in the WSDL.
<?php
class MyComplexDataType {
public $myProperty1;
public $myProperty2;
}
?>
<complexType name="MyWSDLStructure">
<sequence>
<element name="MyProperty1" type="xsd:integer"/>
<element name="MyProperty2" type="xsd:string"/>
</sequence>
</complexType>
* Next, Tell the SoapServer when you initialize it to map these two structures together.
<?php
$classmap = array('MyWSDLStructure' => 'MyComplexDataType');
$server = new SoapServer("http://MyServer/MyService.wsdl", array('classmap' => $classmap))
?>
* Finally, have your method return an instance of your class directly, and let the SoapServer take care of encoding!
<?php
public function MySoapCall() {
$o = new MyComplexDataType();
$o->myProperty1 = 1;
$o->myProperty2 = "MyString";
return $o
}
?>
Jim Plush
13-Jul-2005 01:45
If you're trying to use the SOAP Extension over SSL with a custom PEM file you need to do this:
$client->_local_cert = "C:\\path\myCert.pem";
pash_ka
18-May-2005 09:52
One good tutorial on using this extension is on IBM web site:
"Using the PHP 5 SOAP extension to consume a WebSphere Web service"
http://www.ibm.com /developerworks/library/os-phpws/?ca=dgr-lnxw06PHP5soap
flobee at gmail dot com
11-May-2005 10:25
wow, actually a cool program and soap is new for me.
I found out some interessting things i can not debug because the scripts exit without any error messages or notes. :-(
you may have problems with the memory and/or especially on "shared servers" when server load is high.
sometimes the script does the job, sometimes it just stopping at any unknown point.
these are the steps my script does:
* get data from remote server ( ~ 4.5 MB)
* parsing requested object and store the data in a database.
the return with debug messages was intressting:
-> check Mem limit: 30M
-> $client = new new SoapClient($url_wsdl, $options);
-> Memory usage: 185888
-> $client->[requested_method_to_get_data]();
-> check: __getLastResponseHeaders() - after:
-> HTTP/1.1 200 OK // remote server is fine with me :-)
-> Content-Length: 4586742 // I got the data
-> check: Memory usage now: 23098872 // ups !!! this can't be true!!
so, and if now someone on the server takes the rest of RAM the walk thought the data breaks :-(
so, i need to store the xml tree ($client->client->__last_response) and parsing it by the classical way. (if you would request more RAM, you may get in trouble with the admin if you run a script like this more often! (on shared servers)
OrionI
18-Apr-2005 05:12
kucerar at hhmi dot org
25-Mar-2005 09:04
Norman Clarke <norman at dontblink dot com>
22-Feb-2005 01:29
Note that if you should need to set the timeout for your soap request, you can use ini_set to change the value for the default_socket_timeout. I previously used NuSOAP, whose soap client class has a timeout option, and it took me a while to figure out that PHP's soap uses the same socket options as everything else.
wokan at cox dot net
06-Feb-2005 02:06
It's not good security practice to pass the username and password in the URI when the point of SSL is to prevent that information from being intercepted. Putting that information in the URI makes it interceptable. HTTPS-Posted values are safe because values passed in the headers are sent after the SSL handshake has been completed.
martin AT kouba DOT at
25-Jan-2005 06:11
03-Dec-2004 04:06
mikx at mikx dot de
29-Mar-2004 06:12
It took me a while to properly establish a password protected client connection via https on windows/apache1.3. Here my little guide:
1. The SOAP extension isn't activated by default (PHP5 RC1). Just add "extension=php_soap.dll" to the php.ini and don't forget to set the extension_dir properly (in most cases "c:\php\ext").
2. Add "extension=php_openssl.dll" to the php.ini. This module depends on libeay32.dll and ssleay32.dll - copy them from your php folder to your system32 folder.
3. Restart apache
4. The sourcecode
$client = new SoapClient("https://yourLogin:yourPassword@foo.com/bar.wsdl", array(
"login" => "yourLogin",
"password" => "yourPassword",
"trace" => 1,
"exceptions" => 0));
$client->yourFunction();
print "<pre>\n";
print "Request: \n".htmlspecialchars($client->__getLastRequest()) ."\n";
print "Response: \n".htmlspecialchars($client->__getLastResponse())."\n";
print "</pre>";
Currently it seems to be necessary to add your login and password both in the uri and in the options array. Not sure if this is the expected behavior.
|