Solved

How to call a ASP.NET web service with acrobat and SOAP

Posted on 2008-10-15
33
1,069 Views
Last Modified: 2013-11-18
Hello All...
I am extremely new at SOAP and web services...so let me start there.  I have created a web service in ASP.NET that queries a database and returns a recordset.  I want to have a button on an adobe acrobat form that calls this web service and passes a parameter to it.  So for example, the user would type in there ID and then press a button.  The web service would look up that ID and then return all the records for that id from the database.
Can someone point me in the direction....possibly with some example code.  I just cant get my head wrapped around...1.  How to call the web service via SOAP. 2. how to accept the parameter via the web service.

Thank you
0
Comment
Question by:pattersonr
  • 18
  • 15
33 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22729691
SOAP is only available in the full version of Acrobat, not in Reader. Are you planning on distributing the form to users who only have Reader available? If so, you need to forget about SOAP. If you can make sure that all your users have the full version of Acrobat, you can write JavaScript code to access your web service. Do you have a background in Acrobat JavaScript? Any JavaScript?
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22729728
You can find the JavaScript documentation on this page: http://www.adobe.com/devnet/acrobat/javascript.html
The API reference has a section about SOAP that describes all the properties and methods of the SOAP object.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22733117
khkremer...
I have been reading the api for a few days now.  I am familiar with Javascript, but it has been awhile.  I have never worked with adobe javascript mode.  My understanding was that if I reader enabled the form then SOAP would work with reader only.  Maybe you have a better way?

I THINK  I have the soap code now.... but I am stuck because I am trying to get a fields value into a variable so that I can pass it.  I am trying to use the this.getfield method and I keep getting an error that this.getfield is not a function.  I have tried it at the document level in a function and at the button click level and I cant get it to work.  Without getting the variable then I am stuck....  So that is where I have been for about the last 24 hours.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22733141
Sorry noticed an error...I think the term I was looking for was Reader Extension Enabled Form

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22733226
Try getField (with a capital "F").
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22733276
that was so dumb...I have been beating wracking my brains on that one....
Now the code runs..but it returns undefined into the console.  There is a value in that field currently.
Any thoughts?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22733293
Update...
I had the valueasString added to the getField.  I changed it to value and it returns the value.  My only concern is the fact that I think it might need to be a string....  Can I convert it?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22733359
function Main()
{
var cURL = "http://localhost/Webservice/service.asmx?wsdl";
// Connect to the test service
var service = SOAP.connect(cURL);
// Print out the methods this service supports to the console
//for(var i in service) console.println(i);

var cTestString = this.getField("PolicyNum").value ;
// Call the echoString service -- it is an RPC Encoded method
var result = service.ListAgAdvantageData(cTestString);
// This should be the same as cTestString
console.println(cTestString)
console.println(result);
}

This code currently return the variable and [object Object] in the console....
I am not really sure what the object Object is...but I am assuming the result from the web service...
I really want to get a structured field list back....I am assuming I am missing some additional SOAP code.....

My end game is I want to submit the param...and populate other fields based on the data that is returned from the service...  The service basically runs a query....
Thanks for your continued help
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 22733386
Get used to the "undefined" - it does that all the time :)

If you are worried that you don't have a string, just convert it to one. You can force a value to be interpreted as a string by adding an empty string to it:

var thisIsNotAString = 8;

var thisIsAString = thisIsNotAString + "";

You can use a similar approach to convert a string to a number (JavaScript does not have a type system, and every variable gets interpreted a certain way depending on the situation) by multiplying e.g. with 1 or adding 0:

var thisIsAString = "8";

varthisIsANumber = thisIsAString + 0;
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22733775
Do you have the document "Developing Acrobat Applications Using JavaScript"? You can find that at the same location as the JS refrence document. It has a chapter about SOAP and Web Services. It shows you how to extract some useful information from the result object.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22734006
no I dont think I have read that document yet...
I will go take a look at it....
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22734548
khkremer

