[Best practice] How to call a service from custom Java code
Hi all,
I'm wondering what the best method is to call a standard service from custom Java code?
In a specific situation iDoc script is extended with custom functions with a custom component. There's Java code mapping to these functions that is executing these functions. The iDoc script functions are called from a workflow entry script.
In the Java code that runs when the custom iDoc functions are called, I want to call a standard Content Server service. I don't think that the m_service variable is available, so filling the binder and using m_service.executeService() probably isn't possible.
Also, if it were possible (that is, if I want to call a standard service from my own custom service Java code), what would then be the best method to do so?
Regards, Stijn
Hi Sapan,
Let me explain a bit further.
I'm an UCM consultant trying to solve a problem that occured at a client when they installed the CS10gR35CoreUpdateBundle.
Content items are entered into a Workflow when they are checked in. Part of one of the entry scripts of the a workflow step is that related content to the content item in the workflow is (re)submitted for conversion.
To achive this, a custom component provides an iDoc script extension. This iDoc function (resubmitForConversion) is implemented in Java (the class extends ScriptExtensionsAdaptor).
In this Java method, first the related content items are fetched. Then the service RESUBMIT_FOR_CONVERSION should be called for all dID's in of the related content.
Thus, at a certain point in the custom Java code, a native Content Server service must be called. Of course the class of this Java code does not extend the Service class, so the m_service object isn't available.
The thing is: before installed the 10gR35CoreUpdateBundle everything worked OK. This code was used to execute the service:
Workspace workspace = CommonUtils.getSystemWorkspace();
String cmd = binder.getLocal("IdcService");
if (cmd == null) throw new DataException("!csIdcServiceMissing");
ServiceData serviceData = ServiceManager.getFullService(cmd);
if (serviceData == null) throw new DataException(LocaleUtils.encodeMessage("!csNoServiceDefined", null, cmd));
Service service = ServiceManager.createService(serviceData.m_classID, workspace, null, binder, serviceData);
UserData fullUserData = CommonUtils.getFullUserData(userName, service);
service.setUserData(fullUserData);
binder.m_environment.put("REMOTE_USER", userName);
ServiceException error = null;
try {
service.setSendFlags(true, true);
service.initDelegatedObjects();
service.globalSecurityCheck();
service.preActions();
service.doActions();
service.postActions();
service.updateSubjectInformation(true);
service.updateTopicInformation(binder);
} catch (ServiceException e) {
error = e;
} finally {
service.cleanUp(true);
if (!CommonUtils.isWorkspaceConnectionInTransaction(workspace)) {
workspace.releaseConnection();
}the first problem was that the CS began to complain that a transaction was started within another transaction. So I suspect that the 10gR35 update wrapped a transaction around a workflow script entry.
With some decompiling I figured out how a service is called from iDoc with the <$executeService()$> command. So I replaced the code above with:
String cmd = binder.getLocal("IdcService");
ServiceData serviceData = ServiceManager.getFullService(cmd);
if (serviceData == null) throw new DataException(LocaleUtils.encodeMessage("!csNoServiceDefined", null, cmd));
Workspace workspace = CommonUtils.getSystemWorkspace();
Service service = ServiceManager.createService(serviceData.m_classID, workspace, null, binder, serviceData);
UserData fullUserData = CommonUtils.getFullUserData(userName, service);
service.setUserData(fullUserData);
binder.m_environment.put("REMOTE_USER", userName);
service.initDelegatedObjects();
service.executeSafeServiceInNewContext(cmd, true);This solved the transaction problem but introduces another problem: !csUnableToResubmitItem,(null)!csIllegalScriptAccess,RESUBMIT_FOR_CONVERSION
The Service Reference Guide says that the access level for RESUBMIT_FOR_CONVERION is 33 (Read, Scriptable). However, in shared/config/resources/std_services.htm the access level is specified as 2 (write).
Thus, my question still is:
What is the best method to call a standard Content Server service from any Java code (so without extending the Service class, or having the m_service object available)?
Similar Messages
-
How to call web-service using only java code
Hello, how to call web-service using only java code. I can call it from BPM process or Web Dynpro Java Application, but if I need to call it from ejb component?
I'm found answer:
Java and SAP Portal blog: How to call web service from java code example -
How to call IAC Iview from WebDynpro java code
Hi Team,
I am tring to call IAC Iview from WebDynpro Java code. we are passing value but blank page displayed and there is no error show on error log.
Below is Java Code which i am calling.
public void wdDoInit()
try {
String strURL = "portal_content/TestSRM/iView/TestSRM"; //WDProtocolAdapter.getProtocolAdapter().getRequestParameter("application");
String random = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getParameter("random_code");
//wdContext.currentContextElement().setRandomNumber(random);
//below we are call URL
WDPortalNavigation.navigateAbsolute("ROLES://portal_content/TestSRM/iView/TestSRM?VAL="+random,WDPortalNavigationMode.SHOW_INPLACE,(String)null, (String)null,
WDPortalNavigationHistoryMode.NO_DUPLICATIONS,(String)null,(String)null, " ");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
I am passing value from URL.
http://<host Name>:<port>/webdynpro/resources/local/staruser/StarUser?random_code=111111111
when we call above URL we getting blank screen.
Regards
Pankaj KambleHi Vinod,
read this document (from pages 7 ).
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b5380089-0c01-0010-22ae-bd9fa40ddc62">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b5380089-0c01-0010-22ae-bd9fa40ddc62</a>
In addition lok at these links: (Navigation Between Web Dynpro Applications in the Portal)
<a href="http://help.sap.com/saphelp_erp2005/helpdata/en/ae/36d93f130f9115e10000000a155106/frameset.htm">http://help.sap.com/saphelp_erp2005/helpdata/en/ae/36d93f130f9115e10000000a155106/frameset.htm</a>
<a href="http://help.sap.com/saphelp_erp2004/helpdata/en/b5/424f9c88970f48ba918ad68af9a656/frameset.htm">http://help.sap.com/saphelp_erp2004/helpdata/en/b5/424f9c88970f48ba918ad68af9a656/frameset.htm</a>
It may be helpful for you.
Best regards,
Gianluca Barile -
How to call business service from xquery transformation in OSB ??
Hi All,
How to call business service from xquery transformation in OSB ??
I need to assign the response variable of Business Service to a target element in XQuery Transformation Mapper file.
It's urgent.
Regards,
Jyoti NayakTransformation is to mapping the source and target of 2 different schemas.
In your case you should have a XQuery transformation between, your Business Service output schema and the target schema.
Thanks,
Vijay -
How to call WEB Service From SAP
Hi Friends,
How to call WEB Service From SAP.
Thanks in advance,
Murali Krishna KHi,
if you mean calling a web service in Web Dynpro ABAP, see the <a href="http://help.sap.com/saphelp_nw70/helpdata/en/d7/951b42f828df2ce10000000a1550b0/frameset.htm">documentation</a>, if you mean calling a web service in general, this is not the correct forum. This here is the Web Dynpro ABAP forum, for general questions on ABAP, use the ABAP forum.
Regards, Heidi -
How to call web services from HTML
Hi All,
Does anybody have an idea on how to call web services from HTML using axis and i am using jboss-4.0.5 as the application server.What did your Google search return?
-
How to call web services from PL/SQL?
Hi,
Can one help in how to call web services from PL/SQL? Steps, pros and cons, etc....
Thanks in advanceHere's some example skeleton code to get you started...
PROCEDURE p_soap_request(p_username IN VARCHAR2, p_password IN VARCHAR2, p_proxy IN VARCHAR2) IS
soap_request VARCHAR2(30000);
soap_respond CLOB;
http_req utl_http.req;
http_resp utl_http.resp;
resp XMLType;
soap_err exception;
v_code VARCHAR2(200);
v_msg VARCHAR2(1800);
v_len number;
v_txt Varchar2(32767);
BEGIN
UTL_HTTP.SET_PROXY(p_proxy);
-- Define the SOAP request according the the definition of the web service being called
soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?>'||
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'||
' <SOAP-ENV:Body>'||
' <m:DownloadRequest xmlns:m="http://www.website.net/messages/GetDetails">'||
' <m:UserName>'||p_username||'</m:UserName>'||
' <m:Password>'||p_password||'</m:Password>'||
' </m:DownloadRequest>'||
' </SOAP-ENV:Body>'||
'</SOAP-ENV:Envelope>';
http_req:= utl_http.begin_request
( 'http://www.website.net/webservices/GetDetailsService.asmx'
, 'POST'
, 'HTTP/1.1'
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'Download', ''); -- header requirements of particular web service
utl_http.write_text(http_req, soap_request);
http_resp:= utl_http.get_response(http_req);
utl_http.get_header_by_name(http_resp, 'Content-Length', v_len, 1); -- Obtain the length of the response
FOR i in 1..CEIL(v_len/32767) -- obtain response in 32K blocks just in case it is greater than 32K
LOOP
utl_http.read_text(http_resp, v_txt, case when i < CEIL(v_len/32767) then 32767 else mod(v_len,32767) end);
soap_respond := soap_respond || v_txt; -- build up CLOB
END LOOP;
utl_http.end_response(http_resp);
resp:= XMLType.createXML(soap_respond); -- Convert CLOB to XMLTYPE
END;Using secure web services (https)...
Web serivces call in Plsql
As for 'pros and cons'... there's nothing to compare against... either you want to call a web service or you don't. -
How to call WEB Service From SAP 4.6 c
Hi Friend,
How to call WEB Service From SAP 4.6 c Report
Thanks in advance.It is not possible to directly call a web service from SAP 4.6c.
Indeed, web service enablement is available as from Web AS 6.20, thus as from SAP R/3 4.7
So as described above, the solution is indeed to make use of PI(XI) for this.
Rgds,
Karim -
CE 7.1 - How to call CAF services from Web Dynpro
Hi,
whats the suggested way to call caf services from web dynpro?
Of course I can use the Web Service model. But can I call caf directly?
I read something about caf web dynpro model, but I cannot find it in nwds 7.1. On some older tutorial it was in context menu of caf project, but it seems to be removed.
best regards
tomHi ,
The standard way is to use the web service model.
You have to expose the the services as web service and then you can use the wsdl url in the Adaptive web service model option.
The above option will be available when you click the Model in the webdynpro application and the click create new model.
Hope it helps you.
Regards,
Srinivasan Subbiah -
How to call web services from oracle database 10g
Hi all ,
How can i call web services from oracle database 10g ?
thanks ...abdou123 wrote:
but how can i get complex result
for example
i pass input parameter like National Id Number
and get the person details ( name , age , date of birth , ............ ) .Basic approach to web services using UTL_HTTP explained in {message:id=10448611}.
An example of using a pipeline table function as a data transformation process (turning web data into rows and columns) in {message:id=10158148}. -
How to call the method from the java bean and pass it to JSP textbox
i'm quite new to java thats why i'm asking how to call a method in the java bean file and pass it to the JSP textbox. My projects are communicating JSP with C#. i had successfully created a C# client bean file for JSP. The whole process is to type something on the server(C# programming) and it would appear in the textbox.
your question doesn't provide much informartion. provide some other information and coding so that we could tell exactly what you are looking for?
-
How to register a dll from the java code
Hi,
We can use windows utility Regsv32.exe to register a the components. Is it possible to register the Dll from the java code. If possible please try to provide me the code for the registring the dll.
Thanks in adavance
Aswadif a try this variant it doesnt work
static {
System.loadLibrary("shellExec.dll");
but in this way it work (without .dll extension)
static {
System.loadLibrary("shellExec");
} -
Best Practices:: How to generate XML file from a ResultSet
Hi all,
Could someone please suggest the best practices of how to generate an XML file from a resultset? I am developing a web application in Java with Oracle database and one of my tasks is to generate an XML file when the user, for example, click a "download as XML" button on the JSP. The application is basically like an Order with line items. I am using Struts and my first thought has been to have an action class which will extend struts's DownloadAction and through StAX's Iterator API to create an XML file. I intend to have a POJO which will have properties of all columns of my order and line items tables so that for each order I get all line items and:
1. Write order details then
2. Through an iterator write line items of that order to an XML file.
I will greatly appreciate for comments or suggestions on the best way to do this through any pointers on the Web.
alexUse a OracleWebRowSet in which an XML representation of the result set may be obtained.
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/webrowset/Readme.html
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/jcrowset.htm -
How to call Web Service from Servlet !
Dear All,
I am in dire need to understand how to call a web service from Servlet.
I need to develop a web service which will read LDAP Directory server to retreive information.
How I should call that web service from a Servlet? What Servlet actions do I need to write etc.
I need guidance about design of the above task please.
I would higly appreciate any help and guidance in this regard.
Thanks.
Regards,
WaqarYou can use java.net.URLConnection for that.
-
How to call https service from OSB
hi
I need to call thirt party https service. Its a secured service with authentication.
I have Imported ssl certificate in keystore.
It's one way ssl with authentication and I need to pass wsse token (username/password) from Business service to invoke third party service.
What steps do I need to follow to call this service?
I have gone through all other
Thanks
VibhorBelow note gives the high level steps to be performed for implementing different security requirements with OSB
OSB - Proxy Service HTTPS one way
Configure Identity & Trust Keystore
OSB - Proxy Service HTTPS 2 way
Configure Identity Assertion Provider to support X509
Configure user mapper class for default identity assertion provider
Change 2 way Client Cert behaviour from default
('Client Certificate Not requested”) to “Client Certificate requested but not enforced”
OSB - Business Service HTTPS one way
Add root & intermediate CA certificates of the server to the trust keystore
OSB - Business Service HTTPS 2 way
Add root & intermediate CA certificates of the server to the trust keystore
Configure PKI Credential Provider containing the client certificate
Configure a Service Key provider with SSL Client Authentication key
Associate the service key provider to the proxy service which invokes the business service
OSB - Proxy Service WS-Security User Name Token
Configure Auth.xml or custom username token WS-Security Policy
OSB - Proxy Service WS-Security X509 Token
Configure Auth.xml and Sign.xml Policy
Change UseX509ForIdentity attribute in domain → WS Security → Inbound Mbean Token handlers Page to true
Ensure Certificate passed by client is present in certificate registry or the root CA in trust keystore depending upon weblogic certification path provider configuration
Configure Identity Assertion Provider and Username mapper class.
OSB - Business Service WS-Security User Name Token
Configure Auth or custom username token WS-Security Policy
Configure Service account for username provider
OSB - Business Service WS-Security X509 Token
Configure Sign.xml and Auth.xml policy ( or custom signing and username token policies) in the business service
Configure a PKI credential provider and service key provider containing the certificate to be used for signing and authentication
Associate the service key provider to the proxy service which invokes the business service.
*OSB - Proxy Service Digital Signature [ Request Only]*
Configure Sign.xml or a custom signing policy to the proxy service
Ensure Certificate passed by client is present in certificate registry or the root CA in trust keystore depending upon weblogic certification path provider configuration
*OSB – Business Service Digital Signature [ Request Only]*
Configure Sign.xml policy ( or custom signing policy) in the business service
Configure a PKI credential provider and service key provider containing the certificate to be used for signing
Associate the service key provider to the proxy service which invokes the business service.
Edited by: atheek1 on Aug 26, 2010 5:17 AM
Edited by: atheek1 on Aug 26, 2010 8:20 AM
Maybe you are looking for
-
Hi, Iam doing a report on enhancement, when i use teh code below for the conversion its giving an error To convert GUID in the unicode format <b>DEFINE move_casting. assign &1 to <unicode_x1> casting. assign &2
-
Running 9.0.4 Forms Demos in 10.1.2.0.2 Developer Suite
So, in my continuing adventures as the Oracle AS guy, I've been asked by the developers to install the Oracle Forms Demos so that they can use them. All of our developers have had Developer Suite 10.1.2.0.2 installed on their Windows machines, and th
-
Getting PID of Parents Parent Process ID.
I have Process P1 ------> ( forks() and exec() ) Process 2 -------> ( forks() and exec() ) Process 3. Now my requirement is to get the Process ID of Process P1 in Process P3.?? Its getting the Parents Parent Process ID. I am writing C Application and
-
Hi, I am using weblogic 9.2 on windows. I have the data source configured(Oracle 9.2) I am getting the following exception when I try to create temporaryBlob - BLOB blob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
-
Self Healing integration into third party software
I was wondering if there will be a programmers guide and possibly software libraries that will enable programmers to implement Self Healing and DTrace capabilities in the software we write. Wouldn�t it be cool to extend these capabilities into third