Php soap data send error - php

When sending data to the SomeMethod() method, the 1 excess parameter returns as an error.
My Code:
$client = new SoapClient('site_url/?wsdl');
$client->soap_defencoding = 'UTF-8';
$loginparam = array('userName'=>'name','password'=>'pass','trace' => 1, 'exceptions' => 0);
$session = $client->OturumAc($loginparam);
$SoapIcHeader = new SoapHeader("http://sanayi.gov.tr","TokenId",$session->OturumAcResult);
$client->__setSoapHeaders($SoapIcHeader);
$OturumUzat = $client->OturumDogrulaVeUzat($session ->OturumAcResult);
$param["BosAgirligi"] = "20";
$param["CalismaBasinci"] = "5";
$param["DoluAgirligi"] = "1";
$param["SonMuayeneTarihi"] = "2017-08-01 10:19:04";
$param["SonMuayeneYapanFirmaMersisNo"] = "123456789";
$param["SuKapasitesi"] = "1";
$param["TestBasinci"] = "10";
$param["DolumBasinci"] = "15";
$param["EtKalinligi"] = "3";
$param["ImalatTarihi"] = "2017-08-01 10:19:04";
$param["SeriNo"] = "123";
$param["TescilEdenTesisId"] = "31fd684c-f97d-48c1-a7fb-60f30f536d8d";
$param["UreticiId"] = "31fd684c-f97d-48c1-a7fb-60f30f536d8d";
// $param["UygunlukIsareti"] = "1";
$date = date('d/m/Y');
$id ="2ad9a9a9-adb9-4fb8-8fae-01e84aa72343";
try
{
$sonuc = $client->TupTescil($id,$date,$param);
print_r($sonuc);
}
catch (Exception $e)
{
echo "Error ! ";
echo $e -> getMessage ();
}
Return Error
Error ! The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'TupTescil'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 281.
This example works with C#
Guid tupKimligi = new Guid("07FAF194-4E80-4359-95D9-011CA1F5A1D4");
DateTime islemSaati = DateTime.Today;
TupTescilBilgisi tescilBilgileri = new TupTescilBilgisi()
{
BosAgirligi = 1,
CalismaBasinci = 1,
DoluAgirligi = 1,
SonMuayeneTarihi = DateTime.Today,
SonMuayeneYapanFirmaMersisNo = "123456789",
SuKapasitesi = 1,
TestBasinci = 1,
DolumBasinci = 1,
EtKalinligi = 1,
ImalatTarihi = DateTime.Today,
SeriNo = "123",
TescilEdenTesisId = tesisId,
UreticiId = ureticiId,
UygunlukIsareti = TupUygunlukIsareti.Pi
};
Tup tescilSonuc = tsc.TupTescil(tupKimligi, DateTime.Today, tescilBilgileri);
You can also look at the wsdl structure here
enter link description here
Thanks for your help

Related

Drupal 7, validate node as per interface

I created a webservice, it works correctly, I was doing the node creation operation and it works correctly.
I need to validate the node I'm about to save in the same way it is validated during the interface insertion form.
I have tried with
drupal_form_submit($nodeType . '_node_form', $form_state, (object) $node);
it keeps giving me errors its node reference fields
Could you suggest other ways to do the same validation that is done by the interface on a programmatically created node?
The error on the node reference field is:
" field_ente : this entry cannot be
referenced. "
The node (6310) exists correctly and if I try to do the node_save, it is saved correctly
the complete function is as follows
function my_ws_resource_create($field_nome = '', $field_cognome = '', $field_codice_fiscale = '', $field_data_di_nascita = '', $field_ente= '')
{
module_load_include('inc', 'node', 'node.pages');
global $user;
$nodeType = 'contatti';
$node = new stdClass();
$node->type = $nodeType;
$node->uid = $user->uid;
$node->status = 1;
$node->revision = 1;
$node->promote = 0;
$node->comment = 0;
node_object_prepare($node);
$node->field_cognome['und'][0]['value'] = $field_cognome;
$node->field_nome['und'][0]['value'] = $field_nome;
$node->field_codice_fiscale['und'][0]['cck_codicefiscale'] = $field_codice_fiscale;
$node->field_data_di_nascita['und'][0]['value'] = $field_data_di_nascita;
$node->field_categoria_contatto['und'][0]['tid'] = '66';
// $node->field_ente = array('und' => array(array('nid'=> $field_ente )));
// this field causes the error
$node->field_ente = array('und' => array(array('nid'=> '6310')));
$node->field_simplenews_term['it'][0]['tid'] = '13660';
$form_state = array();
$form_state['values']['type'] = $nodeType;
$form_state['values']['name'] = $user->name;
$form_state['values']['status'] = 1;
$form_state['values']['promote'] = 1;
$form_state['values']['sticky'] = 0;
$form_state['values']['op'] = t('Save');
drupal_form_submit($nodeType . '_node_form', $form_state, (object) $node);
if ($errors = form_get_errors()) {
return services_error(implode(" ", $errors), 406, array('form_errors' => $errors));
}
return 'Creation successful';
}
I've had success with the following (remove $form_state and replace drupal_form_submit):
if ($node = node_submit($node)) {
node_save($node);
// Success!
}
else {
// Fail :(
}

