Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Web Services
Salesforce webservice issue with authenticating
Naresh Talluri
Ranch Hand
Posts: 115
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I'm trying to add Lead programatically by using
SOAP
webservice call in salesforce.com
i got below error could you please help me out of it?
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle). log4j:WARN Please initialize the log4j system properly. https://test.salesforce.com/services/data/v20.0/sobjects/Account/ ENDPOINT Addr : javax.xml.rpc.service.endpoint.address AxisFault faultCode: {http://xml.apache.org/axis/}HTTP faultSubcode: faultString: (400)Bad Request faultActor: faultNode: faultDetail: {}:return code: 400 [{Destination URL not reset. The URL returned from login must be set "errorCode":"URL_NOT_RESET";}] {http://xml.apache.org/axis/}HttpErrorCode:400
Here is my code:
package com.demo; import java.rmi.RemoteException; import java.util.Iterator; import javax.xml.rpc.ServiceException; import com.sforce.soap.enterprise.AssignmentRuleHeader; import com.sforce.soap.enterprise.LoginResult; import com.sforce.soap.enterprise.QueryResult; import com.sforce.soap.enterprise.SaveResult; import com.sforce.soap.enterprise.SessionHeader; import com.sforce.soap.enterprise.SforceServiceLocator; import com.sforce.soap.enterprise.SoapBindingStub; import com.sforce.soap.enterprise.fault.LoginFault; import com.sforce.soap.enterprise.fault.UnexpectedErrorFault; import com.sforce.soap.enterprise.sobject.Lead; import com.sforce.soap.enterprise.sobject.SObject; public class LeadAssignment { static LeadAssignment _leadAssignment; public static void main(String[] args) { _leadAssignment = new LeadAssignment(); try { _leadAssignment.CreateLead(); } catch (Exception e) { e.printStackTrace(); } } public void CreateLead() throws UnexpectedErrorFault, LoginFault, RemoteException, ServiceException { // Create the proxy binding and login SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator() .getSoap(); binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, "https://test.salesforce.com/services/data/v20.0/sobjects/Account/"); System.out.println("--->"+binding._getProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY)); System.out.println("ENDPOINT Addr : "+SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY); //LoginResult lr = binding.login(USERNAME, PASSWORD+SECURITY_TOKEN); LoginResult lr = binding.login("slafferty@sokolovelaw.com.dev1", "VCpass2011lQXTr4QBwnDNlpfjYYL18v3r"); // Reset the binding to use the endpoint returned from login System.out.println("lurl :"+lr.getServerUrl()); binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr.getServerUrl()); // Create the session id header, and add it to the proxy binding SessionHeader sh = new SessionHeader(); sh.setSessionId(lr.getSessionId()); binding.setHeader(new SforceServiceLocator().getServiceName() .getNamespaceURI(), "SessionHeader", sh); // Create a new case and assign various properties Lead lead = new Lead(); lead.setFirstName("Joe"); lead.setLastName("Smith"); lead.setCompany("ABC Corporation"); lead.setLeadSource("API"); // The lead assignment rule will assign any new leads that // have "API" as the LeadSource to a particular user // Create the assignment rule header and add it to the proxy binding AssignmentRuleHeader arh = new AssignmentRuleHeader(); // In this sample we will look for a particular rule and if found // use the id for the lead assignment. If it is not found we will // instruct the call to use the current default rule. You can't use // both of these values together. QueryResult qr = binding .query("Select Id From AssignmentRule where Name = " + "'Mass Mail Campaign' "); if (qr.getSize() == 0) { arh.setUseDefaultRule(new Boolean(true)); } else { arh.setAssignmentRuleId(qr.getRecords(0).getId()); } binding.setHeader(new SforceServiceLocator().getServiceName() .getNamespaceURI(), "AssignmentRuleHeader", arh); // Every operation that results in a new or updated case, will // use the specified rule until the header is removed from the // proxy binding. SaveResult[] sr = binding.create(new SObject[] { lead }); for (int i = 0; i < sr.length; i++) { if (sr[i].isSuccess()) { System.out.println("Successfully created lead with id of: " + sr[i].getId().toString() + "."); } else { System.out.println("Error creating lead: " + sr[i].getErrors(0).getMessage()); } } // This call effectively removes the header, the next lead will // be assigned to the default lead owner. Remember to add the // session header back in. binding.clearHeaders(); binding.setHeader(new SforceServiceLocator().getServiceName() .getNamespaceURI(), "SessionHeader", sh); } }
thanks in advance for your help.
Yes, my master! Here is the tiny ad you asked for:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
jsf navigation and database connection
Axis1 (1.4) - Simple client proof of concept - SAXParserException: Content is not allowed in prolog
JSF 2.0 selectOneMenu control not populated
Fake a post request from java class
ArrayList of ArrayList<String>
More...