[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZSOAPRequest class 4 // 5 // Created on: <19-Feb-2002 15:42:03 bf> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! 30 \class eZSOAPRequest ezsoaprequest.php 31 \ingroup eZSOAP 32 \brief eZSOAPRequest handles SOAP request messages 33 34 */ 35 36 include_once ( "lib/ezutils/classes/ezdebug.php" ); 37 include_once ( "lib/ezxml/classes/ezxml.php" ); 38 include_once ( "lib/ezsoap/classes/ezsoapparameter.php" ); 39 include_once ( 'lib/ezsoap/classes/ezsoapcodec.php' ); 40 include_once ( "lib/ezsoap/classes/ezsoapenvelope.php" ); 41 42 class eZSOAPRequest extends eZSOAPEnvelope 43 { 44 /*! 45 Constructs a new eZSOAPRequest object. You have to provide the request name 46 and the target namespace for the request. 47 48 \param name 49 \param namespace 50 \param parameters, assosiative array, example: array( 'param1' => 'value1, 'param2' => 'value2' ) 51 */ 52 function eZSOAPRequest( $name="", $namespace="", $parameters = array() ) 53 { 54 $this->Name = $name; 55 $this->Namespace = $namespace; 56 57 // call the parents constructor 58 $this->eZSOAPEnvelope(); 59 60 foreach( $parameters as $name => $value ) 61 { 62 $this->addParameter( $name, $value ); 63 } 64 } 65 66 /*! 67 Returns the request name. 68 */ 69 function name() 70 { 71 return $this->Name; 72 } 73 74 /*! 75 Returns the request target namespace. 76 */ 77 function namespace() 78 { 79 return $this->Namespace; 80 } 81 82 /*! 83 Adds a new attribute to the body element. 84 85 \param attribute name 86 \param attribute value 87 \param prefix 88 */ 89 function addBodyAttribute( $name, $value, $prefix = false ) 90 { 91 $this->BodyAttributes[] = eZDOMDocument::createAttributeNode( $name, $value, $prefix ); 92 } 93 94 /*! 95 Adds a new parameter to the request. You have to provide a prameter name 96 and value. 97 */ 98 function addParameter( $name, $value ) 99 { 100 $this->Parameters[] = new eZSOAPParameter( $name, $value ); 101 } 102 103 /*! 104 Returns the request payload 105 */ 106 function payload() 107 { 108 $doc = new eZDOMDocument(); 109 $doc->setName( "eZSOAP message" ); 110 111 $root = $doc->createElementNodeNS( EZ_SOAP_ENV, "Envelope" ); 112 113 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_XSI_PREFIX, EZ_SOAP_SCHEMA_INSTANCE ) ); 114 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_XSD_PREFIX, EZ_SOAP_SCHEMA_DATA ) ); 115 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_ENC_PREFIX, EZ_SOAP_ENC ) ); 116 117 $root->setPrefix( EZ_SOAP_ENV_PREFIX ); 118 119 // add the body 120 $body = $doc->createElementNode( "Body" ); 121 $body->appendAttribute( $doc->createAttributeNamespaceDefNode( "req", $this->Namespace ) ); 122 123 foreach( $this->BodyAttributes as $attribute ) 124 { 125 $body->appendAttribute( $attribute ); 126 } 127 128 $body->setPrefix( EZ_SOAP_ENV_PREFIX ); 129 $root->appendChild( $body ); 130 131 // add the request 132 $request = $doc->createElementNode( $this->Name ); 133 $request->setPrefix( "req" ); 134 135 // add the request parameters 136 foreach ( $this->Parameters as $parameter ) 137 { 138 unset( $param ); 139 $param = eZSOAPCodec::encodeValue( $parameter->name(), $parameter->value() ); 140 141 if ( $param == false ) 142 eZDebug::writeError( "Error enconding data for payload", "eZSOAPRequest::payload()" ); 143 $request->appendChild( $param ); 144 } 145 146 $body->appendChild( $request ); 147 148 $doc->setRoot( $root ); 149 return $doc->toString(); 150 } 151 152 /// The request name 153 var $Name; 154 155 /// The request target namespace 156 var $Namespace; 157 158 /// Additional body element attributes. 159 var $BodyAttributes = array(); 160 161 /// Contains the request parameters 162 var $Parameters = array(); 163 } 164 165 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |