Expand my Community achievements bar.

Submit Pdf form to http w/ credentials (username/password)

Avatar

Level 1

Hi!

I developed a form in Adobe LiveCycle, it has a button which submits form with attachments to http site.

No coding involved, just configuration of the button.

Http site requires credentials (username/password). How do I pass those credentials with submission?

Can username/password be added to http header?

Or I can excecute some javascript before submission?

Thanks you!

7 Replies

Avatar

Level 1

Did you ever get an answer to your question?

Avatar

Level 1

Nope

I was thinking about submitting it to a web service instead.

Credentials for web service can be configured File->New Data Connection->WSDL File.

Theoretically....

The thing is.. you can't just submit to web service, you have to call a method and pass parameters. How do I pass the whole form with attachments. Not sure.

With http submission the whole form is sent as POST http request. I receive it as a byte array on another side and can just save as file with pdf extention or do whatever...

I'll post back about how it goes with web service submission.

Avatar

Level 1

Using web service does not work so far.

I created a very simple prove-of-concept web service, which has a valid wsdl and works fine from other client test application I created.

It was very easy to add it as "New Data Connection" to the form.

But.... values from the form are not getting passed. Why??? How to troubleshoot and fix???

I spent almost the whole day trying to find any posts, no way...

Anyway if anybody has a clue please reply.

Prove-of-concept web service has one method with 2 parameters (string and int). It simply concatinates them and returns as a string with space in between.

In Pdf form in "Data View" everything is displayed correctly (web service method name, both parameters, return(response) value, "SubmitPdfBtn"). I did "Generate Fields" to put new controls binded to web service fields on the form. When I click the button, web service is called, result is return always as " 0" as though it doesn't pass any input parameters.

I expect to see different result, depending on what I input in string and int field.

Very disappointed

Avatar

Level 1

Stephan Cameron offers a lot of info.

Http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records.

Let me know if this helped. I typed this by hand, so hopefully I typed everything correctly.

Joani S.

Sent from my iPad

Avatar

Level 1

Joani, thank you very much for caring.

Unfortunately I did not find answers to my questions yet, but I figure out why my WCF web service does not work

I guess... it is not supported he-he. I tried to use 2 different bindings (this is .net I am talking about) basicHttpBinding and wsHttpBinding. Both support soap, have wsdl, etc.

Only basicHttpBinding was recognized. The other one is not considered to be a valid web service from Adobe LiveCycle perspective

But! Even though it was recognized, it was not working!!!!

As soon as I tried creating web service old-fashioned way (asmx), it worked. I was able to pass values from the form to the service and receive response back.

So I guess WCF is not supported.

The question about attachment still remains... how to submit those through the web service.

Avatar

Level 1

I got it working

1. WS (in .net) must be asmx service. WS method accepting attachment should have string as a parameter, which will be passed as base-64 encoded string. So to save it as a file it has to be decoded first. I used byte[] ... = Convert.FromBase64String(yourstring).

Keep in mind string <= 2GB

2. In PDF file add WS service as Data Connection (File->New Data Connection ->WSDL File-> wsdl -> etc...). PDF will generate all WS parameters and a button to call WS. Drag and drop data connection on the form OR right mouse click -> generate fields OR set <connect> element of different controls as you wish to match data connection. Let's say control generated and binded to WS input string parameter is called "base64StringDocContent" (name = "base64StringDocContent") and button that submits to WS is called "submitAttachmentBtn" (name="submitAttachmentBtn").

3. Javascript code to send attachment to WS:

//access pdf form

var formDom = event.target;

//attachment id should be unique, can be anything you like

var attachmentId = new Date().getTime() + "";

//prompt user for document and get it

var documentSelected = formDom.importDataObject(attachmentId);

if (documentSelected == true){

     //user selected the document

     //get stream of the document (attachment)

     var inputStream = formDom.getDataObjectContents(attachmentId);

    

     //get new stream encoded as base64

     var vEncodedStream = Net.streamEncode(inputStream, "base64");

     //get string from the stream

     var sBase64 = util.stringFromStream(vEncodeStream);

     //get conrol which is binded to WS input parameter

     //my PDF form is called form1

     var wsInputParam = form1.resolveNode("$..base64StringDocContent");

    

     //get button which submits to WS

     var wsSubmitBtn = form1.resolveNode("$..submitAttachmentBtn");

     //assign attachment content (encoded string to input parameter)

     wsInputParam.rawValue = sBase64;

     //call click event of WS submit button

     wsSubmitBtn.execEvent('click');

     //done

     //if WS returns any value it will be assigned to control binded to output value of the web service.

   

}

else{

     //user clicked Cancel

}

4. Validation and try and catch should be added where/when needed.

Hope it saves a couple of days for somebody.

Good luck!!!

I am still curious how to work with credentials doing http submission.

If somebody has a solution please post it.

Avatar

Level 1

Awesome!

You rock!

Sent from my iPad