SOAP extension and object records
| From: | Giovanni Giacobbi | Date: | Sat, 08 Mar 2008 09:40:07 +0000 |
| Subject: | SOAP extension and object records | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-36060@lists.php.net to get a copy of this message | ||
Greetings,
I'm a newbie in SOAP, and I'm doing my first experiments using PHP. I suspect there is a
bug in records processing, but I thought it was useful to discuss it here before submitting a
possibly bogus bug report.
I'll explain briefly the test case, but before a tiny side note: I've been reading thru
the ext/soap source code and cleaned up some white spaces. Shall I submit that patch?
Back in topic, I define a simple record type:
<schema xmlns:tns="urn:testing" xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:testing">
<complexType name="Product">
<all>
<element name="id" type="int" />
<element name="title" type="string" />
<element name="description" type="string" minOccurs="0"
/>
</all>
</complexType>
</schema>
And a simple operation:
<message name="genericObjectId">
<part name="id" type="xsd:int" />
</message>
<message name="ProductCommit">
<part name="product" type="tns:Product" />
</message>
<operation name="ProductCommit">
<input message="ProductCommit" />
<output message="genericObjectId" />
</operation>
Now the SOAP envelope. First a complete record but with bogus data (a string in place of the int):
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<product>
<id>hello</id>
<title>Product name</title>
</product>
</soap:Body>
</soap:Envelope>
So far all fine, a SOAP fault is returned:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>SOAP-ERROR:
Encoding: Violation of encoding
rules</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
But if I submit an incomplete record no errors are returned:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<product>
<title>Product name</title>
</product>
</soap:Body>
</soap:Envelope>
The server callback function is called with the following arguments:
array(1) {
[0]=>
object(stdClass)#2 (1) {
["title"]=>
string(12) "Product name"
}
}
But I'd expect another encoding violation fault, because there was NOT minOccurs="0"
in Product's <id> element definition. Am I doing something wrong?
Thank you
--
Giovanni Giacobbi