# Several questions migrating DA from java to cocoa

**URL:** https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401
**Category:** Data Abstract
**Tags:** ios
**Created:** [October 9, 2017, 2:12am UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401 "2017-10-09T02:12:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 9, 2017, 2:12am UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/1 "2017-10-09T02:12:06Z")

</div>

In each case i post java code and my try on cocoa code(not working)

How to setup a proxy service?

```
  {$IFDEF JAVA}
  fDataService := new NewLibrary.DataService_Proxy(java.net.URI.&create(adapter_serverUrl));
  //(fDataService.ProxyMessage as BinMessage).UseCompression := true;
  (fDataService.ProxyClientChannel as HttpClientChannel).Timeout := 5000;
  (fDataService.ProxyMessage as BinMessage).Envelopes.put('AES', aesEnvelope);
   fDataService.ProxyClientChannel.ChannelCallback := new interface ClientChannel.IClientChannelCallback(
    clientChannelNeedsLogin := method(anException: Exception)
    begin
      System.out.println("SessionNotFoundException was thrown");
      exit true;
    end,
    requestFailWithException := method(anException: Exception)
    begin
      //Connected := False;
      doMessageShow('DataService requestFailWithException ' + anException.Message, false);
      System.out.println(anException.Message);
    end
  );
  {$ELSE}
  // ver si puedo usar directamente el adapter con cast
  fDataService := new NewLibrary.DataService_Proxy(adapter_serverUrl);
  {$ENDIF}

```

trying to get datatables in a call

```
var tableNames := new NSMutableArray<String>;
  tableNames.addObject(nme_tipoactividad);
  tableNames.addObject(nme_locaciones);
  //tableNames.addObject(nme_bitacora_entidad);

  var tables := DataAdapter.getDataTables(tableNames);

```

get this message

> Error dispatching message: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

building a where condition

```
{$IFDEF JAVA}
    var lCondition :BinaryExpression :=
        new BinaryExpression(
          new BinaryExpression(
            new BinaryExpression(
              new FieldExpression(fld_empresas_empresaglobalkey),
              new ConstantExpression(fDataAccess.adapter_loginCompany),
              BinaryOperator.Equal),
            new BinaryExpression(
              new FieldExpression(fld_personas_usuario),
              new ConstantExpression(fDataAccess.adapter_loginName),
              BinaryOperator.Equal),
            BinaryOperator.And),
        new BinaryExpression(
          new FieldExpression(fld_hardware_device_serie_imei),
          new ConstantExpression(fDataAccess.adapter_loginIMEI),
          BinaryOperator.Equal),
        BinaryOperator.And);
{$ENDIF}

```

Thats all.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 9, 2017, 8:16am UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/2 "2017-10-09T08:16:17Z")

</div>

Hello

> [@DonaldShimoda](#):
>
> The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

This is a platform (iOS) thing not direcly related to DA. Please take a look at [http://highaltitudehacks.com/2016/06/23/ios-application-security-part-46-app-transport-security/](http://highaltitudehacks.com/2016/06/23/ios-application-security-part-46-app-transport-security/) for more details.

Regards

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 9, 2017, 12:45pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/3 "2017-10-09T12:45:31Z")

</div>

> [@antonk](#):
>
> This is a platform (iOS) thing not direcly related to DA. Please take a look at [http://highaltitudehacks.com/2016/06/23/ios-application-security-part-46-app-transport-security/](http://highaltitudehacks.com/2016/06/23/ios-application-security-part-46-app-transport-security/) for more details.

Thanks for your help, but i dont undesrtand. Seems like the conenction is made in an insecure form. Is not related to remobejcts channel? I build an IOS client, using Delphi + DA, IOS 10 and never see that message, over the same server. Then i think some is misconfigurated on Fire? Sorry, i think i need a more deeper information here about how to configure my remobjects channel.

Best regards.  
P.S. Please if can ask the other stuff?

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 9, 2017, 1:00pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/4 "2017-10-09T13:00:56Z")

</div>

Ih you are using Url like `http://...` (not `https://...`) then the connection is not secure by definition.

If in this case Delphi-built app doesn’t warn you then ( IMHO ) this is actually a security flaw and a kind of violation of Apple requirements (ones that require all apps to use https for connections). Most probably Delphi app just have the override option enabled by default.

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 9, 2017, 1:57pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/5 "2017-10-09T13:57:59Z")

</div>

Ok, delphi fault as usual. How to fix that then? Must i put a security certficate on the server? Can please explain that?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 9, 2017, 2:00pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/6 "2017-10-09T14:00:48Z")

