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
AshwinAshwin 

wsdl2apex setting inputHttpHeaders

Hi all,

 

I am new to salesforce and am using this tutorial to invoke a webservice.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm

 

My wsdl2Apex has

  

public Map<String,String> inputHttpHeaders_x;

 

in the DocSamplePort class. 

 

 

public class test {
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.inputHttpHeaders_x = new Map<String, String>();
}

 

And I get the following error while making a inputHttpHeaders_x object which is

 

 

Error: Compile Error: unexpected token: '=' at line 3 column 24 


I read lot of discussions in the forum and there seem to be no problems of this sort. Can anyone point me where I am going wrong?

 

Thanks in Advance.

 

 

AshwinAshwin
I figured out this problem. Pretty strange though. The solution was to create the object in a method not at class level.  So instead of this

 

public class test {
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.inputHttpHeaders_x = new Map<String, String>();
}

 

Would be:

 

public class test {
public void callService(){

docSample.DocSamplePort stub = new docSample.DocSamplePort();

stub.inputHttpHeaders_x = new Map<String, String>();

}

}

 

I am still trying to figure out how to call the method :D. Any suggestions?