Hello, my Project involve writing a openoffice sugarCRM plugin .so i need to make an interop communication between OO and sugarCRM probably via webservices.
i thought a starting point is to write a java client to connect to sugarrcm server and query the sugarCRM instance for some valuable data.
below is an example of soap params to send to sugarcrm server so to get available sugarCRM modules .what i need is to write a java client to connect to sugarcrm using below params and get back the results.
can someone give me hint (or java code) to write this soap client? many thanks.
Because SugarCRM chose to use a RPC/encoded messaging SOAP endpoint your choice of toolkit will be limited because RPC/encoded messaging is NOT supported by the newer toolkits like Apache CXF or Axis2. So it wouldn't be surprising if a future version of SugarCRM might change to a different web services interface (document/literal messaging if they stick with SOAP).
Alternately the WSDL will give you enough information to write a SAAJ client � though I wouldn�t recommend that with RPC/encoded.
i wrote a soap client to talk to my local sugarcrm server.
i just added soap.jar and mail.jar to my classpath & this simple code :
it seems my client don't work perfectly for all methods of sugar webservice
when running above java program ,i got this exception:
i don't know what i'm doing wrong & would appreciate if you guide me.
i know sugar wdsl file url. if i use WSDL2Java to generate my java stub classes , how can i invoke the web service via these generated classes & how to send requests and receive responses from sugar ?
Joined: Aug 19, 2005
Please do not write any new code that depends on Apache SOAP (org.apache.soap) - that is even more ancient than Axis 1.x (org.apache.axis).
Originally posted by othman El Moulat: if i use WSDL2Java to generate my java stub classes , how can i invoke the web service via these generated classes & how to send requests and receive responses from sugar?
That is detailed in the link I gave you; look under "3. WSDL2Java: Generate the Server-side Wrapper Code and Stubs For Easy Client Access" and later in "6. Client: Write a Client That Uses the Generated Stubs to Easily Access the Web Service". (Even that article dates back to 2002!!!)
For http://demo.sugarcrm.com/sugarcrm/soap.php?wsdl WSDL2Java creates the classes necessary for the client. You use the SugarsoapLocator to obtain an instance of the SugarsoapPortType through getSugarsoapPort(). On the SugarsoapPortType instance you can then call methods like get_available_modules(); WSDL2Java creates classes like Module_list and Error_value for you.
thanks for the helpful reply : i managed to generate the stub clients and here is my Test java class :
i now can get a reference to sugar soap web service & i have a plenty of remote sugar methods available for me to call. the first method i want to call is login(User_auth user_auth, String application_name);
i kow i have to call :
my questions: 1) what wsdl file i need to use (i used the demo one yuu gave me in your post).is the wsdl file fixed for a given web service or does it depends on my local sugar server ? 2) do i need to provide real 'password' string or use md5('password')? if yes should i use some java md5 library ? 3) what 'application_name' refer to in login method? 4) is it mandatory to login to sugar before calling any soap method ? or just create a session(username,password) and use that session String as param to suguarsoap methods ?
for my test code above ,I'm not getting the list of modules though .I'm sure there exist one module on my sugar2 server. but i can't get any.
Originally posted by othman El Moulat: 1) what wsdl file i need to use (i used the demo one yuu gave me in your post).is the wsdl file fixed for a given web service or does it depends on my local sugar server ?
To be on the safe side I would use the WSDL on your local sugar server. At the very least your local server version may be different from the version of the demo and they could expose a different SOAP API. It is conceivable that the SOAP API could change based on the configuration of the server - however I doubt that this is the case here.
2) do i need to provide real 'password' string or use md5('password')? if yes should i use some java md5 library ?
As you have already found out and as the SOAP intro shows you need to send the MD5 hash.
3) what 'application_name' refer to in login method?
I presume that you can configure the SugarRCM server to support multiple applications at once. I have no idea what the actually means. The application name could serve as an alias for a database that the server can access, or it could refer to one of many applications configured inside of SugarRCM; it may simply identify the accessing application to SugarRCM. The PHP SOAP samples seem to treat it as an optional parameter.
4) is it mandatory to login to sugar before calling any soap method ? or just create a session(username,password) and use that session String as param to suguarsoap methods ?
The samples suggest that you need to login first. However the application name seems to be only needed in some cases. I noted however that you specified "5.0.0RC" in the version slot.
This states: "parameter 3: string:version - this is the version of soap you are expecting"
The values "0.1" and "1" used in the samples don't make any sense there are only SOAP 1.1 and 1.2 in use (and "1.1" is the one you want)
One avenue to pursue is to see if you can get those PHP SOAP samples to work. If you have trouble getting the Java equivalent to work, use TCPMon (Tutorial) to intercept the successful PHP generated requests and compare them to the request generated by the failing Java code. The differences may give you a clue as to what is going wrong. [ December 14, 2007: Message edited by: Peer Reynders ]