Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise. Mobile platform > Exchange plan error

Forum

Search UsersRules
Exchange plan error
#1
Active user
Points:: 0
Joined:: Sep 1, 2014

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

Profile
#2
Guest
Points::
Joined::

Hello, Marius Gidu.

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

Profile
#3
Active user
Points:: 0
Joined:: Sep 1, 2014

Can you please explain in details?

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

Profile
#4
Guest
Points::
Joined::

You can output it using TypeOf() function.

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.