00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 include_once( "lib/ezutils/classes/ezdebug.php" );
00039 include_once( "lib/ezxml/classes/ezxml.php" );
00040 include_once( "lib/ezsoap/classes/ezsoapparameter.php" );
00041 include_once( 'lib/ezsoap/classes/ezsoapcodec.php' );
00042 include_once( "lib/ezsoap/classes/ezsoapenvelope.php" );
00043
00044 class eZSOAPRequest extends eZSOAPEnvelope
00045 {
00046
00047
00048
00049
00050
00051
00052
00053
00054 function eZSOAPRequest( $name="", $namespace="", $parameters = array() )
00055 {
00056 $this->Name = $name;
00057 $this->Namespace = $namespace;
00058
00059
00060 $this->eZSOAPEnvelope();
00061
00062 foreach( $parameters as $name => $value )
00063 {
00064 $this->addParameter( $name, $value );
00065 }
00066 }
00067
00068
00069
00070
00071 function name()
00072 {
00073 return $this->Name;
00074 }
00075
00076
00077
00078
00079 function namespace()
00080 {
00081 return $this->Namespace;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091 function addBodyAttribute( $name, $value, $prefix = false )
00092 {
00093 $this->BodyAttributes[] = eZDOMDocument::createAttributeNode( $name, $value, $prefix );
00094 }
00095
00096
00097
00098
00099
00100 function addParameter( $name, $value )
00101 {
00102 $this->Parameters[] = new eZSOAPParameter( $name, $value );
00103 }
00104
00105
00106
00107
00108 function payload()
00109 {
00110 $doc = new eZDOMDocument();
00111 $doc->setName( "eZSOAP message" );
00112
00113 $root = $doc->createElementNodeNS( EZ_SOAP_ENV, "Envelope" );
00114
00115 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_XSI_PREFIX, EZ_SOAP_SCHEMA_INSTANCE ) );
00116 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_XSD_PREFIX, EZ_SOAP_SCHEMA_DATA ) );
00117 $root->appendAttribute( $doc->createAttributeNamespaceDefNode( EZ_SOAP_ENC_PREFIX, EZ_SOAP_ENC ) );
00118
00119 $root->setPrefix( EZ_SOAP_ENV_PREFIX );
00120
00121
00122 $body = $doc->createElementNode( "Body" );
00123 $body->appendAttribute( $doc->createAttributeNamespaceDefNode( "req", $this->Namespace ) );
00124
00125 foreach( $this->BodyAttributes as $attribute )
00126 {
00127 $body->appendAttribute( $attribute );
00128 }
00129
00130 $body->setPrefix( EZ_SOAP_ENV_PREFIX );
00131 $root->appendChild( $body );
00132
00133
00134 $request = $doc->createElementNode( $this->Name );
00135 $request->setPrefix( "req" );
00136
00137
00138 foreach ( $this->Parameters as $parameter )
00139 {
00140 unset( $param );
00141 $param = eZSOAPCodec::encodeValue( $parameter->name(), $parameter->value() );
00142
00143 if ( $param == false )
00144 {
00145 eZDebug::writeError( "Error encoding data for payload: " . $parameter->name(), "eZSOAPRequest::payload()" );
00146 continue;
00147 }
00148 $request->appendChild( $param );
00149 }
00150
00151 $body->appendChild( $request );
00152
00153 $doc->setRoot( $root );
00154 return $doc->toString();
00155 }
00156
00157
00158 var $Name;
00159
00160
00161 var $Namespace;
00162
00163
00164 var $BodyAttributes = array();
00165
00166
00167 var $Parameters = array();
00168 }
00169
00170 ?>