Expand my Community achievements bar.

How to call preview release SOAP API from non-java environment (e.g. .NET)

Avatar

Former Community Member
I've finally managed to get the Forms Server ES preview release installed and configured together with JBoss.



Now I want to try and call the SOAP API from a .NET project.



The only article I have on this is this:


Adobe - Developer Center : Developing a .NET web application using Adobe LiveCycle Forms



The articel looks useful (potentially), but the ES Preview Release doesn't offer any DLL client libraries such as "ICSharpCode.SharpZipLib.dll" mentioned in the article.



So, as an alternative I've tried generating a .NET class library from the WSDL definition at "http://localhost:8080/soap/services/FormsService?wsdl". This seems to generate a class library ok. But now I'm trying to understand what all the arguments are for the renderForm() and renderPDFForm() methods... My method calls seem to be getting SoapExceptions back so it feels as if I'm nearly there if only I could account for all the arguments correctly.



Is there a comprehensive description of these anywhere? All I've found so far is the
java class library documentation for the FormServiceClient class methods, which isn't quite the same as what I'm trying to use.
25 Replies

Avatar

Level 10
Refer to the LiveCycle SDK at http://www.adobe.com/support/documentation/en/livecycle/ (under Develop) for all information on developing application with LiveCycle products.



You can find a bunch of examples under the API Quick Start section.



You can also find a .Net specific example under the section Invoking LiveCycle ES/Invoking LiveCycle ES Using Web Services/Creating a .NET client assembly



Jasmin

Avatar

Former Community Member
Thanks, but I'm lost - can you be more specific about *exactly* where the docs you mention are? There's a ton of stuff under 'quick start' and none of it looks particularly relevant to my problem.

Avatar

Former Community Member
In case anyone else is reading this and is as lost as me, the docs mentioned above would seem to be located
here. Unzip the 'sdkHelp.zip' file and extract it somewhere local - it produces a load of inter-navigable html help docs.

Avatar

Former Community Member
However, the "Creating a .NET client assembly" stuff is no use - it describes exactly what I've done already (see initial posting above).

Hopefully the Quick Starts stuff will be more use...

Avatar

Former Community Member
The Creating a .NET assembly topic is a general description of creating a .NET assembly that consumes a services native SOAP stack. As an example - this topic explains how to upload a form to the repository.



However -- all Forms ES operations have examples that show SOAP invocation:



http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Forms.11.1.html



There are 10 Forms SOAP code examples. See the Rendering Interactive PDF Forms quick start.



In addition -- most LiveCycle ES operations have a corresponding code example that shows how to perform the operation via web services and Java APIs.

Avatar

Former Community Member
ALso - when creating your proxy object - be sure to set the user name and password - as discussed in the web service section:



FormsServiceService formsClient = new OutputServiceService();

formsClient.Credentials = new System.Net.NetworkCredential("administrator", "password");

Avatar

Former Community Member
Also - you may want to read this topic: Rendering an interactive PDF form using the web service API



This topic provides step by step instructions on how to render a form using web services and is located at:



http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/renderingPDF.32.4.html

Avatar

Former Community Member
Quick Starts not proving much use so far.



What I'm after, really, is something a bit like the stuff in sdkHelp/programmer/javadoc/com/adobe/livecycle/formsservice/client/FormsServiceClient.html, but for .NET, and much, much more detailed.



In simple terms, what I've got is an XFA form template created in LiveCycle Designer, and some data that I want to import into it. I want to call the FormsService SOAP API to request a PDF document that's made up of my template and the data.



I'm using the Preview Release of Forms Server ES. This doesn't contain any helpful .NET DLLs so I'm having to create my own web service proxy class using the WSDL definition at "http://localhost:8080/soap/services/FormsService?wsdl".



This produces a class that exposes a handful of methods including "renderForm()" and "renderPDFForm". I'm trying to call these but I'm having to guess what the arguments are.



For instance, in the following example, can somebody tell me exactly what ALL these arguments are and what I need to supply to them in order to render the PDF:



public BLOB renderForm(

string formQuery,

FormPreference formPreference,

BLOB inDataDoc,

RenderOptionsSpec renderFormOptionsSpec,

string userAgent,

string applicationWebRoot,

string targetURL,

string contentRootURI,

string baseURL,

out BLOB outputXML,

out long pageCount,

out string locale,

out string actualRendering,

out FormsResult renderFormResult)



At the moment, when I call the above method, I'm getting the following error:



Soap Exception: System.Web.Services.Protocols.SoapException: java.io.IOException: java.lang.NullPointerException at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at FormsServiceService.renderForm(String formQuery, FormPreference formPreference, BLOB inDataDoc, RenderOptionsSpec renderFormOptionsSpec, String userAgent, String applicationWebRoot, String targetURL, String contentRootURI, String baseURL, BLOB& outputXML, Int64& pageCount, String& locale, String& actualRendering, FormsResult& renderFormResult)

Avatar

