These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Problems calling an ASP.NET 2.0 web service using JavaScript

thfeldman67
Registered: Apr 25 2008
Posts: 23

I have been trying to call an ASP.NET web service using JavaScript code. It calls the web service - but does not pass ANY of the parameters. It seems like this should be easy. Any ideas would be much appreciated!!

I'll paste code for a simplified example using my EchoString web method:

var cURL = the URL to my WSDL file;
var oService = SOAP.connect(cURL);
var oRequest = { EchoString: {value: "test"}};
var oResults = SOAP.request({
cURL: cURL,
oRequest: oRequest,
cAction: "http://mynamespace/EchoString",
bEncoded: false,
cNameSpace: "http://mynamespace",
cResponseStyle: SOAPMessageStyle.Message
});

My Product Information:
LiveCycle Designer, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Here's how you can execute the connection to the web service using LiveCycle Designer.
Based on the value a user chooses from a list, you can pass that value to the service.

Enter the following script on the event you want to trigger the web service:

In JavaScript: xfa.connectionSet.MyWSDLDataConnection.execute(0);

In FormCalc: $connectionSet.MyWSDLDataConnection.execute(0)

In both cases, the parameter being passed is a Boolean value. When the results are returned from the web service, this value indicates whether the entire data DOM should be merged with the form or whether the returned values will replace those in the current instance of the form. Zero (0) indicates that the data will not be remerged; that is, no new fields or subforms will be added or removed directly as a result of this execute operation. One (1) indicates that all data in the data DOM will be remerged.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

thfeldman67
Registered: Apr 25 2008
Posts: 23
I appreciate the suggestion, but I an trying to create the connection all using JavaScript code - not using a Data Connection created (where you "drag and drop" controls for parameters/responses. Your suggestion assumes that you have a Data Connection setup - I'm trying to do without one ...
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Have you tried using the connect method. This method is much more staight forward than the request method. If nothing else you should be able to use it to test the connection between acrobat and the web service, and to get a listing of the remote procedures.

Have you tried the request without the "cAction", "bEncoded", and "cResponseStyle" parameters?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thfeldman67
Registered: Apr 25 2008
Posts: 23
Thanks for this suggestion. I tried all you suggested and no difference - each variation of the code calls the web service but does not pass any parameters to it.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Have you been able to use this web service from another client, like a web page? Is this your web service, so that you can see what's happening in the debugger?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thfeldman67
Registered: Apr 25 2008
Posts: 23
Yes - I have been able to use the web service from another client.

The web service is one that I created myself - so I can debug it (which is how I know it is calling the web service without passing in any parameters), modify it and do whatever I want to it.

I can even get this web service to work from within an Adobe LiveCycle PDF when I use a DataConnection with the WSDL file - I just can't get it to work when the connection to the web service is created in code ...
tarekahf
Registered: May 1 2008
Posts: 91
Hello everyone, this is my first post, and I have been using Adobe LiveCycle Designer for more than 18 months so far.

I am also interested in using ASP.NET 2.0 Web Services from Adobe LiveCycle.

May I know why you want to manually create the connection using code instead of using the connection created with the Wizards ?

I created a Web Service in ASP.NET and followed a flash tutorial on how to use a web service in LiveCycle in 15 seconds, and the results were impressive ! My boss was shocked when he saw the PDF calling the Web Service.

The function you are using to connect to the web service manually, is it restricted in terms of security ? I know some function in JavaScript require some trust settings in order to make them work.

Tarek.
thfeldman67
Registered: Apr 25 2008
Posts: 23
As for using the "wizard" to call the web service - I can do this as well, but I want to do more advanced things than this approach will allow. The reasons I want to use a connection created in code (vs. using a DataConnection created with a "wizard") are as follows:

1) I want to make it easier for non-technical users to create standard forms using tools that we create (ex. it would be much easier to train them to drag+drop a control containing our web service JavaScript code in one of our custom controls onto a PDF than using a combination of such code and the "wizard").

2) Our web services won't necessarily match our forms exactly. For example, we may have a web service that will receive one data point - but we want the form to collect 10 data points. We can't create an infinite number of web service interfaces that anticipate the number of data points that we might collect on one PDF form (1 thru n) in order to use these in the "wizard". We need to be able to write a generic form that can loop through all controls and use one standard call to the web service per data point.

As for security/trust issues, I'm pretty sure this is not the problem (though I suppose I could be wrong). I can verify that it is calling the web service using JavaScript code (it is my own web service - so I can verify this with 100% certainty) - I just cannot get it to receive the parameters I am passing to it - nor can I get the PDF to receive a result back. I would think if this was a security/trust issue, it woudn't be able to reach the web service at all (i.e. my guess is that it would be "all or nothing" - either it would all work or all fail). Not to mention that it works with the Data Connection I created using the "wizard" - why would that be allowed if it were a security/trust issue?
tarekahf
Registered: May 1 2008
Posts: 91
thfeldman67,

Ok, I understand your point.

With regards to security/trust issue, you can confirm the specs of the function your are calling from the Documentation of this function.

For example, I know for sure that the Acrobat JavaScript function used to save the current PDF as different file name requires trust to be enabled or some kind of wrapper function to make it trusted.

Another thing you may want to check is the method used to call the web service. There are generally 3 methods:

1. HTTP GET: Using URL and QueryString. This method allows you to call the web service from the IE by enter the address and parameters in the Address Bar.

2. HTTP Post: Using Form Action and Form Variables. After you develop a Web Service in ASP.NET, you can test this method directly by viewing the web service in the Explorer.

3. HTTP SOAP POST: Using SOAP Message Envelop. You have to make sure you are passing the correct SOAP Message Structure and version.

All methods above will return a Response which need to be parsed.

This will help you to troubleshoot the problem. You need to make sure you are using the correct format of the submitted request to the Web Service, and you need to make sure that you enabled calling the web wervice using the allowed method which can be configured in web.config.

You can try calling the web service from client-sde javaScript using the Ajax Object XMLHTTPRequest Object or something like that. This object supports all three methods mentioned. If you need further help in this area, please let me know. I have developed a web service recently and using VBScrirp from WSH / IE and JavaScript from IE / Lotus Notes to call the web service and all worked successfully. Initially, it did not work because the SOAP Message Envelop I was sending was not formatted properly. You can check the SOAP version/structure requirements from by viewing the web service under IE.

Tarek.