on 07-27-2005 9:27 AM
Hi everyone,
I am trying to use the feature of "SAP connectivity" in the NDS.
I created a proxy for a simple RFC.
What I am trying to do is to call the RFC from a Java code.
Here is what I wrote :
try {
Z_Rfc_Ws_Test2_Input input = new Z_Rfc_Ws_Test2_Input();
input.setInput("Salut la compagnie");
SAPProxy_PortType proxy = new SAPProxy_PortType();
Z_Rfc_Ws_Test2_Output output = proxy.z_Rfc_Ws_Test2(input);
} catch (Exception e) {
e.printStackTrace();
}
I get an exception because I didn't specify the username and its credentials. Of course, I have to specify the server and the client number.
Here is the exception :
com.sap.aii.proxy.framework.core.BaseProxyException: JCoClient connection missing
at com.sap.aii.proxy.framework.core.AbstractProxy.send$(AbstractProxy.java:150)
at com.proxy.SAPProxy_PortType.z_Rfc_Ws_Test2(SAPProxy_PortType.java:16)
at Client.main(Client.java:45)
Can someone help with this issue ?
Thanks in advance.
You first have to create a JCO client:
//create client
JCO.Client client = JCO.createClient("client", "username", "password", "language", "server", "sysnr");
//connect to the SAP system
client.connect();
Then your code to create the Input object.
Z_Rfc_Ws_Test2_Input input = new Z_Rfc_Ws_Test2_Input();
input.setInput("Salut la compagnie");
SAPProxy_PortType proxy = new SAPProxy_PortType();
Next you have to pass the cieltn to the proxy class:
proxy.messageSpecifier.setJCOClient(client);
Now you can get the output using your own code:
Z_Rfc_Ws_Test2_Output output = proxy.z_Rfc_Ws_Test2(input);
And finally close the client if you're done:
client.disconnect();
Now you can write some code to display the results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also I fotget to mention that after getting connection place your code which calls the BAPI/RFC in another try block and finally close your connection.
Hope it has helped you.
Regards,
Guru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you are missing this (see my previous post):
Next you have to pass the client to the proxy class:
proxy.messageSpecifier.setJCOClient(client);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
In your below code the JCO configurations is missing I mean ur JCO client. Try some thing like this which is self explanatory.
(ur package name here if u have any)
import com.sap.mw.jco.*;
public class Jco {
public static void main(String[] args) {
// Necessary fields for Connection
JCO.Client myConnection = null;
JCO.Repository myRepository = null;
JCO.Function myFunction = null;
JCO.Field myHostName = null;
// Establishing a connection
try{
// Defining the connection parameters
myConnection = JCO.createClient("Client","User","Password","Lang","ServerIP","Sys Number");
myConnection.connect();
// Creating a repository
myRepository = new JCO.Repository(attribute,myConnection);
}catch(Exception e){
System.out.println(e.toString());
System.exit(1);
}
// Finally closing the connection
finally{
myConnection.disconnect();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guru,
I tried it but I get the exact same exception.
I know that in .Net I create a Proxy and a Destination class.
In the Destination class, I define all the user and server parameters. After, I pass the Destination class to the Proxy.
I think that we must do the same thing : how to pass the JCO connection to the proxy ?
Thanks.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.