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
DJHDJH 

Missing setHeader() method in SforceServiceLocator()

I'm trying to duplicate the sample project, using my company's WSDL. I ran the WSDL document through WSDL2Java to get the appropriate classes.

First problem: _QueryOptions and _SessionHeader were not generated. I worked around this by swiping them from the sample project, since they should be the same for all customers.

Second problem: when I compile, I get the following errors:

AccessSforce1.java:182: cannot resolve symbol
symbol : method setHeader (java.lang.String,java.lang.String,com.sforce.soap.enterprise._SessionHeader)
AccessSforce1.java:469: cannot resolve symbol
symbol : method setHeader (java.lang.String,java.lang.String,com.sforce.soap.enterprise._QueryOptions)

The first error is at this part of my application source code, which is verbatim from the example code:

//Create a new session header object and set the session id to that returned by the login
_SessionHeader sh = new _SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader("SforceService", "SessionHeader", sh);

The second error is also an invocation of binding.setHeader:

_QueryOptions qo = new _QueryOptions();
qo.setBatchSize(new Integer(3));
binding.setHeader("SoapService", "QueryOptions", qo);

It seems from the code that setHeader() is supposed to be a method in SforceServiceLocator, or its superclass org.apache.axis.client.Service. But there's no such method.

I'm running Java 1.4.2 and I have Axis 1.1.

How do I get this to work? Is there an implementation for setHeader() (and presumably getHeader() available)?

DJH
DevAngelDevAngel

Hi DJH,

Try using the command switches shown below:

 

org.apache.axis.wsdl.WSDL2Java -v -a -T 1.2  enterprise.wsdl

DJHDJH
Thanks, that took care of my _QueryOptions, _SaveOptions and _SessionHeader class issues.

That still leaves me with one last problem: the missing setHeader() method. I understand this is defined in Stub, but it doesn't seem to be in either javax.rmi.CORBA.Stub or javax.xml.rpc.Stub, which are the only two varieties I know about. What am I missing?

DJH
zakzak
Sutb is in the org.apache.axis.client package

Cheers
Simon
DJHDJH
But org.apache.axis.client.Stub does not implement setHeader(), either.....

DJH
zakzak
Are you sure you have Axis 1.1 ? setTimeout is in my org.apache.axis.client.Stub, line 273
DJHDJH
I have Axis 1.1 and setTimeout() exists in org.apache.axis.client.Stub. setTimeout() is not my problem, though. My problem is that setHeader() does not exist.

DJH
zakzak
setHeader is lines 314 - 324

Cheers
Simon
DJHDJH


zak wrote:
setHeader is lines 314 - 324

Cheers
Simon




Not in my copy of org.apache.axis.client.Stub. It does not contain getHeader or setHeader(). Why not?

DJH
zakzak
you don't have Axis 1.1, go check the Source in CVS

http://cvs.apache.org/viewcvs.cgi/ws-axis/java/src/org/apache/axis/client/Stub.java

the revision taged as release 1.1 has setHeader in it, you must have an earlier version. I'd grab Axis 1.1 from the apache site and try again.