Java Callout Policy

Not applicable

In Eclipse, I've added expressions-1.0.0.jar and message-flow-1.0.0.jar along with other dependent Apache HTTPClient jars but while import com.apigee.flow.execution.ExecutionContext and other 3 classes in my java file, showing error like com.apigee.flow can not be resolved. How to make it work? Am I doing anything wrong? Please advise and refer some more Java Callout samples.

0 13 1,695
13 REPLIES 13

Not applicable

This clearly seems to be classpath problem. Can you share your screenshot or share your eclipse project so we can look at fixing the issue.

@sriki77

Hi Thanks for ur support. Attached 2 screen shots of my Eclipse proj. Installed JRE is 1.7.0_67javacalloutissue1.jpgjavacalloutissue.jpg

Not applicable

@sriki77

some update to my question: This Java code is all about enabling NTLM Authentication between apigee on-prem and Microsoft SharePoint Server. Is there possible to have similar java example with apigee wrapper code?

Give me more context - Auth is for APIs or for Apigee itself. In the later case your login's to apigee will be controlled by Sharepoint not your APIs. Please let me know.

Not applicable

@sriki77

Please provide solution for Java Build Path problem in Eclipse for expressions-1.0.0.jar and message-flow-1.0.0.jar.

Showing unresolved error in imports for

import com.apigee.flow.execution.ExecutionContext;

import com.apigee.flow.execution.ExecutionResult;

import com.apigee.flow.execution.spi.Execution;

import com.apigee.flow.message.MessageContext;

More Context:

Standalone Java Code in Eclipse is working fine, NTLM Auth. is happening, Receiving valid XML response from SharePoint WS. Rightnow I need more clarity in Apigee wrapper code around this Standalone java code to make use of Java Callout Policy. For NTLM Auth.-> I'm using Service Account, in this Service Account apigee On-Prem components Host Names are added and Locally Logon Rights (LLR) is granted, so NTLM is happening between apigee Host and SharePoint.

Code Snippet:

DefaultHttpClient httpClient = new DefaultHttpClient();

List<String> authpref = new ArrayList<String>();

authpref.add(AuthPolicy.NTLM); httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF,authpref);

// TO PASS SERVICE ACCOUNT, PASSWORD, WORKSTATION(HOSTNAME of APIGEE, IT IS ADDED in the SERVICE ACCOUNT), DOMAIN of the SERVICE ACCOUNT

NTCredentials creds = new NTCredentials("","","acpsmlintranet.europe.shell.com",""); httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);

// APIGEE LB HOST DETAILS

HttpHost target = new HttpHost("acpsmlintranet.europe.shell.com",443,"https"); HttpContext localContext = new BasicHttpContext();

// URI of Web Service - https://acpsmlintranet.europe.shell.com/service1

HttpGet httpGet = new HttpGet("/service1");

HttpResponse httpResponse = null;

int statusCode = 0;

try { httpResponse = httpClient.execute(target,httpGet,localContext); }

catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }

Not applicable

I have attached jars again to this post - use them...theses jars work for me....let me know if you still face a compilation issue.jc-callout.tar.gz

The gzip file contains the two jars - put those jars in your classpath.

@sriki77

Downloaded expressions-1.0.0.jar and message-flow-1.0.0.jar from

api-platform-samples/doc-samples/java-cookbook/lib are corrupted right?

Your version is working and not showing any compilation errors. Thanks.

In my standalone program, I'm receiving the SharePoint WS response as XML (huge content) and converting this XML into String. Please help me, how to pass this final output to apiee response using apigee wrapper code for both XML and String.

Not applicable

You can pass the XML and string as a variable - using messageContext.setVariable method. The variable can be accessed in the policies.

Interesting did know the jars were corrupted. @Floyd Jones can you please take a look at the jars in the platform sample mentioned above by @P.Ganesanseems like they are corrupted.

@sriki77 //You can pass the XML and string as a variable - using messageContext.setVariable method. The variable can be accessed in the policies.// - Which Policy?

Using this Java Call out in No Target "Starting Point Type" in On-Prem because "Backend Service URL" is inside the java call out java code.

Receiving the following error... any remedy for this?

{ fault: { faultstring: "Internal server error Received unknown request for Organization:orgname;Environment:env;APIProxy:No-Target;Revision:4" detail: { errorcode: "messaging.adaptors.http.ServerError" }- }- }

Many Thanks!

Not applicable

The variables will be available as context variable - you can use it in assign message or any other policy. Take a look at proxy samples - it should help

The second error seems to be deployment issue, what does you trace show is the request coming to you proxy?

Not applicable

@sriki77 Thanks a lot for your response.

//Error creating trace session for API proxy sharepointservice1, revision 1, environment acp.

Failed to create DebugSession 1433311881702//

Whenever click 'Start Trace Session' button i'm getting the above error message. What could be wrong?

Not applicable

You need to select the correct deployed revision in the dropdown next the start trace session button.

Not applicable

@sriki77 cause = com.apigee.kernel.exceptions.spi.UncheckedException{ code = steps.javacallout.JavaCalloutInstantiationFailed, message = Failed to instantiate the JavaCallout Class com.sml.ApigeeNTLM, associated contexts = []} Please help me to identify the issue?