</div>

Apple require all communication to go via TSL1.2 or later. You must switch your server to use `https:`. As a _workaround_ you can add this to your Info.plist file, but you may nit be able to submit the app to the store with that, in there future:

```auto
		<key>NSAppTransportSecurity</key>
		<dict>
			<key>NSAllowsArbitraryLoads</key>
			<true/>
		</dict>

```

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 9, 2017, 2:01pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/7 "2017-10-09T14:01:43Z")

</div>

Thanks for the clarification.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 9, 2017, 2:01pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/8 "2017-10-09T14:01:46Z")

</div>

> [@DonaldShimoda](#):
>
> Ok, delphi fault as usual.

FWIW, the same would apply to a Delphi app, but it’d not be shocked to hear that Delphi just adds the above to your Plist automatically (which would be really, really bad, but…)

—marc

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 9, 2017, 2:02pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/9 "2017-10-09T14:02:45Z")

</div>

> [@mh](#):
>
> FWIW, the same would apply to a Delphi app, but it’d not be shocked to hear that Delphi just adds the above to your Plist automatically (which would be really, really bad, but…)

Marc, the strange stuff here is i submitted delphi ios app to the apple store, not complain at all.

Best regards.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 9, 2017, 2:04pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/10 "2017-10-09T14:04:26Z")

</div>

> [@DonaldShimoda](#):
>
> Marc, the strange stuff here is i submitted delphi ios app to the apple store, not complain at all.

Apple is not enforcing this 100% _yet_.

But that means Delphi most likely _did_ add that setting for you secretly. The mind boggles. But then, DataSnap also opens a pass-thru connection to your database to the client, and they call out “secure multi-tier”, so what do i expect… 😜

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 10, 2017, 12:29pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/11 "2017-10-10T12:29:29Z")

</div>

Sorry for ask again. Can help my explaining how to migrtae taht code from java to cocoa?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 11, 2017, 12:14pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/12 "2017-10-11T12:14:41Z")

</div>

> [@DonaldShimoda](#):
>
> How to setup a proxy service?
> 
> {$IFDEF JAVA}  
> fDataService := new NewLibrary.DataService\_Proxy(java.net.URI.&create(adapter\_serverUrl));  
> //(fDataService.ProxyMessage as BinMessage).UseCompression := true;  
> (fDataService.ProxyClientChannel as HttpClientChannel).Timeout := 5000;  
> (fDataService.ProxyMessage as BinMessage).Envelopes.put(‘AES’, aesEnvelope);  
> fDataService.ProxyClientChannel.ChannelCallback := new interface ClientChannel.IClientChannelCallback(  
> clientChannelNeedsLogin := method(anException: Exception)  
> begin  
> System.out.println(“SessionNotFoundException was thrown”);  
> exit true;  
> end,  
> requestFailWithException := method(anException: Exception)  
> begin  
> //Connected := False;  
> doMessageShow('DataService requestFailWithException ’ + anException.Message, false);  
> System.out.println(anException.Message);  
> end  
> );  
> {$ELSE}  
> // ver si puedo usar directamente el adapter con cast  
> fDataService := new NewLibrary.DataService\_Proxy(adapter\_serverUrl);  
> {$ENDIF}

Need URGENT help with that please. Theres no documentation or samples covering this case.

Thanks.

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 11, 2017, 12:52pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/13 "2017-10-11T12:52:53Z")

</div>

Please explain what you are trying to achieve

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 11, 2017, 4:22pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/14 "2017-10-11T16:22:20Z")