Error: SQLSTATE[HY093] sending data through HTML/PHP to MySQL

I'm trying to send a lot of data from a form to a mysql database, and I'm getting the following error:
Error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
I know the error is likely related to the amount of fields I'm sending not matching the number of parameters in the query.
Code below:
$stmt = $conn->prepare("INSERT INTO propuestas_emitidas (fecha_operacion, vendedor_codigo, vendedor_nombre, vigencia, plan, persona_tipo, IVA_cond, auto_marca, auto_modelo, auto_anofab, auto_cerokm, auto_suma, auto_uso, auto_rastreo, auto_cp, auto_tarifa, acc1_cod, acc1_desc, acc1_valor, acc2_cod, acc2_desc, acc2_valor, acc3_cod, acc3_desc, acc3_valor, acc4_cod, acc4_desc, acc4_valor, cobertura_tipo, electronica, tit_tipo_persona, tit_tipodoc, tit_nrodoc, tit_apellido, tit_provincia, tit_localidad, tit_calle, tit_altura, tit_piso, tit_dpto, tit_cp, tit_tel1, tit_tel2, tit_sexo, tit_est_civil, tit_nacionalidad, tit_actividad, tit_cuit, tit_mail, tit_prov_nac, tit_loc_nac, tit_fecha_nac, rep_tipodoc, rep_nrodoc, rep_apellido, rep_nombre, vh_patente, vh_chasis, vh_motor, pago_forma, pago_cuotacero, pago_cbu, pago_tarj_nombre, pago_tarj_nro, pago_tarj_vcto, pago_tarj_titular)
VALUES (:fecha_operacion, :vendedor_codigo, :vendedor_nombre, :vigencia, :plan, :persona_tipo, :IVA_cond, :auto_marca, :auto_modelo, :auto_anofab, :auto_cerokm, :auto_suma, :auto_uso, :auto_rastreo, :auto_cp, :auto_tarifa, :acc1_cod, :acc1_desc, :acc1_valor, :acc2_cod, :acc2_desc, :acc2_valor, :acc3_cod, :acc3_desc, :acc3_valor, :acc4_cod, :acc4_desc, :acc4_valor, :cobertura_tipo, :electronica, :tit_tipo_persona, :tit_tipodoc, :tit_nrodoc, :tit_apellido, :tit_provincia, :tit_localidad, :tit_calle, :tit_altura, :tit_piso, :tit_dpto, :tit_cp, :tit_tel1, :tit_tel2, :tit_sexo, :tit_est_civil, :tit_nacionalidad, :tit_actividad, :tit_cuit, :tit_mail, :tit_prov_nac, :tit_loc_nac, :tit_fecha_nac, :rep_tipodoc, :rep_nrodoc, :rep_apellido, :rep_nombre, :vh_patente, :vh_chasis, :vh_motor, :pago_forma, :pago_cuotacero, :pago_cbu, :pago_tarj_nombre, :pago_tarj_nro, :pago_tarj_vcto, :pago_tarj_titular)");
$fecha_operacion = str_replace("/", "", date("d/m/y"));
$vendedor_codigo = $_POST["vendedor_codigo"];
$vendedor_nombre = $_POST["vendedor_nombre"];
$vigencia = $_POST["vigencia"];
$plan = $_POST["plan"];
$persona_tipo = "F";
$IVA_cond = $_POST["IVA_cond"];
$auto_marca = $_POST["auto_marca"];
$auto_modelo = $_POST["auto_modelo"];
$auto_anofab = $_POST["auto_anofab"];
$auto_cerokm = $_POST["auto_cerokm"];
$auto_suma = NULL;
$auto_uso = $_POST["auto_uso"];
$auto_rastreo = $_POST["auto_rastreo"];
$auto_cp = $_POST["auto_cp"];
$auto_tarifa = $_POST["auto_tarifa"];
if (!(isset($_POST["acc1_cod"]))) {
$acc1_cod = NULL;
$acc1_desc = NULL;
$acc1_valor = NULL;
} else {
$acc1_cod = $_POST["acc1_cod"];
$acc1_desc = $_POST["acc1_desc"];
$acc1_valor = $_POST["acc1_valor"];
}
if (!(isset($_POST["acc2_cod"]))) {
$acc2_cod = NULL;
$acc2_desc = NULL;
$acc2_valor = NULL;
} else {
$acc2_cod = $_POST["acc2_cod"];
$acc2_desc = $_POST["acc2_desc"];
$acc2_valor = $_POST["acc2_valor"];
}
if (!(isset($_POST["acc3_cod"]))) {
$acc3_cod = NULL;
$acc3_desc = NULL;
$acc3_valor = NULL;
} else {
$acc3_cod = $_POST["acc3_cod"];
$acc3_desc = $_POST["acc3_desc"];
$acc3_valor = $_POST["acc3_valor"];
}
if (!(isset($_POST["acc4_cod"]))) {
$acc4_cod = NULL;
$acc4_desc = NULL;
$acc4_valor = NULL;
} else {
$acc4_cod = $_POST["acc4_cod"];
$acc4_desc = $_POST["acc4_desc"];
$acc4_valor = $_POST["acc4_valor"];
}
$cobertura_tipo = NULL;
$electronica = NULL;
$tit_tipo_persona = "F";
$tit_tipodoc = $_POST["tit_tipodoc"];
$tit_nrodoc = $_POST["tit_nrodoc"];
$tit_apellido = $_POST["tit_apellido"];
$tit_provincia = $_POST["tit_provincia"];
$tit_localidad = $_POST["tit_localidad"];
$tit_calle = $_POST["tit_calle"];
$tit_altura = $_POST["tit_altura"];
$tit_piso = $_POST["tit_piso"];
$tit_dpto = $_POST["tit_dpto"];
$tit_cp = $_POST["tit_cp"];
$tit_tel1 = $_POST["tit_tel1"];
$tit_tel2 = $_POST["tit_tel2"];
$tit_sexo = $_POST["tit_sexo"];
$tit_est_civil = $_POST["tit_est_civil"];
$tit_nacionalidad = $_POST["tit_nacionalidad"];
$tit_actividad = NULL;
$tit_cuit = $_POST["tit_nrodoc"];
$tit_mail = $_POST["tit_mail"];
$tit_prov_nac = $_POST["tit_prov_nac"];
$tit_loc_nac = $_POST["tit_loc_nac"];
$tit_fecha_nac = $_POST["tit_fecha_nac"];
$rep_tipodoc = $_POST["tit_tipodoc"];
$rep_nrodoc = $_POST["tit_nrodoc"];
$rep_apellido = $_POST["tit_apellido"];
$rep_nombre = $_POST["tit_apellido"];
$vh_patente = NULL;
$vh_chasis = NULL;
$vh_motor = NULL;
$pago_forma = "CBU";
$pago_cuotacero = $_POST["pago_cuotacero"];
$pago_cbu = $_POST["pago_cbu"];
$pago_tarj_nombre = NULL;
$pago_tarj_nro = NULL;
$pago_tarj_vcto = NULL;
$pago_tarj_titular = NULL;
$stmt->bindParam(':fecha_operacion', $fecha_operacion);
$stmt->bindParam(':vendedor_codigo', $vendedor_codigo);
$stmt->bindParam(':vendedor_nombre', $vendedor_nombre);
$stmt->bindParam(':vigencia', $vigencia);
$stmt->bindParam(':plan', $plan);
$stmt->bindParam(':persona_tipo', $persona_tipo);
$stmt->bindParam(':IVA_cond', $IVA_cond);
$stmt->bindParam(':auto_marca', $auto_marca);
$stmt->bindParam(':auto_modelo', $auto_modelo);
$stmt->bindParam(':auto_anofab', $auto_anofab);
$stmt->bindParam(':auto_cerokm', $auto_cerokm);
$stmt->bindParam(':auto_suma', $auto_suma);
$stmt->bindParam(':auto_uso', $auto_uso);
$stmt->bindParam(':auto_rastreo', $auto_rastreo);
$stmt->bindParam(':auto_cp', $auto_cp);
$stmt->bindParam(':auto_tarifa', $auto_tarifa);
$stmt->bindParam(':acc1_cod', $acc1_cod);
$stmt->bindParam(':acc1_desc', $acc1_desc);
$stmt->bindParam(':acc1_valor', $acc1_valor);
$stmt->bindParam(':acc2_cod', $acc2_cod);
$stmt->bindParam(':acc2_desc', $acc2_desc);
$stmt->bindParam(':acc2_valor', $acc2_valor);
$stmt->bindParam(':acc3_cod', $acc3_cod);
$stmt->bindParam(':acc3_desc', $acc3_desc);
$stmt->bindParam(':acc3_valor', $acc3_valor);
$stmt->bindParam(':acc4_cod', $acc4_cod);
$stmt->bindParam(':acc4_desc', $acc4_desc);
$stmt->bindParam(':acc4_valor', $acc4_valor);
$stmt->bindParam(':cobertura_tipo', $cobertura_tipo);
$stmt->bindParam(':electronica', $electronica);
$stmt->bindParam(':tit_tipo_persona', $tit_tipo_persona);
$stmt->bindParam(':tit_tipodoc', $tit_tipodoc);
$stmt->bindParam(':tit_nrodoc', $tit_nrodoc);
$stmt->bindParam(':tit_apellido', $tit_apellido);
$stmt->bindParam(':tit_provincia', $tit_provincia);
$stmt->bindParam(':tit_localidad', $tit_localidad);
$stmt->bindParam(':tit_calle', $tit_calle);
$stmt->bindParam(':tit_altura', $tit_altura);
$stmt->bindParam(':tit_piso', $tit_piso);
$stmt->bindParam(':tit_dpto', $tit_dpto);
$stmt->bindParam(':tit_cp', $tit_cp);
$stmt->bindParam(':tit_tel1', $tit_tel1);
$stmt->bindParam(':tit_tel2', $tit_tel2);
$stmt->bindParam(':tit_sexo', $tit_sexo);
$stmt->bindParam(':tit_est_civil', $tit_est_civil);
$stmt->bindParam(':tit_nacionalidad', $tit_nacionalidad);
$stmt->bindParam(':tit_actividad', $tit_actividad);
$stmt->bindParam(':tit_cuit', $tit_cuit);
$stmt->bindParam(':tit_mail', $tit_mail);
$stmt->bindParam(':tit_prov_nac', $tit_prov_nac);
$stmt->bindParam(':tit_loc_nac', $tit_loc_nac);
$stmt->bindParam(':tit_fecha_nac', $tit_fecha_nac);
$stmt->bindParam(':rep_tipodoc', $rep_tipodoc);
$stmt->bindParam(':rep_apellido', $rep_apellido);
$stmt->bindParam(':rep_nombre', $rep_nombre);
$stmt->bindParam(':vh_patente', $vh_patente);
$stmt->bindParam(':vh_chasis', $vh_chasis);
$stmt->bindParam(':vh_motor', $vh_motor);
$stmt->bindParam(':pago_forma', $pago_forma);
$stmt->bindParam(':pago_cuotacero', $pago_cuotacero);
$stmt->bindParam(':pago_cbu', $pago_cbu);
$stmt->bindParam(':pago_tarj_nombre', $pago_tarj_nombre);
$stmt->bindParam(':pago_tarj_nro', $pago_tarj_nro);
$stmt->bindParam(':pago_tarj_vcto', $pago_tarj_vcto);
$stmt->bindParam(':pago_tarj_titular', $pago_tarj_titular);
$stmt->execute();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
You missed
$stmt->bindParam(':rep_nrodoc', $rep_nrodoc);

getting error to display all record in php json

I am trying to display all records using jason in php.
but display all filed with null value.
I'm using postman for testing purpose.
I don't know what is the problem with that code. I getting null value only.
here is my code :
<?php
header('Content-Type: application/json');
$checkFields = "";
$REQUEST = $_SERVER['REQUEST_METHOD'];
if ($REQUEST == "POST")
{
include "DB/db.php";
$userlist = mysql_query("SELECT * FROM reg_services");
if(mysql_num_rows($userlist) > 0)
{
$p = 0;
$ph = array();
while($userlistdata = mysql_fetch_row($userlist))
{
$ph[$p]["UserId"] = $userlistdata['id'];
$ph[$p]["FirstName"] = $userlistdata['fname'];
$ph[$p]["LastName"] = $userlistdata['lname'];
$ph[$p]["Email"] = $userlistdata['email'];
$ph[$p]["Mobile"] = $userlistdata['mobile'];
$ph[$p]["Password"] = $userlistdata['password'];
$p++;
}
$json = array("success" => 1, "All_User_List" => $ph);
$jsonarray = json_encode($json);
}
}
else
{
$json = array("success" => 0, "message" => "Invalid Request Type(Use POST Method)");
$jsonarray = json_encode($json);
}
echo $jsonarray;
?>
please help me if you are know what is the error in code.
just replace this code with old one
$p = 0;
$ph = array();
while($userlistdata = mysql_fetch_array($userlist))
{
$ph[$p] = array();
$ph[$p]["UserId"] = $userlistdata['id'];
$ph[$p]["FirstName"] = $userlistdata['fname'];
$ph[$p]["LastName"] = $userlistdata['lname'];
$ph[$p]["Email"] = $userlistdata['email'];
$ph[$p]["Mobile"] = $userlistdata['mobile'];
$ph[$p]["Password"] = $userlistdata['password'];
$p++;
}
You need to tell PHP about arrays
while($userlistdata = mysql_fetch_row($userlist))
{
$ph[$p] = array(); // let PHP know it is an array
$ph[$p]["UserId"] = $userlistdata['id'];
$ph[$p]["FirstName"] = $userlistdata['fname'];
$ph[$p]["LastName"] = $userlistdata['lname'];
$ph[$p]["Email"] = $userlistdata['email'];
$ph[$p]["Mobile"] = $userlistdata['mobile'];
$ph[$p]["Password"] = $userlistdata['password'];
$p++;
}
just replace this while loop condition with olde one.
while($userlistdata = mysql_fetch_array($userlist))
now it's work

PHP SoapClient WSDL DeserializationFailed Invalid enum value

I am trying to use SoapClient in PHP to retrieve data from a WSDL. If I use hardcoded values, then it works with zero errors:
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = 'UsedCar';
$params2['ApplicationCategory'] = 'Consumer';
$params2['VersionDate'] = '2016';
$result2 = $client->GetMakes($params2);
I am getting the following error when I use variables or dynamic content:
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed
] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter
http://someURL/VehicleInformationService:VehicleClass
. The InnerException message was 'Invalid enum value 'UsedCars'
I have tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = $VehicleClass;
$params2['ApplicationCategory'] = $ApplicationCategory;
$params2['VersionDate'] = $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = (string) $obj->{'LoginResult'};
$params2['VehicleClass'] = (string) $VehicleClass;
$params2['ApplicationCategory'] = (string) $ApplicationCategory;
$params2['VersionDate'] = (string) $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried:
$SubmitData = new stdClass();
$SubmitData->AuthenticationKey = new SoapVar($obj->{'LoginResult'}, XSD_STRING);
$SubmitData->VehicleClass = new SoapVar($VehicleClass, XSD_STRING);
$SubmitData->ApplicationCategory = new SoapVar($ApplicationCategory, XSD_STRING);
$SubmitData->VersionDate = new SoapVar($VersionDate, XSD_STRING);
$result2 = $client->GetMakes($SubmitData);
Same error each time. I do not know how to get around "Invalid enum value" error
Thanks in advance

