Exchange plan error

Discussions regarding 1C:Enterprise for mobile devices with Android, iOS, or Windows Phone.

#1
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

Hello Timofey.

I`m getting the following error when I try to execute exchange mechanism beetween server and mobile.

On the server in the web service is all ok, function for sending data is executing.

Function in the web service module for sending data to mobile is:

Code
Function PerformExchange(DeviceCode, DeviceData)
   SetPrivilegedMode(True);
   
   //1. Initialization (if necessary)
   ExchangeNode = ExchangePlans.Mobile.ThisNode().GetObject();
   If Not ValueIsFilled(ExchangeNode.Code) Then
      ExchangeNode.Code="001";
      ExchangeNode.Description="Main";
      ExchangeNode.Write();
   EndIf;
   
   ExchangeNode = ExchangePlans.Mobile.FindByCode(DeviceCode); 
   If ExchangeNode.IsEmpty() Then
      NewNode = ExchangePlans.Mobile.CreateNode();
      NewNode.Code = DeviceCode;
      NewNode.Description = DeviceCode;
      NewNode.Write();
      RecordDataChanges(NewNode.Ref);
      ExchangeNode = NewNode.Ref;
   EndIf;
   
   
   //2. Retrieving data from the mobile device
   ExchangeNode = ExchangePlans.Mobile.FindByCode(DeviceCode); 
   XMLReader = New XMLReader;
   XMLReader.SetString(DeviceData.Get());
   MessageReader = ExchangePlans.CreateMessageReader();
   MessageReader.BeginRead(XMLReader);
   ExchangePlans.DeleteChangeRecords(MessageReader.Sender,MessageReader.ReceivedNo);
   BeginTransaction();
   While CanReadXML(XMLReader) Do
      Data = ReadXML(XMLReader);
      If Not Data = Undefined Then
         Data.DataExchange.Sender = MessageReader.Sender;
         Data.DataExchange.Load = True;
         Data.Write();
      EndIf;
   EndDo;
   CommitTransaction();
   MessageReader.EndRead();
   XMLReader.Close();
   
   
   //3. Exporting data to the mobile device
   ExchangeNode = ExchangePlans.Mobile.FindByCode(DeviceCode); 
   XMLWriter = New XMLWriter;
   XMLWriter.SetString("UTF-8");
   XMLWriter.WriteXMLDeclaration();
   MessageWriter = ExchangePlans.CreateMessageWriter();
   MessageWriter.BeginWrite(XMLWriter, ExchangeNode);               
   XMLWriter.WriteNamespaceMapping("xsi", "http://www.w3.org/2001/XMLSchema-instance");
   XMLWriter.WriteNamespaceMapping("v8",  "http://v8.1c.ru/data");
   ChangeSelection = ExchangePlans.SelectChanges(ExchangeNode, MessageWriter.MessageNo);//, Users.GetExchangePermissionsFilter(SystemUser));
   While ChangeSelection.Next() Do
      Data = ChangeSelection.Get();
      WriteXML(XMLWriter, Data);// Writing data to the message
   EndDo;
   MessageWriter.EndWrite();
   Return New ValueStorage(XMLWriter.Close(), New Deflation(9));
   
EndFunction



On the mobile when processing server response i`m getting the following error

"Error setting value of context attribute(Sender)".

Can you please help me to fix this?

The function is:

Code
&AtServer
Procedure ExecuteDataExchange() Export
   
   
   Address = Constants.ServerAdress.Get();
   
   Definitions = New WSDefinitions(Address,"admin", "admin");
   URI = "http://localhost/ws1";
   Proxy = New WSProxy(Definitions, URI, "WebExchange", "WebExchangeSoap");
   Proxy.User = "admin";
   Proxy.Password = "admin";
   
   SysInfo = New SystemInfo;
   MobileDeviceCode = String(SysInfo.ClientID);
   
   //1. Initialization (if necessary)
   Node = ExchangePlans.Mobile.ThisNode();
   If Not ValueIsFilled(Node.Code)
      Or Node.Code <> MobileDeviceCode Then
      NodeObject = Node.GetObject();
      NodeObject.Code = MobileDeviceCode;
      NodeObject.Description = MobileDeviceCode;
      NodeObject.Write();
   EndIf;
   
   MainExchangeNode = ExchangePlans.Mobile.FindByCode("001");
   If MainExchangeNode.IsEmpty() Then
      NewNode = ExchangePlans.Mobile.CreateNode();
      NewNode.Code="001";
      NewNode.Description="Main";
      NewNode.Write();
      MainExchangeNode = NewNode.Ref;
   EndIf;   
   
   //2. Exchange with the main base
   ExchangeData = Proxy.PerformExchange(MobileDeviceCode, GenerateExchangePackage(MainExchangeNode));   
   
   
   //3. Processing data received from the main base
   XMLReader = New XMLReader;
   XMLReader.SetString(ExchangeData.Get());
   MessageReader = ExchangePlans.CreateMessageReader();
   MessageReader.BeginRead(XMLReader);
   ExchangePlans.DeleteChangeRecords(MessageReader.Sender,MessageReader.ReceivedNo);
   BeginTransaction();
   While CanReadXML(XMLReader) Do
      Data = ReadXML(XMLReader);
      If Not Data = Undefined Then
         Message(MessageReader.Sender);
         Data.DataExchange.Sender = MessageReader.Sender;
         Data.DataExchange.Load = True;
         Data.Write();
      EndIf;
   EndDo;
   CommitTransaction();
   MessageReader.EndRead();
   XMLReader.Close();
   
EndProcedure

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Marius Gidu.

Please, check types of Data.DataExchange.Sender and MessageReader.Sender.

 
#3
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

Can you please explain in details?

I can`t see these two types because i don`t have debug on mobile....

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

You can output it using TypeOf() function.

There actually is debug mode for mobile application. The emulator or an actual device can be used.

Download debug.png (24.48 KB)
 
Subscribe
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.