Former Community Member
NB: in the above example, I am populating SOME of the arguments...as follows:<br /><br />formQuery <--- I'm just supplying the name of my XFA template<br />formPreference <--- I'm supplying FormPreference.PDFForm<br />inDataDoc <--- I'm supplying a BLOB object with it's binaryData field populated with a byte array representing an XML document containing the data I want to import into my XFA template.<br /><br />contentRootURI <--- I'm supplying the absolute path to the location of the XFA template, as named in the formQuery argument.<br /><br />All other arguments are either empty strings ("") or newly instantiated objects of a type to match that of the argument.<br /><br />Here's a code snip:<br /><br />BLOB renderedForm = null;<br />BLOB dataDoc = new BLOB();<br />string xmlData ="<?xml version=\"1.0\" encoding=\"UTF-8\"?><book>Test</book>";<br />byte[] byteData = System.Text.UTF8Encoding.UTF8.GetBytes(xmlData);<br />dataDoc.binaryData = byteData;<br /><br />BLOB v = new BLOB();<br />long w = 0;<br />string x = string.Empty;<br />string y = string.Empty;<br />FormsResult z = new FormsResult();<br /><br />renderedForm = fss.renderForm(<br /> "ExampleXFAForm_EmbeddedFonts.pdf",<br /> FormPreference.PDFForm,<br /> dataDoc,<br /> new RenderOptionsSpec(),<br /> "",<br /> "",<br /> "",<br /> "C:\\PETE\\LiveCycle ES Server\\dev\\VS.NET\\Projects\\Trial01",<br /> "",<br /> out v,<br /> out w,<br /> out x,<br /> out y,<br /> out z);<br /><br />Where am I going wrong, and what's the meaning of the 'null pointer exception' I've quoted in my previous post?

Avatar

Former Community Member
IN LiveCycle ES - developers have to create their own proxy assemblies.



2nd - what is happening is that the Preview release is using an old code base that does not match up wiht the docs. That is the cause of your problem. LiveCycle ES has new Form operations that require a lot fewer parameters. Here is the method signature that is used to render a PDF form:



public BLOB renderPDFForm ( System.String formQuery , BLOB inDataDoc , PDFFormRenderSpec pdfFormRenderSpec , URLSpec urlSpec , mapItem[] attachments , System.Int64 pageCount , System.String locale , FormsResult renderPDFFormResult )



This is the code base that lines up with the documenation. The method renderForm is no longer used.

Avatar

Former Community Member
This is going from bad to worse.

I've been in touch with an Adobe representative in the UK about the possibility of using LiveCycle ES in our project solution, and he specifically pointed me in the direction of the preview release as something that would enable me to make an assessment of how feasible it would be for us to use the product.



Now you're telling me that the preview release is not only using an obsolete code base, but also that the documentation which certain colleagues of yours have been advising me to read in order to solve the problems I'm having, is in fact for a different, newer API.



How am I supposed to make a reasoned and intelligent assessment of this product within a reasonable timeframe? It seems almost as if I have to purchase the full version of the product first in order to work out whether I want to purchase it or not! I'm at my wits end with this.



Can anyone help me specifically with the preview release issues I've described above, or advise me how to progress this some other way?



Also, never mind the fact the Preview Release is an old code base, there must be a way of getting it to work as it is, surely? Can someone tell me how? It must be possible to pass stuff in those extra parameters, even if they're "deprecated".



I just want to be able to get a PDF populated with data, and incorporate it into a proof of concept. It's not much to ask, surely?

Avatar

Level 10
You can get an evaluation of the 8.0.1 version on the developer web site. You don't have to purchase the product in order to try it. Just go ahead and download it from this URL:



http://www.adobe.com/devnet/livecycle/



Jasmin

Avatar

Former Community Member
Here is Java code that uses Java proxy classes that were created using AXIS and the Forms service WSDL. ALthough it is not .NET code, it shows how to render a form by invoking the renderPDFForm operation. You should invoke renderPDFForm, not renderForm.



The Java code is:



com.adobe.idp.services.FormsServiceServiceLocator sl = new FormsServiceServiceLocator();

FormsService formsOb = sl.getFormsService();

((javax.xml.rpc.Stub)formsOb)._setProperty(javax.xml.rpc.Stub.SERNAME_PROPERTY, "administrator");

((javax.xml.rpc.Stub)formsOb)._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "password");



//Specify file attachments to attach to the form

FileInputStream fileAttachment = new FileInputStream("C:\\rideau1.jpg");

BLOB attachment1 = new BLOB();

int len = fileAttachment.available();

byte []fileStream = new byte[len] ;

fileAttachment.read(fileStream);

attachment1.setBinaryData(fileStream);

String fileName = "rideau1.jpg";



//Create a HashMap object to store file attachments

HashMap fileAttachments = new HashMap();

fileAttachments.put(fileName, attachment1);



//Create a PDFFormRenderSpec object

PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();

