• Stanley He (skype: konafornia)
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
1. Brief description of the issue: 
Java client can log in and subscribe to PushTopic, but cannot receive CRUD events.

2. Org ID: 
https://kfo-dev-ed.my.salesforce.com

3. Description:
I have the SAME Java code calling Streaming API, it works well with other testing Orgs which were created from OLD the old "PartnerForce".

Following "Dev Org" is created from outside (not from Environment Bub), as can be seen from the below attached log: Java code (Streaming API) can subscribe to the PushTopic successfully, but the CRUD ecents never being pushed into PushTopic. The user I am using is Syatem Admin, it has all the roles needed; to test, I also added a "Permission Set" with all related customer objects.Again, the same code works fine for Orgs previously created by PartnerForce.


Here is my tracing:

Running streaming client example....
Login successful!
Endpoint: https://kfo-dev-ed.my.salesforce.com
Sessionid=00D1a000000I2Xm!ARkAQMempbqGj8mi9CANglgiNU5REvTdLUTdq2sZlabSp01SacadCS6B61NhFCf9rfXkx545Mk_uwNDWcU3ajvsqsRGY_dQv
Waiting for handshake
[CHANNEL:META_HANDSHAKE]: {"minimumVersion":"1.0","clientId":"24pjfhnah4zf5412s9y72mnqq6c","supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"1","version":"1.0","successful":true}
[CHANNEL:META_CONNECT]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","advice":{"reconnect":"retry","interval":0,"timeout":110000},"channel":"/meta/connect","id":"2","successful":true}
Subscribing for channel: /topic/Cloudchoir_kfo
Waiting for streamed data from your organization ...
[CHANNEL:META_SUBSCRIBE]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","channel":"/meta/subscribe","id":"4","subscription":"/topic/Cloudchoir_kfo","successful":true}
[CHANNEL:META_CONNECT]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","channel":"/meta/connect","id":"3","successful":true}

 
1. In this reference, ApexTriggerMember is mentioned, but I cannot turn it into a working sample. http://redcurrantscloud.blogspot.in/2013/09/forcecom-tooling-api-create-apex-class.html

2. Forllowing this http://www.javacodegeeks.com/2014/06/how-to-use-salesforce-rest-api-with-your-javaserver-pages.html ,
 Works fine to update Account, if I tried it against ApexTrigger, still not working. Following is my code, and the error I got is "Response Status line :HTTP/1.1 400 Bad Request".

Please tell me what I missed. Thank you very much!
~Stanley

______________________________________________________________
CloseableHttpClient httpclient = HttpClientBuilder.create().build(); //HttpClients.createDefault();
            
            // http://mvnrepository.com/artifact/org.json/json/20140107
            JSONObject update = new JSONObject();

            update.put("Name", "TestTrigger");
            update.put("Body", "trigger TestTrigger on Opportunity (before insert){}");
            update.put("TableEnumOrId","Opportunity");

            HttpPost httpost = new HttpPost(instance_URL
                    + "/services/data/v32.0/tooling/sobjects/ApexTrigger/"  
                    + "01qi0000000GJn7" + "?_HttpMethod=PATCH");

            
            httpost.addHeader("Authorization", "OAuth " + access_token);
            httpost.addHeader("Accept", "application/json");
            httpost.addHeader("Content-Type", "application/json");
            
            System.out.println("---update.toString():" + update.toString());
            
            StringEntity messageEntity = new StringEntity(update.toString(),
                    ContentType.create("application/json"));

            httpost.setEntity(messageEntity);

            // Execute the request.
            CloseableHttpResponse closeableresponse = httpclient
                    .execute(httpost);
            System.out.println("Response Status line :"
                    + closeableresponse.getStatusLine());

            try {
                System.out.println("HTTP status "
                        + closeableresponse.getStatusLine().getStatusCode());
            } finally {
                httpclient.close();
            }
        }
 

This is an  Outbound Message based Integration Solution (thus no worry about "Callout Execution Governors and Limits ")

 

