Expand my Community achievements bar.

How to get response of the web service

Avatar

Former Community Member
I can call a web service with the script :



xfa.connectionSet.DataConnection.execute(0);



in the form designer inside an event.



Which script can return me the response of the web service ? I return a string value for instance. I want to get this value with a script.
7 Replies

Avatar

Former Community Member
Hi,



You can do something like this:



try{

SOAP.wireDump = false;

var oListURL = "http://X.X.X.X:XXXX/XXXXWS-XXXXWS-context- root/XXXXWSSoapHttpPort?WSDL";

var service = SOAP.connect(oListURL);

if(typeof service != "object")

xfa.host.messageBox("Error calling the Web Service.");

else{

if(service.getXXX == "undefined")

xfa.host.messageBox("Error calling the Web Service.");

var array = service.getXXX(parameter); //if you method needs to receive a parameter

if( array != null && array != "" ){

//put your code here

}

}

}catch (e) {

}

Avatar

Former Community Member
Hi,

I run the code, but I get the error



SOAPError:java.lang.NullPointerException



I checked the code, I can reach to line



var array = service.getXXX(parameter);



The method is seen by the code, it doesnt give a message of any "undefined". However, when I call the service function, I get the error.

Avatar

Former Community Member
I got the problem. When I call a web service method which has no input parameters, it runs successfully and get the response. However, if I call a method with input parameters, it give this error :



SOAPError:java.lang.NullPointerException



what should I do ?

Avatar

Former Community Member
Hi,



When you call the method in the browser what did you get?



The web service must be RPC/enconded, what are you using?

Avatar

Level 6
Hi,



You should note that the Soap object will only work with Acrobat professional and not with Reader...

Avatar

Former Community Member
I write my web service as a simple java class and my java ide automaticaly creates it as a web service(including wsdl files,etc.). Then I export it as an ear file and deploy to server.



I dont really know what is a rpc encoded web service or how it is written ?



By the way, I know the difference of acrobat professional and reader. I just cant run a function with input parameters, other functions work as expected.

Avatar

Former Community Member
Hi,



When i create the Web Service in Jdev I have to choose the type is the Web Service!



When you call in WS in the browser to test the methods what did you get?