I am walking directly through the guided example and when I use the code below I get an error
var ListAgAdvantageData = {
"http://localhost/webservice/service.asmx:ListAgAdvantageData" {
intID: myIntegerObject
}

I have changed the names to work for my code.  The example does not have the " after Data...If I do that I get an unterminated string.  If I put the quote, I get a missing : after property ID.

Any ideas?
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22734755
I think there is a "}" missing from your snipped. Try this:

var ListAgAdvantageData = {
    "http://localhost/webservice/service.asmx:ListAgAdvantageData" {
        intID: myIntegerObject
    }
};
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22734828
I forgot to comment about the usage rights: You are right, a document can be modified so that it will allow Reader to  use SOAP, but these rights cannot be applied with Acrobat, you need the LifeCycle Rights Server (or whatever Adobe calls this software today) - and that's expensive.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22734906
khremer....
That was my fault...I had the other bracket in the code...I just didnt paste it.  I repaste over with yours and still no change.

As to the rights server....I knew that we would have to purchase something like that.
Do you know if you could do anything like this without SOAP? Maybe using HTTP and creating a URL with the parameter....I am kinda stabbing in the dark here.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22736143
khremer
The specs of this thing keep changing on me...I am going to accept your answer seeing as it helped me address my initial problem.  My new question is they want not to worry about the SOAP, but they are only concerned about being about to submit the entire pdf to some sort of web app/service/or sharepoint.  I see that there is a submit function with a URL...but what do I need on the server side to handle the submission?  I can put this in a different question if you want...
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22739266
There are several ways to submit data from a PDF form. The most straight forward method is to do a HTTP submit, just like a web form. In this case, you can even use the same backend program that you would use with a web form (makes is easy to test, because you can create a web form as well that allows you to determine if a problem is on the server side or your PDF).
You can also submit the data as FDF or XFDF - both are Adobe specific formats, XFDF is XML based, FDF is based on the PDF format. You can also submit - if you have the full version of Acrobat, or the document is Reader enabled - the full PDF with all filled in fields in the document (but then you would have the problem of extracting that data again on the server).
Would a standard web submission work for you?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22743348
Yes I think so....specifically they want a user to be able to pull up the pdf...fill in the form...sign it...and then press a button to submit that form back to a file repository.  I was thinking HTTP submit would be the way we would have to go as well....
Can you point me in the direction for HTTP submit?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22743365
khkremer....
I actually read your post again....They actually want the entire file...not just the data.
They want the pdf to be stored completely either in sharepoint or some other file repository.  They specifically want to keep the pdf file intact with the form and data.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22757514
OK, as I said, that is possible. There is an easy and a more complex way to do that. Here is the easy variant:

Add a button to your document (add a label "Submit" or something similar). On the "Actions" tab create a "Mouse Up" action with an action of "Submit a form". Then click on the "Add" button. On the following dialog provide the path to your server program that can receive a file, and select the Export Format to "The complete document".
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22757735
khkremer,

Thanks for your continued help.  Does this only work in reader with extensions enabled?  Is there any way to submit an entire pdf without extensions enabled?  I was performing the process that you described above and kept getting a general error in acrobat.  So I tried the same procedure, but with an email.  With an email it worked in acrobat, but got an operation not possible in reader...hence the question above.  
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22757894
Yes, this requires the extensions enabled - otherwise Reader will not be able to save the file with the modifications, and no, without Reader extensions, you will not be able to submit the whole PDF file. As an alternative, you could submit just the form data, and then merge the form data with the original PDF on the server, and save that file. That's  a bit more involved, but it would get around the  requirements for a more complicated PDF document (involving more cost and certain licensing requirements).

What is your server backend doing when it receives the PDF file? When you say a "general error" in Acrobat, what exactly do you mean?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22757906
khkremer,

Do you know why I would get a general error when I try to post in acrobat.  I created a web folder in IIS so that I could drop files directly to a folder on my computer.  I am going on the assumption right now that if we need extensions they are going to purchase them.  So I am continuing the endeavor to post directly to a folder
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22757940
Again, what exactly is this "general error"? Are you talking about an Acrobat crash?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22757991
sorry missed your comment before I posted....
I dont think saving the data and recombining will work because we are trying to allow the users to digitally sign the document.  I am assuming that if we separate the data and form...then the digital signature would be invalid.  (That might be an incorrect assumption)....

as to the error.  I did what you described above.  I created a button. Then assigned the submit action.  Clicked entire PDF.  Then for the url....http:\\localhost\webfolder.  I have IIS installed on my local machine..So I created a webfolder in IIS.  I tested that I could copy a file to the folder from my desktop.  That works fine.  However, when I try the submit...acrobat attempts and in the box that comes up it has the url and beside it...it says general error.  No additional description... :(

I have also tried sharepoint without any luck so far.  I thought the local computer would be easier to work with for starters.
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22758009
sorry put the wrong \  should be /
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22758028
Unfortunately, this is not how it works. The file will be uploaded to the server using a HTTP request, and you need some custom code to deal with that. I'm not familiar enough with either IEE or Sharepoint to tell you how that needs to be done. I may have some Perl code somewhere that does that (but I need to dig deep for that, it's been a few years since I last used that). Would the Perl code be helpful?
0
 
LVL 1

Author Comment

by:pattersonr
ID: 22758113
yes if you could find it.  I might be able to gather enough from that to create some sort of asp front end.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22758171
While I'm looking (this will take a day or so, the information is probably on one of my PCs at home), take a look at this: http://www.adobe.com/devnet/acrobat/fdftoolkit.html
This may contain everything you need to receive a full PDF document.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22758356
Here is some information with some PHP code from a few years ago:
http://www.experts-exchange.com/Web_Development/Document_Imaging/Adobe_Acrobat/Q_20949792.html?sfQueryTermInfo=1+acrobat+complet+document+pdf+submit+upload

Close to the end of that discussion I'm writing this:
"OK, PHP it is. I'm however not a PHP expert, and you have to do some with on your own. :-)

This is the most basic PHP script that can receive a PDF file. It's _NOT_ a normal file upload, the PDF file is sent as POST data, so don't use any "normal PHP file upload functions" - whatever they are.

<?
$fptr = fopen("/tmp/temp.pdf", "w");
fputs($fptr, $HTTP_RAW_POST_DATA);
fclose($fptr);
?>

Just put this into a file e.g. PDFupload.php on your server and use the path to this script as URL in your Submit button.

This only creates a file /tmp/temp.pdf on your server, which is a bad idea :-) You need to give this file a unique name (e.g. attach a time stamp to the file name or something like this)."

Maybe the information about the "post data" will allow you to convert that to ASP.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22758396
And here is some information about how to convert that to ASP:
http://team.mixmedia.com/index.php?title=globals_http_raw_post_data_in_asp&more=1&c=1&tb=1&pb=1

0
 
LVL 1

Author Comment

by:pattersonr
ID: 22758802
khremer,

Ok you have been brilliant.. I am going to go ahead an close this issue since it has really turned into about 10 others.  I think the code that you have given me certainly will help me get a demo site up and going to test the pdf submission.  I am as you can probably tell not that proficient at this stuff so it may take me awhile.  Thank again for your help.  I am going to accept one of the earlier answers since that dealt with the original question.  
0
 
LVL 1

Author Closing Comment

by:pattersonr
ID: 31506391
Thank you.  Your help has really been invaluable.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SSL WCF Service Issues - Value cannot be null 6 43
Upload PDF On Mobile 1 82
pdf reading with FULL screen 2 20
Problem to page 4 29
*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now