• zhang gj
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Trying to set password while creating a user in Salesforce using partner.wsdl
One of the reason its not able to set a password because the user is not created in the Saleforce.

Hi,

 

We get an error stating "no operation available for the request..." when we are trying to bind the apexwsdl to create trigger programmatically.This issue is due to endpoint url not been set properly.Please find the sample which helped us in resolving the issue,posted by Abhinav gupta on a blog.

 

SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator()
02        .getSoap();
03LoginResult lr = binding.login(username, password);
04binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr
05        .getServerUrl());
06SessionHeader sh = new SessionHeader();
07sh.setSessionId(lr.getSessionId());
08binding.setHeader(new SforceServiceLocator().getServiceName()
09        .getNamespaceURI(), "SessionHeader", sh);
10ApexBindingStub apexBinding = (ApexBindingStub) new ApexServiceLocator()
11        .getApex();
12/*
13Line below was cause of problem, I was setting incorrect url for binding end point.
14*/
15apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY,
16        lr.getServerUrl());
17  
18// Apex Session Header
19com.sforce.soap._2006._08.apex.SessionHeader ash = new com.sforce.soap._2006._08.apex.SessionHeader();
20ash.setSessionId(lr.getSessionId());
21apexBinding.setHeader(new ApexServiceLocator().getServiceName()
22        .getNamespaceURI(), "SessionHeader", ash);
23  
24RunTestsRequest runTestsRequest = new RunTestsRequest(false,
25        new String[] { "TestFooBar" }, "myns", null);
26RunTestsResult runTests = apexBinding.runTests(runTestsRequest);
27System.out.println("Failures " + runTests.getNumFailures());

 

Metadata WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/m/18.0/[org-id]
03Partner WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/u/18.0/[org-id]
04  
05Both these URLs can be fetched via LoginResult.getServerUrl() and LoginResult.getMetadataServerUrl(). But there is no direct method  for Apex WSDL URL. 
06Though Apex WSDL/ENDPOINT URL is simply one char change
07https://[api node].salesforce.com/services/Soap/s/18.0/[org-id]
08So here is the trick, and the above code snippet will work fine then.
09*/
10apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY,
11    lr.getServerUrl().replaceAll("/u/", "/s/"));