pdfFormRenderSpec.setCacheEnabled(new Boolean(true));



//Specify URI values used by the Forms service

URLSpec uriValues = new URLSpec();

uriValues.setApplicationWebRoot("http://localhost:8080/FormsServiceClientApp");

uriValues.setContentRootURI("repository://");

uriValues.setTargetURL("http://localhost:8080/FormsServiceClientApp/HandleData");



//Create class holder objects

BLOBHolder outRenderPDFFormResultDoc = new BLOBHolder();

FormsResultHolder formsResult = new FormsResultHolder();

BLOBHolder blobHolder = new BLOBHolder();

LongHolder longHolder = new LongHolder();

StringHolder stringHolder = new StringHolder();



//Invoke the renderPDFForm method to render

//an interactive PDF form

formsOb.renderPDFForm(

"/Loan.xdp",

null,

pdfFormRenderSpec,

uriValues,

fileAttachments,

blobHolder,

longHolder,

stringHolder,

formsResult);



//Create a BLOB object that contains form data

BLOB formData = formsResult.value.getOutputContent();





This example will be ported to .NET to show the exact .NET syntax.

Avatar

Former Community Member
Thanks I've seen your java example in the documentation already. I originally hoped to be able to use this as inspiration for my .NET version but ran into the diffiuclties I've mentioned previously



More interesting is the availability of a proper version of LiveCycle ES for evalutation purposes. If only I'd known about this earlier I wouldn't have wasted any time on the preview release.



Well, I'll scrap everything and start again with this, and see how it goes.

Avatar

Former Community Member
HI Pete,



I ported the Java web service code example to .NET code. This .NET example works and renders a form.



However - when you create your .NET assembly - be sure to change the URL in your proxy class from



http://localhost:8080/soap/services/FormsService



to



http://localhost:8080/soap/services/FormsService?blob=base64



This ensures that binary data is returned with the BLOB instance.



Good luck and here is the .NET example (call renderPDFForm):



try

{

FormsServiceService forms = new FormsServiceService ();

forms.Credentials = new System.Net.NetworkCredential("administrator", "password");



//Create a PDFFormRenderSpec object

PDFFormRenderSpec pdfFormRenderSpec = new PDFFormRenderSpec();

pdfFormRenderSpec.cacheEnabled = new Boolean();

pdfFormRenderSpec.locale="en_US";

pdfFormRenderSpec.acrobatVersion = AcrobatVersion.auto;



//Specify URLSpec values

URLSpec uriValues = new URLSpec();

uriValues.applicationWebRoot = "";

uriValues.contentRootURI = "C:\\Adobe";

uriValues.targetURL = "";



//Create class holder objects

FormsResult formsResult = new FormsResult();

System.Int64 numPage = 0;

string locale = "";



//Invoke the renderPDFForm method to render

//a PDF form

forms.renderPDFForm(

"Loan.xdp",

null,

pdfFormRenderSpec,

uriValues,

null,

out numPage,

out locale,

out formsResult);



//Create a BLOB object that contains form data

byte[] formData = formsResult.outputContent.binaryData;



//Write the Form to a file

string FILE_NAME = "C:\\Adobe\\RenderedForm.pdf" ;

FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);



//Create a BinaryWriter object

BinaryWriter w = new BinaryWriter(fs2);

w.Write(formData);

w.Close();

fs2.Close();





}

catch (Exception ee)

{

Console.WriteLine("An unexpected exception was encountered: " + ee.Message + "\n" + ee.StackTrace);

}

Avatar

Former Community Member
Well thank you Scott, I have now managed to install/configure the full trial version of LiveCycle ES and have finally got things working on a very basic level, using your sample code as a starting point.



Currently I have successfully rendered my original LiveCycle xfa template document using the above technique, and have also managed to populate some of the fields in it using some xml data.



The thing I need to now work out is how to populate dropdowns (combo box controls) with values on-the-fly, and to then also include pre-selected values for dropdowns in the xml data I pass to renderPDFForm().



Currently my dropdowns are being rendered as empty, and clearly this is because I haven't provided the list values for them. But where do I specify these and how do I include them in the call to renderPDFForm() ?



Hope you can help...

Avatar

Level 10
The best thing is to use the Form Designer Help. Go under Help/LiveCycle Designer Help and do a search for "dynamically populate drop-down".



The explanation should get you going.



Jasmin

Avatar

Level 10
You can also look at this post and follow Howard's technique. It didn't work for Form Guides but will work in your case.



http://www.adobeforums.com/cgi-bin/webx/.3bc4bdbb/4



Jasmin

Avatar

Former Community Member
When I generate the .NET proxies, none of those secondary classes (e.g., BLOB, URLSpec, etc) have constructors. I've had to manually add this to the generated files. Is this expected?

Avatar

Former Community Member
That is not expected behaviour. Each complex type ie - BLOB - should have a construtor. What tool did you use to generate the proxy cs file on which the assembly was based?