views:

91

answers:

5

I don't have much experience with web services, but I think I have a problem for which a web service would work great.

My company has just purchased a .net version of Cete Pdf Merger (great product btw). We use both .Net & asp code and will likely use java in the future as well.

The scenario is that one technology (asp, java, .net) would have a list of raw data such as an array of field names & values. This data would be posted to the web service that would then open a given pdf, match pdf form fields to the field names array, grab the corresponding value, populate it on the pdf, and then stream the pdf back to the user to download.

Does this seem feasible? Any gotcha's I might run into that you know of? Any preferred method of doing (Web Services, WCF, ???)

A: 

If you're going to use web services with .NET, I recommend using WCF (Windows Communication Foundation).

Bernard
+1  A: 

Short answer: WCF

Longer answer is: you seem to be making a distinction between WCF and "web services". Perhaps you're thinking of the old ".asmx" web services. Microsoft now considers them to be "legacy software", and suggests you use WCF for all new web service development.

John Saunders
Could these other technologies (asp / java) call/invoke WCF? I've not used WCF at all so I'm not sure. I'll look into this in details this evening.
Jason
Yes. That's what WCF is for - it's the replacement for ASMX web services, and then does about 20 times as much, and does it better.
John Saunders
A: 

WCF (MSDN) is a good choice, but you if you would like to provide a user interface (such as an HTML form to type in the field values), you could use a regular web form and post to a page with HTTP, returning the PDF output by streaming the response with the appropriate MIME-type.

jscharf
A: 

This sounds like a great idea. You could use an .asmx web service (others might look down on .asmx).

Suggest creating a webmethod like so:

(this example is rough around the edges, but it's just to describe the general idea)

[WebMethod]
public void CreatePdfIncomeTax(IncomeTaxForm itf)
{
    // integrate with Cete Pdf Merger 
    string fileName = SomePdfMerging(itf);

    Response.ContentType = "application/pdf";
    Response.AddHeader("Content-Disposition", "inline; filename=foo.pdf");
    Response.WriteFile(path);
    Response.Flush();
    Response.End();
}

...
// a class that the caller would populate as param to the webmethod
public class IncomeTaxForm 
{
   public string FirstName {get;set;}
   public string AddressLine1 {get;set;}
   ...
}
p.campbell
Why in the world would you suggest that new development be done using a legacy technology? Also, how would this service be consumed? Anything looking at the WSDL will decide there is no output from this service.
John Saunders
@John: the world hasn't moved away from asmx over to WCF. Lots of experience out there with asmx, and unfortunately some (mis)conceptions around WCF and overt complexity amongst devs. You and Microsoft might consider it legacy, but it's got a lot of momentum still. I sure didn't mean to attract derisive comments with this answer. I put a disclaimer on the rough code, and wanted to leave the OP with an idea on how to make a PDF available to a caller. @Everyone: It's not meant to be copy/pasted into production. :)
p.campbell
@p.campbell: perhaps you meant "inertia" and not "momentum"?
John Saunders
A: 

I've done pretty much that exact thing but using Aspose as the PDF component. We used an .asmx web service and not WFC which is what I wanted. I would certainly agree with everyone else that say that WCF is the way to go. I know that I would have preferred that, but the decision was unfortunately not mine to make.

daft