|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-06 10:09 UTC] mattsch at gmail dot com
Description:
------------
This is somewhat related to the tuscany bug early about xsi:type. There are schemas that rely on the xsi:type and without it, the xml request/response will be unintelligible. Don't remove the xsi:type.
Reproduce code:
---------------
public function toXML($sdo)
{
SCA::$logger->log('Entering');
SCA::$logger->log("sdo = $sdo");
try
{
$xdoc = $this->xmldas->createDocument('', 'BOGUS', $sdo);
$xmlstr = $this->xmldas->saveString($xdoc, 0);
// remove the xsi:type="<type of the top level element>" and its preceding blank
#Don't remove the xsi:type
# $xmlstr = preg_replace('/ xsi:type=".*"/','',$xmlstr);
SCA::$logger->log("xml = $xmlstr");
return $xmlstr;
}
catch( Exception $e )
{
$problem = $e->getMessage();
if ( $e instanceof SDO_Exception )
$problem = "SDO_Exception in toXML : " . $problem ;
/**
* Depending on whether the function is being used on the client side
* or the server side either report the problem to the client, or
* record the problem in the error.log
*/
trigger_error($problem);
/* When the 'TypeHandler is being used by the Soap Server */
if ( strcmp($this->association, self::SERVER) === 0)
SoapServer::fault("Client", "Unable to encode to XML");
}/* End trap problem
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
My point in my last posting was that actually we do not have an abstract complex type in this example. The wsdl that we generate defines the messages and responses as elements, not complex types e.g.: <xs:element name="reverseResponse"> <xs:complexType> <xs:sequence> <xs:element name="reverseReturn" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> ... here it is an error to have an xsi:type. If you use XERCES to try to parse xml with an xsi:type like the following you will get an error. <tns2:reverseResponse xsi:type="tns2:reverseResponse" <!-- error !!! -> xmlns:tns2="http://SoapHandlerTestComponent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tns2:reverseReturn>MBI</tns2:reverseReturn> </tns2:reverseResponse> So my point was that because the wsdl defines elements not types, there should never be an xsi:type for the top-level message or response in the generated xml. The preg that you suggested taking out was there to stop us generating it, a left-over from a time when we were generating when we shouldn't. As I said I am happy to take it out, and will do so, but I don't believe it was doing any harm.