Quantcast
Channel: SCN : Discussion List - SAP Sourcing
Viewing all articles
Browse latest Browse all 1416

Custom Jar to eSourcing

$
0
0

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.


Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>