note 110233 added to class.soapfault
| From: | fbernoldi at gmail dot com | Date: | Wed, 03 Oct 2012 17:46:33 +0000 |
| Subject: | note 110233 added to class.soapfault | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191119@lists.php.net to get a copy of this message | ||
Hi all,
I've decided to post this since it may be helpful, I've spend a couple of days trying to
do this.
In order to use wsdl's specified faults with complex types, i.e:
WSDL definitions:
(xsd:schema namespace, ns1 = target namespace)
<xsd:element name="doubleFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="detail1" type="xsd:string"/>
<xsd:element name="detail2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
WSDL messages:
<message name="fault_specified">
<part name="relevant_name" element="ns1:doubleFault"/>
</message>
WSDL port type:
<portType name="test">
<operation name="operationTest">
<input message="ns1:not_relevant_request"/>
<output message="ns1:not_relevant_response"/>
<fault name="FaultSpecified" message="ns1:fault_specified"/>
....
</portType>
You have to specify the response in the detail parameter as an array corresponding the tag names.
PHP Code:
<?php
function operationTest($request_param ...) {
// ...
$array_details = array("detail1" => "Explanation 1", "detail2"
=> "Explanation 2");
return new SoapFault("Server", "example fault string", null, $array_details,
"FaultSpecified");
}
$server = new SOAPServer("handmade.wsdl");
$server->addFunction("operationTest");
$server->handle();
?>
that should respond something like this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://mynamespace">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>example fault string</faultstring>
<detail>
<ns1:doubleFault>
<detail1>Explanation 1</detail1>
<detail2>Explanation 2</detail2>
</ns1:doubleFault>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I Hope it helps,
Federico.
----
Server IP: 69.147.83.199
Probable Submitter: 190.210.112.40
----
Manual Page -- http://www.php.net/manual/en/class.soapfault.php
Edit -- https://master.php.net/note/edit/110233
Del: integrated -- https://master.php.net/note/delete/110233/integrated
Del: useless -- https://master.php.net/note/delete/110233/useless
Del: bad code -- https://master.php.net/note/delete/110233/bad+code
Del: spam -- https://master.php.net/note/delete/110233/spam
Del: non-english -- https://master.php.net/note/delete/110233/non-english
Del: in docs -- https://master.php.net/note/delete/110233/in+docs
Del: other reasons-- https://master.php.net/note/delete/110233
Reject -- https://master.php.net/note/reject/110233
Search -- https://master.php.net/manage/user-notes.php