Working with a third party service I got: "SOAP-ERROR: Parsing Schema: unexpected <text> in restriction"
Thought it would be worth it to share. What it is saying is that there is some text in an invalid place. C# seems to ignore it, and if you are using nusoap it doesn't notice it either. But what was causing my problem was something like:
<types>
<schema ...
<simpleType name="some type">
<restriction base="xsd:string">
<enumeration value="foo"/>;
</restriction>
</simpleType>
Note the semicolon (;). Filter that out and your good.
SOAP関数
導入
SOAP拡張モジュールは、 SOAPサーバーおよびクライアントを書くために使用することができます。 本拡張モジュールは、» SOAP 1.1、 » SOAP 1.2 および » WSDL 1.1 規約のサブセットをサポートします。
要件
本拡張モジュールは、 » GNOME xml library を必要とします。 このライブラリをダウンロード/インストールしてください。 libxml-2.5.4 以上が必要です。
インストール手順
本拡張モジュールは、 --enable-soapを指定して PHPのconfigureが行われた場合のみ利用可能です。
実行時設定
php.ini の設定により動作が変化します。
| 名前 | デフォルト | 変更の可否 | 変更履歴 |
|---|---|---|---|
| soap.wsdl_cache_enabled | "1" | PHP_INI_ALL | PHP 5.0.0 から利用可能 |
| soap.wsdl_cache_dir | "/tmp" | PHP_INI_ALL | PHP 5.0.0 から利用可能 |
| soap.wsdl_cache_ttl | "86400" | PHP_INI_ALL | PHP 5.0.0 から利用可能 |
| soap.wsdl_cache_limit | "5" | PHP_INI_ALL | PHP 5.1.5 から利用可能 |
以下に設定ディレクティブに関する 簡単な説明を示します。
定義済みクラス
SoapClient
コンストラクタ
-
SoapClient->__construct() - constructs a new SoapClient object
メソッド
-
SoapClient->__call() - SOAP 関数をコールする (推奨されません)
-
SoapClient->__doRequest() - SOAP リクエストを実行する
-
SoapClient->__getFunctions() - SOAP 関数の一覧を返す
-
SoapClient->__getLastRequest() - 直近の SOAP リクエストを返す
-
SoapClient->__getLastRequestHeaders() - 直近の SOAP リクエストヘッダを返す
-
SoapClient->__getLastResponse() - 直近の SOAP レスポンスを返す
-
SoapClient->__getLastResponseHeaders() - 直近の SOAP レスポンスヘッダを返す
-
SoapClient->__getTypes() - SOAP 型の一覧を返す
-
SoapClient->__setCookie() - SOAP リクエストと共に送信されるクッキーを設定する
-
SoapClient->__soapCall() - SOAP 関数をコールする
SoapFault
コンストラクタ
-
SoapFault->__construct() - 新規 SoapFault オブジェクトを生成する
SoapHeader
SoapHeader は、SOAP ヘッダを渡すもしくは返すための特別な低レベルクラスです。 このクラスは単純なデータホルダーで、 コンストラクタ以外の特別なメソッドを持ちません。このクラスは SOAP ヘッダを渡すための SoapClient->__soapCall() 中、もしくは SOAP レスポンスにおけるヘッダを返すための SOAP ヘッダハンドラ中で使用されます。
コンストラクタ
-
SoapHeader->__construct() - 新規 SoapHeader オブジェクトを生成する
SoapParam
SoapParam は、非 WSDL モードにおけるパラメータの名前付け、 もしくは値を返すための特別な低レベルクラスです。 このクラスは単純なデータホルダーで、 コンストラクタ以外の特別なメソッドを持ちません。
コンストラクタ
-
SoapParam->__construct() - 新規 SoapParam オブジェクトを生成する
SoapServer
コンストラクタ
-
SoapServer->__construct() - 新規 SoapServer オブジェクトを生成する
メソッド
-
SoapServer->addFunction() - SOAP リクエストによって処理される単一もしくはいくつかの関数を追加する
-
SoapServer->getFunctions() - 定義されている関数の一覧を返す
-
SoapServer->handle() - SOAP リクエストを処理する
-
SoapServer->setClass() - SOAP リクエストを処理するクラスを設定する
-
SoapServer->setPersistence() - SoapServer の持続モードを設定する
SoapVar
SoapVar は、非 WSDL モードにおけるパラメータのエンコード、 もしくは値を返すための特別な低レベルクラスです。 このクラスは単純なデータホルダーで、 コンストラクタ以外の特別なメソッドを持ちません。 このクラスは SOAP リクエストもしくはレスポンスにおける型プロパティを 設定したい場合に有効です。
コンストラクタ
-
SoapVar->__construct() - 新規 SoapVar オブジェクトを生成する
定義済み定数
以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。
- SOAP_1_1 (integer)
- SOAP_1_2 (integer)
- SOAP_PERSISTENCE_SESSION (integer)
- SOAP_PERSISTENCE_REQUEST (integer)
- SOAP_FUNCTIONS_ALL (integer)
- SOAP_ENCODED (integer)
- SOAP_LITERAL (integer)
- SOAP_RPC (integer)
- SOAP_DOCUMENT (integer)
- SOAP_ACTOR_NEXT (integer)
- SOAP_ACTOR_NONE (integer)
- SOAP_ACTOR_UNLIMATERECEIVER (integer)
- SOAP_COMPRESSION_ACCEPT (integer)
- SOAP_COMPRESSION_GZIP (integer)
- SOAP_COMPRESSION_DEFLATE (integer)
- SOAP_WAIT_ONE_WAY_CALLS (integer)
- PHP 5.1.0 で追加されました。
- UNKNOWN_TYPE (integer)
- XSD_STRING (integer)
- XSD_BOOLEAN (integer)
- XSD_DECIMAL (integer)
- XSD_FLOAT (integer)
- XSD_DOUBLE (integer)
- XSD_DURATION (integer)
- XSD_DATETIME (integer)
- XSD_TIME (integer)
- XSD_DATE (integer)
- XSD_GYEARMONTH (integer)
- XSD_GYEAR (integer)
- XSD_GMONTHDAY (integer)
- XSD_GDAY (integer)
- XSD_GMONTH (integer)
- XSD_HEXBINARY (integer)
- XSD_BASE64BINARY (integer)
- XSD_ANYURI (integer)
- XSD_ANYXML (integer)
- PHP 5.1.0 で追加されました。
- XSD_QNAME (integer)
- XSD_NOTATION (integer)
- XSD_NORMALIZEDSTRING (integer)
- XSD_TOKEN (integer)
- XSD_LANGUAGE (integer)
- XSD_NMTOKEN (integer)
- XSD_NAME (integer)
- XSD_NCNAME (integer)
- XSD_ID (integer)
- XSD_IDREF (integer)
- XSD_IDREFS (integer)
- XSD_ENTITY (integer)
- XSD_ENTITIES (integer)
- XSD_INTEGER (integer)
- XSD_NONPOSITIVEINTEGER (integer)
- XSD_NEGATIVEINTEGER (integer)
- XSD_LONG (integer)
- XSD_INT (integer)
- XSD_SHORT (integer)
- XSD_BYTE (integer)
- XSD_NONNEGATIVEINTEGER (integer)
- XSD_UNSIGNEDLONG (integer)
- XSD_UNSIGNEDINT (integer)
- XSD_UNSIGNEDSHORT (integer)
- XSD_UNSIGNEDBYTE (integer)
- XSD_POSITIVEINTEGER (integer)
- XSD_NMTOKENS (integer)
- XSD_ANYTYPE (integer)
- SOAP_ENC_OBJECT (integer)
- SOAP_ENC_ARRAY (integer)
- XSD_1999_TIMEINSTANT (integer)
- XSD_NAMESPACE (string)
- XSD_1999_NAMESPACE (string)
目次
- is_soap_fault — SOAP コールが失敗したかどうかを調べる
- SoapClient->__call() — SOAP 関数をコールする (推奨されません)
- SoapClient->__construct() — SoapClient コンストラクタ
- SoapClient->__doRequest() — SOAP リクエストを実行する
- SoapClient->__getFunctions() — SOAP 関数の一覧を返す
- SoapClient->__getLastRequest() — 直近の SOAP リクエストを返す
- SoapClient->__getLastRequestHeaders() — 直近の SOAP リクエストヘッダを返す
- SoapClient->__getLastResponse() — 直近の SOAP レスポンスを返す
- SoapClient->__getLastResponseHeaders() — 直近の SOAP レスポンスヘッダを返す
- SoapClient->__getTypes() — SOAP 型の一覧を返す
- SoapClient->__setCookie() — SOAP リクエストと共に送信されるクッキーを設定する
- SoapClient->__soapCall() — SOAP 関数をコールする
- SoapFault->__construct() — SoapFault コンストラクタ
- SoapHeader->__construct() — SoapHeader コンストラクタ
- SoapParam->__construct() — SoapParam コンストラクタ
- SoapServer->addFunction() — SOAP リクエストによって処理される単一もしくはいくつかの関数を追加する
- SoapServer->__construct() — SoapServer コンストラクタ
- SoapServer->fault() — エラーを示す SoapServer フォールト を発行する
- SoapServer->getFunctions() — 定義されている関数の一覧を返す
- SoapServer->handle() — SOAP リクエストを処理する
- SoapServer->setClass() — SOAP リクエストを処理するクラスを設定する
- SoapServer->setPersistence() — SoapServer の持続モードを設定する
- SoapVar->__construct() — SoapVar コンストラクタ
- use_soap_error_handler — SOAP エラーハンドラを使用して前の値を返すかどうかを設定する
SOAP
14-Jan-2008 12:59
11-Jan-2008 08:52
From the "I'll just do it manually" school of frustration.
If you've been having trouble getting complex types to work with no, or an entirely non-descript wsdl (my particular complaint... every method just has one child, a complex type element sequence of any... unnngh). Anyway I found the following works to fully replace the contents of the soap body with a pre-built xml string. I haven't tested what this does for calls expecting multiple parameters, since that usually means I can call it with an actual paremeters argument, but I imagine it would still work the same way.
----------------------------------
$Result=$Client->SomeCall(new SoapVar('<Element attr="AttrValue">ElValue</Element>', XSD_ANYXML));
----------------------------------
it's really quite hackish and I'd prefer to know the proper method to add custom arguments to a SoapVar or SoapParam Object, but this worked and I'm leaving it there for now so can I lose the urge to break things.
NOTE: documentation says XSD_ANYXML wasn't added until 5.1.0
07-Dec-2007 06:31
If you are working
- on localhost
- in WSDL mode
and encounter the following error when you try to connect the soap client with the soap server
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host...
then change "localhost" to "127.0.0.1" in your WSDL file:
<soap:address location='http://127.0.0.1/soap-server.php'/>
06-Dec-2007 10:24
Hi,
I'd like to add this trick to get SoapClient correctly running with a WSDD-generated Axis 1 webservice.
By default, Apache Axis 1 generates a SOAP RPC/Encoded WSDL with "urn:" prefixes before all <SERVICE_NAME> occurrences.
Axis 1 WSDL also uses an "impl:" namespace prefix.
Suppose your service's name is "myWS", your WSDL will contains a "<wsdl:binding>" element with the name attribute valued "urn:myWSSoapBinding":
<wsdl:binding name="myWSSoapBinding">
PHP SoapClient has a problem (I hope it will be fixed soon ) parsing this WSDL and generates this error:
SOAP-ERROR: Parsing WSDL: No element with name 'myWSSoapBinding'
This error arise because PHP SoapClient could not resolve the "urn:impl:myWSSoapBinding" QName in generated WSDL:
<wsdl:service name="myWSService">
<wsdl:port binding="impl:urn:myWSSoapBinding" name="urn:myWS">
<wsdlsoap:address location="http://URL/services/urn:myWS"/>
</wsdl:port>
</wsdl:service>
To solve this problem I parse WSDL applying a preg_replace to delete all "urn:" occurrences.
Then I save this generated WSDL somewhere in my site and point my SoapClient to this location.
I also need to specify additional parameters to SoapClient constructor:
<?php
$soap = new SoapClient("wsdl/myWS.wsdl",
array(
"style" => SOAP_RPC,
"use" => SOAP_ENCODED,
"soap_version" => SOAP_1_1,
"uri"=>"urn:myWS"
));
?>
I suggest you this resources to a full understanding of this kind of problems:
http://www.ibm.com/developerworks/
webservices/library/ws-whichwsdl/
http://wso2.org/wiki/display/wsfphp/
PHP+SOAP+Extension+API+-+Backward+Compatibility
I hope this save you hours of imprecations! :)
Emanuele Colonnelli
28-Nov-2007 09:05
this might be helpful, as it took quite some time for me to find this out:
if you're using some .wsdl and there's a sequence that can be there more than once (ie: maxOccurs > 1), you can specify an non-associative array for it if you have more than 1 items OR you could just specify the one item if there is only one:
<?php
'items' => array(
array(
'itemId' => 5,
'name' => 'some name',
),
array(
'itemId' => 6,
'name' => 'some other name',
),
),
?>
this also works:
<?php
'items' => array(
'itemId' => 5,
'name' => 'some name',
),
?>
28-Nov-2007 01:58
I had to add the following to be able to call the PHP webservice from .Net Client
It seems that eighter PHPs implementation of SoapServer or Microsofts .Net way is wrong. The Namespace SOAP-ENV must be removed inside of the SOAP-ENV:Body
function callback($input) {
$search = '/(<SOAP-ENV:Body>)\s*(<SOAP-ENV:)/';
$replace = '$1<';
$input = preg_replace($search, $replace, $input);
$search = '/(<\/SOAP-ENV:)([A-Za-z0-9]*>)\s*(<\/SOAP-ENV:Body>)/';
$replace = '</$2$3';
$input = preg_replace($search, $replace, $input);
return ($input);
}
ob_start('callback');
$server->handle();
ob_end_flush();
27-Nov-2007 04:54
when dealing with wsdl and flash soap with php
(not exactly php, but proper wsdl - took me hours to figure it to work properly in flash webservice)
when naming definitions,
don't use "tns:" but use "typens:"
makesure your "definitions/targetNamespace"
is same as your "soap:body" namespace
example: "urn:mynamespace"
makesure your "binding/type" is declared with "typens"
makesure your service/port/binding is set to 'typens:...'
if you did not do it properly, you will end up with
WSDL.UnrecognizedNamespace - in flash
but seems okay in php soapclient...
happy coding :)
hope this help you to save your time on the wsdl :)
24-Nov-2007 06:45
If you use wsdl,
makesure you define the input correctly.
if your method does not contain any input parameter,
you got to makesure that you:
- do not create the message tag for the input..
- do not put input within porttype / operation
- do not put input within binding / operation
if not, you will get the error:
[Client] looks like we got no XML
d***, took me several hours figuring that out...
24-Nov-2007 12:15
A word of warning:
Do NOT use associative arrays or arrays not starting with element number 0...
Various versions of the soap extension will not send it through properly.
22-Nov-2007 08:33
I had the "DTD are not supported by SOAP" message, too. It helped me to var_dump the complete "SoapFault" exception to find helpful information in a field "["faultstring"]=>....".
It was an error my soap handler (adding a non existant function).
21-Jun-2007 08:31
I hope this will save someone time. When developing and testing your SOAP server, remember to disable WSDL caching in BOTH client and server:
$ini = ini_set("soap.wsdl_cache_enabled", 0);
12-Jun-2007 12:56
When encountering an error message like this
[faultstring] => Function ("yourMethod") is not a valid method for this service
although it is present in the WSDL etc., be aware that PHP caches the wsdl locally for better performance. You can disable the caching via php.ini/.htaccess completely or remove the cache file (/tmp/wsdl-.. if you are on Linux) to force regeneration of it.
17-May-2007 06:22
In case your soap response containts an ampersand, in certain cases you might get an "unterminated entity reference" warning and data might appear truncated (related to bug #36795?). Maybe there is a more formal fix or setting, but since I couldn't find anything I came with the following:
class MySoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$res = parent::__doRequest($request, $location, $action, $version);
$resx = str_replace('&', '&amp;', $res);
print_r($resx);
return ($resx);
}
}
27-Mar-2007 07:59
A note for ppl who use certificates with SOAP under a Windows config: it seems to be required to give the full path to the certificate file - and don't prepend 'file://' :
<?php
$wsdl = "test.wsdl";
$local_cert = "c:\htdocs\mycert.pem";
$passphrase = "xyz";
$client = new SoapClient($wsdl, array('local_cert' => $local_cert, 'passphrase' => $passphrase);
?>
10-Feb-2007 12:38
If you dont want to manually maintain the classmap, make sure you use the same names for your PHP object classes and your WSDL complexTypes, and use the following code:
$classmap = array();
$tmpClient = new SoapClient("soapserver.wsdl");
foreach($tmpClient->__getTypes() as $type)
{
$array = split(" ", $type);
if($array[0] == "struct" && class_exists($array[1]))
{
$classmap[$array[1]] = $array[1];
}
}
unset($tmpClient);
$server = new SoapServer("soapserver.wsdl", array("classmap" => $classmap));
unset($classmap);
$server->setClass("someclass");
$server->handle();
07-Feb-2007 11:32
I recently found that when using SoapClient with client certificates (the 'local_cert' and 'passphrase' options), PHP needs to have CURL enabled. (At least with PHP 5 and Apache on Windows)
I kept getting errors like this:
Unable to set local cert chain file `filename.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in somescript.php on line ##
I tried everything I could find on the net (correct .pem format, constructing and passing my own stream context, etc) but nothing would work. Enabling CURL (by uncommenting extension=php_curl.dll in php.ini) instantly caused my client to work.
19-Jan-2007 02:45
For those working from a wsdl full of complex types that just want a class structure to hang your code on and not worry about typing in long parameter lists (or creating a script to do so): wsdl2php is a wonderful time-saver. Gets a structure going so you can go in and add what validation and special data munging you need: http://www.urdalen.no/wsdl2php/
Big up yourself, Knut.
22-Nov-2006 06:48
If you use SSL with a cert and password authentication:
$wsdl = "https://ws.ecopatz.de/ProductInfo?wsdl";
$pass = 'a password';
$certFile = "./mycert.pem";
$client = new SoapClient($wsdl,
array(
'local_cert' => $certFile,
'passphrase' => $pass
)
);
If you have problems with the certfile like this:
Warning: SoapClient::__construct(): Unable to set local cert chain file `./mycert.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in productinfo.php on line 27
then the certFile is probably in the "wrong format" (the wrong format for php maybe). It worked for me, when i appended the content of the private key file and the certificate file to a single file "mycert.pem":
cat mycert.key >mycert.pem # mycert.key was the private key
cat mycert.crt >>mycert.pem # mycert.crt was the signed certificate
Thanks to an author somewhere, who pointed to "curl --cert", where this little "so unimportant" dependency has been mentioned.
17-Nov-2006 01:27
When compiling SOAP support for PHP 5.2.0 it was not sufficient to use "--with-soap" in the "./configure" statement. I also had to include "--enable-soap" to get it work.
25-Aug-2006 10:20
If you want to build a Soap Server for Microsoft Office's client (like Microsoft Office Research Service) you need to rewrite SOAP's namespaces :
<?php
// (...)
$server = new SoapServer($wsdl, array('uri' => $uri, 'classmap' => $classmap));
$server->setClass($class);
function callback($buffer)
{
$s = array('<ns1:RegistrationResponse>', 'ns1:', 'xmlns:ns1="urn:Microsoft.Search"');
$r = array('<RegistrationResponse xmlns="urn:Microsoft.Search">', '', '');
return (str_replace($s, $r, $buffer));
}
ob_start('callback');
$server->handle();
ob_end_flush();
// (...)
?>
There are a complete example at this URL : http://touv.ouvaton.org/article.php3?id_article=104
23-Aug-2006 04:30
If you want to use soap over https, you *must* compile php with the configure option with-openssl or you will have the error "[HTTP] SSL support not available in this build" while trying to use the web services over SSL
09-Jul-2006 08:54
wokan at cox dot net is incorrect about the security of URI-passed values to HTTPS URIs. HTTPS connections are HTTP inside SSL -- all of the HTTP traffic, including the request, are encrypted.
14-Mar-2006 11:26
To enable SoapClient on Windows, simply add a line:
extension=php_soap.dll
in php.ini in the extensions section.
02-Mar-2006 04:27
Wondering why the function you just added to your WSDL file is not available to your SOAP client? Turn off WSDL caching, which (as the documentation says) is on by default.
At the top of your script, use:
$ini = ini_set("soap.wsdl_cache_enabled","0");
21-Jan-2006 01: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.
17-Jan-2006 04: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 ---
19-Dec-2005 01: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
// complexTypes being an array containing several instances of SomeComplexType
myWSParameter = array();
foreach (complexTypes as ct)
{
// Don't misspell the type or the namespace. Also note that php won't assume the default namespace defined in the WSDL file.
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
// Here, we will be echoing each return item
$res = $someWS->myFunction($myArgs)
// If only one element is returned, an array won't be built
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.
24-Oct-2005 03: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();
12-Oct-2005 05: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...
30-Sep-2005 01:32
Those having to work with Paypal's api and using PHP5 SOAP:
http://www.johnjawed.com/ppo/
23-Sep-2005 01: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"));
21-Jul-2005 03: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
}
?>
13-Jul-2005 08: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";
18-May-2005 04: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
12-May-2005 05: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)
19-Apr-2005 12:12
If you're having problems calling a .NET web service, see the comments over on http://php.net/soap_soapclient_soapcall (the __soapCall method).
26-Mar-2005 05:04
Here are 73 test cases that detail the kinds of schemas that PHP5 currently supports and the structures you are expected to plug into them for the return value from your services. Much better than trying to guess!
http://cvs.php.net/co.php/pecl/soap/tests/schema
You can cycle through the listings by changing the main index in the URL below, rather than go in and out of the pages
http://cvs.php.net/co.php/pecl/soap/tests/schema/schema052.phpt?r=1.2
I downloaded the whole thing with this, CVS might work too.
http://www.httrack.com/
With them all downloaded I just browse them with Textpad.
22-Feb-2005 09: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.
06-Feb-2005 10: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.
26-Jan-2005 02:11
this is something i wrote to access a webservice with php4
http://kouba.at/projects/soap/
here i found a good collection of tutorials all around soap/web services and/or rss:
http://www.dynamic-webpages.de/05.tutorials.php?kategorie=39
30-Mar-2004 01: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.