cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Jar to eSourcing

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member89217
Contributor
0 Kudos

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

Former Member
0 Kudos

Gary,

Our Basis team used the configure tool that you mentioned for jar deploy. We are getting class doesn't exist in class path.

Thanks,

Venu.

former_member190023
Contributor
0 Kudos

Fresh from the printing press:

The described approach will also save you of all the headaches when you'll upgrade to a different SP or version.

Regards,

Bogdan

former_member89217
Contributor
0 Kudos

The configure utility only BUILDS the SCA file with the included jar. Deployment is a seperate task. If the deployment was done properly the class chould be in the classpath.  You can also consider the procedure Bogdan has described.

Former Member
0 Kudos

Bogdan,


This worked for me, I could able to call the ECC Rest Services that got exposed through gateway from Sourcing.


Thanks,

Venu.

Answers (0)