on 2016 Mar 03 6:20 PM
We have a requirement to call Rest WebServices from Sourcing(Version-10). I developed a custom Rest Client in eclipse and created it has jar and basis deployed to sourcing using the wizard. When I try to call the custom jar from scripting it's not recognizing the RestClient.
Below is my Custom Rest Client Class that I created in eclipse and converted into jar RestClientCLM.jar
package com.uprr.ws;
import java.nio.charset.Charset;
import org.apache.commons.codec.binary.Base64;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
public class RestClientCLM {
public void main() {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders httpHeaders = new HttpHeaders(){
{
String auth = "userid" + ":" + "password";
byte[] encodedAuth = Base64.encodeBase64(
auth.getBytes(Charset.forName("US-ASCII")) );
String authHeader = "Basic " + new String( encodedAuth );
set( "Authorization", authHeader );
}
};
String url = "Rest Url";
// ResponseEntity<String> response = restTemplate.getForEntity(url , String.class);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<String>(httpHeaders), String.class);
System.out.println(response.getBody());
}
}
I created my eSourcing script like below.
import com.uprr.ws.*;
RestClientCLM rt = new RestClientCLM();
rt.main();
Error:
Sourced file: inline evaluation of: ``import com.uprr.ws.RestClientCLM Sourced file: inline evaluation of: ``import com.uprr.ws.RestClientCLM RestClientCLM rt = new RestClientCLM(); rt . . . '' : Typed variable declaration : Class: RestClientCLM not found in namespace : at Line: 3 : in file: inline evaluation of: ``import com.uprr.ws.RestClientCLM; RestClientCLM rt = new RestClientCLM(); rt . . . '' : RestClientCLM || at bsh.BSHAmbiguousName.toClass(Unknown Source)| at bsh.BSHType.getType(Unknown Source)| at bsh.BSHTypedVariableDeclaration.eval(Unknown Source)| at bsh.Interpreter.eval(Unknown Source)| at bsh.Interpreter.eval(Unknown Source)| at bsh.Interpreter.eval(Unknown Source)| at com.sap.odp.comp.scripting.ScriptEnvironment.execute(ScriptEnvironment.java:185)| at com.sap.odp.doccommon.scripting.util.ScriptUtil.executeCallableScript(ScriptUtil.java:953)| at com.sap.odp.doccommon.scripting.daemon.ScriptExecutionDaemon.processHook(ScriptExecutionDaemon.java:135)| at com.sap.odp.comp.daemon.AbsEventDaemon.process(AbsEventDaemon.java:160)| at com.sap.odp.comp.daemon.ResponsibleEventDaemon.runHook(ResponsibleEventDaemon.java:140)| at com.sap.odp.comp.daemon.ResponsibleDaemonBase.run(ResponsibleDaemonBase.java:301)| at java.lang.Thread.run(Thread.java:763)|;Sourced file: inline evaluation of: ``import com.uprr.ws.RestClientCLM; RestClientCLM rt = new RestClientCLM(); rt . . . '' : Typed variable declaration : Class: RestClientCLM not found in namespace|Sourced file: inline evaluation of: ``import com.uprr.ws.RestClientCLM;
Need experts help.
Thanks,
Venu.
Request clarification before answering.
How did you deploy this custom jar? there is provision for deploying custom jars in the Sourcing Configure utility. You would add the custom jar there, rebuild the SCA file and then redeploy the SCA in Netweaver.
Regards,
Gary
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.