</div>

Connect to a Remobjects service and call a method, same the java code do, but in IOS. See the java code.

Best regards.

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 11, 2017, 4:31pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/15 "2017-10-11T16:31:28Z")

</div>

Did you lokk at the `c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java` folder?

“c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java\Oxygene\HTTP Chat\Program.pas”

F.e. the file `c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java\Oxygene\Mega Demo\UserInterface.pas`:

```
method DemoWindow.initDemoProxy;
begin
  var lProtocol: String := protocolBox.SelectedItem as String;
  var lHost: String := hostField.Text as String;
  var lPort: String := portSpinner.Text as String;
  var lMessageType: String := '/';
  if binaryRbtn.isSelected then
    lMessageType := '/bin';
  var lURI := new URI(lProtocol + '://' + lHost + ':' + lPort + lMessageType);
  MegaDemoService := new MegaDemoService_Proxy(lURI);
  if useCompession.isSelected then
    (MegaDemoService.ProxyMessage as BinMessage).UseCompression := true
  else
    (MegaDemoService.ProxyMessage as BinMessage).UseCompression := false;
  (MegaDemoService.ProxyClientChannel as HttpClientChannel).Timeout := 1000;
end;

```

Similar code in the MegaDemo Android sample:

```
var lURI := new URI("http://10.0.2.2:8099/bin");
fService := new MegaDemoService_Proxy(lURI);
(fService.ProxyMessage as BinMessage).UseCompression := true;
(fService.ProxyClientChannel as HttpClientChannel).Timeout := 1000;

```

Regards

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 12, 2017, 2:27pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/16 "2017-10-12T14:27:17Z")

</div>

No, sorry, i dont. I start in the bad path thinking syntaxis for RO and DA are the same on all platforms. I will check every sample for IOS now.

Best regards.

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 12, 2017, 2:36pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/17 "2017-10-12T14:36:10Z")

</div>

There is a good reason why the syntax differs:  
The code you write is compiled directly into platform-native code, without a massive overhead of some runtime library that hides platform-specific stuff.  
From one side, it requires you to write more code, from other it gives beter performance more native apps. Also it allows to use platform-specific tutorials to do the things needed (f.e. you want ot use https with self-signed certificate on Android and just found some code on StackOverflow. You can oxidize that code and it will work fo you in your app)

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 12, 2017, 2:38pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/18 "2017-10-12T14:38:35Z")

</div>

I have to disagree. That forces to wrote all the code two or tree times to do the same. In any case, as i talk with marc, will be better if you offer a common wrapper and let the use to decide if use native code or the common wrappers, and not force to write a lot of code. is a manintenance nigthmare, despite the aditional time to get it working.

Best regards.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 12, 2017, 2:40pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/19 "2017-10-12T14:40:41Z")

</div>

> [@DonaldShimoda](#):
>
> I have to disagree. That forces to wrote all the code two or tree times to do the same.

As i explained before, DA/.NET and DA/Cocoa were written **LONG** before there was Elements support for Java and Cocoa. They were design dot fit in well with each respective platform because there **WAS** no way to share code anyways (Android apps would have been in Java, Cocoa apps in Objective-C).

We **ARE** looking into a better approach in the future, but for now, thats what it is.

---

<div class="post-metadata">

### Author: ![DonaldShimoda](https://talk.remobjects.com/user_avatar/talk.remobjects.com/donaldshimoda/32/6_2.png) [@DonaldShimoda](https://talk.remobjects.com/u/DonaldShimoda)
#### Post date: [October 12, 2017, 2:42pm UTC](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401/20 "2017-10-12T14:42:16Z")

</div>

Thank you marc, will be a better approach without any doubt.

Best regards.

[Next page](https://talk.remobjects.com/t/several-questions-migrating-da-from-java-to-cocoa/14401.md?page=2)
