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
tpausmatpausma 

SoapBindingStub.setHeader() does not exist?

Hi there,

In the API documentation, version 13.0; the following snippet of sample code is posted under the  "login" method:

Code:
private boolean login() {
  LoginResult loginResult = null;
  SoapBindingStub sfdc = null;
  try {
    //    Create binding object 
    sfdc = (SoapBindingStub) new SforceServiceLocator().getSoap();
    //    login
    loginResult = sfdc.login("username", "password");
  } catch (Exception ex) {
    System.out.println("An unexpected error has occurred." + ex.getMessage());
    return false;
  }

  System.out.println("Login was successful.");

  //    Reset the SOAP endpoint to the returned server URL
  sfdc._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());

  //    Create a new session header object
  //    add the session ID returned from the login
  SessionHeader sh = new SessionHeader();
  sh.setSessionId(loginResult.getSessionId());
  //    Set the session header for subsequent call authentication
  sfdc.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
                       "SessionHeader", sh);

.
.
.
}


 


However, the WSDL (I'm using the partner WSDL) which contains the definitions for the SOAP binding does not contain a method called "setHeader" and the API documentation itself mentions nothing about a setHeader method except in the sample code of a number of functions.

How does one set a header then if this does not work? Or am I completely missing something?
 

SuperfellSuperfell
The sample code is for Axis 1.x, and the setHeader call is a feature of that. If you're using something different, then you'll need to consult the docs for that for how to create soap headers.
wyvernwyvern
Which soap toolkit are you using?