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
Venki123Venki123 

Need a help in webservices

Hi !

 

I am new to sales force. I have taken small example webservice in forum . I am not getting any error but i am not ble to see "Hello world" in the Page.

 

Here is my class Venki:

 

global

classVenki {

 

webService

staticstring sayHello() {

 

return'Hello World!';

}

}

 

Controller Class:

public

classVenkiController {

String uname=

null;

 

publicString getUsername() {

 

returnuname;

}

publicString getHelloWorld() {

string result;

WSDL2ApexVenki.Venki stub =

newWSDL2ApexVenki.Venki();

uname = stub.sayHello();

return uname ;

}

 

 

}

 

Visual force Page:

<

apex:pagecontroller="VenkiController"tabStyle="Account">

<

apex:form><!-- Define the JavaScript function sayHello--><apex:actionFunctionname="HelloWorld"action="{!getHelloWorld}"rerender="out"/><h1> This is my first VisualForce Page! </h1><apex:outputTextvalue={!uname}/></apex:form>

</

apex:page>

 

 

What am i missing? Please suggest.

 

 

 

 

 

 

 

 

 

 

SRKSRK

U r call that action fucntion on the onload event i belive

  u page is created first & the in apex controller assing value in  uname

 property

u can try c
ommand button which u click after complite page get loaded  & rerender the outputText

Venki123Venki123

Hi SPK thanks for your reply. Can you please give me an example visual force code...

SRKSRK

Visual force Page:

<apex:pagecontroller="VenkiController"tabStyle="Account">

<apex:form>

<script>

 function show()

{

     testHello();

}

</script>

<apex:actionFunction name="testHello"  action="{!getHelloWorld}"  rerender="out"/>

<h1> This is my first VisualForce Page! </h1>

<apex:outputText value={!uname} id="out" />

<apex:commandbutton onclick = "show()"/>

</apex:form>

</apex:page>

Venki123Venki123

Thanks a lot !. I am getting below error now..please help..

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=

 

Class.WSDL2ApexVenki.Venki.sayHello: line 62, column 1 Class.VenkiController.getHelloWorld: line 11, column 1

Venki123Venki123

I reset the password..the error vanished but there is no out like Hello World

Venki123Venki123

There is no consitancy i am still keep getting the above error please help