my YouTube demo:
http://youtu.be/Z5YTqa0bm6M

More details:

http://konafornia.blogspot.com/

DEMO video:
http://youtu.be/Z5YTqa0bm6M

More details:
http://konafornia.blogspot.com/

Key tech notes:
1. Outbound Message based solution, thus no worry about "Apex Callout Execution Governors and Limits " or "Apex Trigger Execution Governors and Limits".
2. Full Java (Groovy) power, including debugging Groovy/Java using IDEs such as Eclipse/Netbeans.
3. Utilizing existing Java (Groovy) framework/library such as Apache Commons, Restlet, Axis2, Jsch, JDBC, BigData, UnboundID, ... etc. And... utilizing your Java developers.
4. If you prefer, Java debug can be done 100% inside Salesforce.
5. HTTPs and SSH based security.

DEMO video:
http://youtu.be/Z5YTqa0bm6M

 

More details:
http://konafornia.blogspot.com/

 

Key tech notes:
1. Outbound Message based solution, thus no worry about "Apex Callout Execution Governors and Limits " or "Apex Trigger Execution Governors and Limits".
2. Full Java (Groovy) power, including debugging Groovy/Java using IDEs such as Eclipse/Netbeans.
3. Utilizing existing Java (Groovy) framework/library such as Apache Commons, Restlet, Axis2, Jsch, JDBC, BigData, UnboundID, ... etc. And... utilizing your Java developers.
4. If you prefer, Java debug can be done 100% inside Salesforce.
5. HTTPs and SSH based security.

1. Brief description of the issue: 
Java client can log in and subscribe to PushTopic, but cannot receive CRUD events.

2. Org ID: 
https://kfo-dev-ed.my.salesforce.com

3. Description:
I have the SAME Java code calling Streaming API, it works well with other testing Orgs which were created from OLD the old "PartnerForce".

Following "Dev Org" is created from outside (not from Environment Bub), as can be seen from the below attached log: Java code (Streaming API) can subscribe to the PushTopic successfully, but the CRUD ecents never being pushed into PushTopic. The user I am using is Syatem Admin, it has all the roles needed; to test, I also added a "Permission Set" with all related customer objects.Again, the same code works fine for Orgs previously created by PartnerForce.


Here is my tracing:

Running streaming client example....
Login successful!
Endpoint: https://kfo-dev-ed.my.salesforce.com
Sessionid=00D1a000000I2Xm!ARkAQMempbqGj8mi9CANglgiNU5REvTdLUTdq2sZlabSp01SacadCS6B61NhFCf9rfXkx545Mk_uwNDWcU3ajvsqsRGY_dQv
Waiting for handshake
[CHANNEL:META_HANDSHAKE]: {"minimumVersion":"1.0","clientId":"24pjfhnah4zf5412s9y72mnqq6c","supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"1","version":"1.0","successful":true}
[CHANNEL:META_CONNECT]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","advice":{"reconnect":"retry","interval":0,"timeout":110000},"channel":"/meta/connect","id":"2","successful":true}
Subscribing for channel: /topic/Cloudchoir_kfo
Waiting for streamed data from your organization ...
[CHANNEL:META_SUBSCRIBE]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","channel":"/meta/subscribe","id":"4","subscription":"/topic/Cloudchoir_kfo","successful":true}
[CHANNEL:META_CONNECT]: {"clientId":"24pjfhnah4zf5412s9y72mnqq6c","channel":"/meta/connect","id":"3","successful":true}

 
Hi

I managed to get my Java Environment up and running using the following:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_developer_environment_tipsheet.meta/salesforce_developer_environment_tipsheet/?state=id

The above uses HttpComponents 4.4.

There are examples using the Rest API here:
https://developer.salesforce.com/page/Getting_Started_with_the_Force.com_REST_API

This appears to be using the old version of HttpComponents (v3 maybe?). In particular, I'm trying to get the SOQL code working for HttpComponents 4.4. Has anyone successfully managed to do so and have code samples?

Thanks