function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kaulsaksoftkaulsaksoft 

Web Services

I downloaded the partner wsdl and using axis converted it to java. Now i cannot locate the class SoapBindingStub.

Have I made any error.

 

Please help me

 

kaulsaksoftkaulsaksoft

private void login() throws Exception{ System.out.println("Here in login"); Login login = new Login(); login.setUsername(username); login.setPassword(password); System.out.println("Here in login" +login.getUsername()); System.out.println("Here in login" +login.getPassword()); LoginScopeHeader loginHeader = new LoginScopeHeader(); this.binding._setProperty(SforceServiceStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl(); // loginHeader.setOrganizationId("00D80000000c5AL"); CallOptions callOptions = new CallOptions(); binding =(SforceServiceStub) new SforceServiceStub binding.login(login, loginHeader, callOptions); System.out.println("Here after binding"); System.out.println("LOGGING IN NOW...." +binding.login(login, loginHeader, callOptions)); SessionHeader sh = new SessionHeader(); //sh.setSessionId(loginResult.getServerUrl()); //binding._setServiceClient(_serviceClient) }

in the above java program I am unable to create the binding using the SforceServiceStub.

 

Please has someone attempted using SforceServiceStub in the java program for logging into salesforce

SuperfellSuperfell
You probably used Axis2 which generates a completely different set of classes to Axis 1.x (all the samples are for Axis 1.x)
mpiercempierce
Check that your classpath settings are correct. You might not have your IDE configured to look in the directory that your generated code is in.
kaulsaksoftkaulsaksoft

Hi Simon

 

Thanks for replying

 

Yes i used Axis2-1.4.1 for generating from the partner WSDL. The classes it generates are completely different from the one generated using Axis1.

Can u please give me any example where Axis2 has been used.

 

I am not able to figure out which methods are being used for creating a login method .

SuperfellSuperfell
I'd recommend you use Axis 1.x instead of Axis2.x
kaulsaksoftkaulsaksoft

import java.net.MalformedURLException; import java.net.URL; import java.rmi.RemoteException; import java.util.Iterator; import javax.xml.rpc.ServiceException; import org.apache.axiom.om.OMElement; import org.apache.axis.transport.http.HTTPConstants; import org.apache.axis.client.*; import com.sforce.soap.partner.SforceServiceCallbackHandler; import com.sforce.soap.partner.SforceServiceStub; import com.sforce.soap.partner.SforceServiceStub.CallOptions; import com.sforce.soap.partner.SforceServiceStub.Login; import com.sforce.soap.partner.SforceServiceStub.LoginResponse; import com.sforce.soap.partner.SforceServiceStub.LoginResult; import com.sforce.soap.partner.SforceServiceStub.LoginScopeHeader; import com.sforce.soap.partner.SforceServiceStub.Query; import com.sforce.soap.partner.SforceServiceStub.QueryResult; import com.sforce.soap.partner.SforceServiceStub.SessionHeader; import org.apache.axis2.client.Options; public class MyDemo { private static String username = "1234@83demo.com"; private static String token ="56687678678678"; private static String password ="1234" + token; private SforceServiceStub binding; public static void main(String args[]) { MyDemo d = new MyDemo(); try { System.out.println("Here in main"); d.login(); //d.search(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void login() throws Exception { System.out.println("Here in Login Method "); SforceServiceStub stub = new SforceServiceStub(); Options options = stub._getServiceClient().getOptions(); options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE); options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE); System.out.println("Here before Login"); Login login = new Login(); // Salesforce user name login.setUsername(username); // Your password at Salesforce followed by your security token login.setPassword(password); System.out.println("After setting username and password"); LoginResult lr = stub.login(login, null,null).getResult(); System.out.println("Here after Login"); System.out.println(lr.getServerUrl()); System.out.println(lr.getSessionId()); SessionHeader sh = new SessionHeader(); sh.setSessionId(lr.getSessionId()); stub = new SforceServiceStub(lr.getServerUrl().replace("https:", "http:")); Query q = new Query(); q.setQueryString("select id, name, accountNumber from Account"); QueryResult qr = stub.query(q, sh, null, null,null, null).getResult(); System.out.println("Query return a total " + qr.getSize() + " rows"); OMElement o = (OMElement) qr.getRecords()[0]; Iterator i = o.getChildElements(); while(i.hasNext()) { OMElement c = (OMElement)i.next(); System.out.println(c.getLocalName() + " : " + c.getText()); } } }

Hi Simon

 

I created the java program using the classes generated from Axis2. But I am getting a connection time out error.

 

org.apache.axis2.AxisFault: Connection timed out: connect

at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)

at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)at org.apache.axis2.transport.http.HTTPSender.send(

HTTPSender.java:75)

at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)

 

Can u please tell me why i would be so .

 

We i try to access this site in the web i get

https://www.salesforce.com/services/Soap/u/16.0

 

405 GET not supported

 

error.

mpiercempierce

I have a tutorial on how to connect to the partner API that might be easier to get started with. Give it a try: http://eng.genius.com/blog/2009/05/23/salesforcecom-partner-soap-api-jax-ws-tutorial-part-1/

 

Let me know if you have any difficulties doing the tutorial.

kaulsaksoftkaulsaksoft

Hi

 

Thanx for replying.

 

I will be going through the tutorial and if i have any difficulties I will surely let u know.

 

Thanx again

 

Regards

 

kaulsaksoft

airrick3airrick3
@SimonF,  why do you recommend Axis1 over Axis2? 
SuperfellSuperfell

Axis1 is stable, works, requires less boilerplate code to use, and there's lots of sample code

http://www.pocketsoap.com/weblog/2006/05/1622.html 

datekaroradatekarora

Is using Axis-2 still an issue?  Quick response is appreciated as we are in the middle of  building webservice using Axis-2 1.4.  Thanks.

SuperfellSuperfell

Last time i looked (which has been a while), you could get it working with Axis2, but there seemed little point, you'd end up having to write more clue code, and for very little to no actual benefit. I'd stick with either Axis1, or WSC.

airrick3airrick3

I agree with SimonF,  Axis1 was stabler then Axis2 when it came to generating the classes from the WSDL (when using the Enterprise API).

datekaroradatekarora

Thanks. One more clarification though -does it matter what kind of process is being used.

Actually,  reading the initial post on this I realized that it stated about partner wsdl.

In my case I am using the AuthenticationService.wsdl for implementing delegation authentication. I guess it should not matter but thought I will confirm before redoing my work using axis1.