PHP-EWS 2010, how to set the IsRead flag

I have been able to successfully retrieve the unread emails from an Exchange 2010 inbox using php-ews API. However after I have fetched the emails, I want to set the IsRead property of the email to true, so that these messages do not appear the next time I fetch emails.
Anyone done this before ?
EDIT :
This is how I am trying to set the IsRead flag :
$message_id = ''; //id of message
$change_key = ''; //change key
$response = $ews->GetItem($request);
//print_r($response);exit;
if( $response->ResponseMessages->GetItemResponseMessage->ResponseCode == 'NoError' &&
$response->ResponseMessages->GetItemResponseMessage->ResponseClass == 'Success' ) {
$a = array();
$message = $response->ResponseMessages->GetItemResponseMessage->Items->Message;
$a['message_body'] = $message->Body->_;
$a['sender'] = $message->From->Mailbox->EmailAddress;
$a['subject'] = $message->ConversationTopic;
$data[] = $a;
//process the message data.
$messageType = new EWSType_MessageType();
$messageType->IsRead = true;
$path = new EWSType_PathToUnindexedFieldType();
$path->FieldURI = 'message:IsRead';
$setField = new EWSType_SetItemFieldType();
$setField->Message = $messageType;
$setField->FieldURI = $path;
$u = new EWSType_ItemChangeType();
$u->Updates = new EWSType_NonEmptyArrayOfItemChangeDescriptionsType();
$u->Updates->SetItemField = $setField;
$u->ItemId = new EWSType_ItemIdType();
$u->ItemId->Id = $message_id;
$u->ItemId->ChangeKey = $change_key;
$updatedItems = new EWSType_NonEmptyArrayOfItemChangesType();
$updatedItems->ItemChange = $u;
$updateMessenger = new EWSType_UpdateItemType();
$updateMessenger->ItemChanges = $updatedItems;
$updateMessenger->MessageDisposition = 'SaveOnly';
$updateMessenger->ConflictResolution = 'AutoResolve';
try {
$update_response = $ews->UpdateItem($updateMessenger);
}catch (Exception $e){
echo $e->getMessage();
}
}
When I run the file I get the following error :
An internal server error occurred. The operation failed.
After debugging for some time, I have concluded that the error happens at the curl_exec function in NTLMSoapClient.php file.
I dont know where to go on from here. Please help.
I've faced a similar issue when updating a calendar event and setting the IsAllDayEvent flag. This is the code that worked for me:
$ews = new ExchangeWebServices(...);
$request = new EWSType_UpdateItemType();
$request->ConflictResolution = 'AlwaysOverwrite';
$request->ItemChanges = array();
$change = new EWSType_ItemChangeType();
$change->ItemId = new EWSType_ItemIdType();
$change->ItemId->Id = $id;
$change->ItemId->ChangeKey = $changeKey;
$field = new EWSType_SetItemFieldType();
$field->FieldURI = new EWSType_PathToUnindexedFieldType();
$field->FieldURI->FieldURI = "calendar:IsAllDayEvent";
$field->CalendarItem = new EWSType_CalendarItemType();
$field->CalendarItem->IsAllDayEvent = true;
$change->Updates->SetItemField[] = $field;
$request->ItemChanges[] = $change;
$response = $ews->UpdateItem($request);
The biggest difference I see here is that you do $u->Updates->SetItemField = $setField;, whereas my code uses $u->Updates->SetItemField[] = $setField;.
I hope this helps.
Edit: You might have already seen this, but I based my code on the one from the php-ews wiki.
I tried everything including PathToExtendedFieldType and it doesn't work at the end code below worked for me
$ews = new ExchangeWebServices('red', 'red', 'red',ExchangeWebServices::VERSION_2007_SP1);
$request = new EWSType_UpdateItemType();
$request->SendMeetingInvitationsOrCancellations = 'SendToNone';
$request->MessageDisposition = 'SaveOnly';
$request->ConflictResolution = 'AlwaysOverwrite';
$request->ItemChanges = array();
// Build out item change request.
$change = new EWSType_ItemChangeType();
$change->ItemId = new EWSType_ItemIdType();
$change->ItemId->Id = $contact_id;
$change->ItemId->ChangeKey = $contact_change_key;
#$change->Updates = new EWSType_NonEmptyArrayOfItemChangeDescriptionsType();
#$change->Updates->SetItemField = array();
// Build the set item field object and set the item on it.
$field = new EWSType_SetItemFieldType();
$field->FieldURI = new EWSType_PathToUnindexedFieldType();
$field->FieldURI->FieldURI = "message:IsRead";
$field->Message = new EWSType_MessageType();
$field->Message->IsRead = true;
$change->Updates->SetItemField[] = $field;
$request->ItemChanges[] = $change;
$response = $ews->UpdateItem($request);
var_dump($response);
Well, i dont know how it is in php, but in C# there is another field, that must be set: IsReadSpecified = true.
email.IsRead = true;
email.IsReadSpecified = true;

Categories