Consuming WCF Web Service - Beginner Level

Posted by Brmcdani44 under WCF on 11/3/2011 | Points: 10 | Views : 1987 | Status : [Member] | Replies : 2
We are trying to create a web service that will create a pdf using a third party tool. Only trouble is none of us have ever created a WCF and then consumed it on a Windows Form before.

I have added the reference successfully and can reference the class I created but I cannot figure out how to make it do it's job. I need to send a URL to the web service from a Web Browser Control. The web service will then create the PDF in byte code, then send it back to the client, the client will then show the PDF in a Web Browser Control. Can someone please tell me what I need to do? Any help will be appreciated. Thanks.

Imports System.ServiceModel
Imports WebSupergoo.ABCpdf8

Public Interface ICreatePDF

Function CreatePDF(ByVal givenURL As String) As Byte
End Interface

The Client Windows Form has the Service referenced. I just need to send the URL and then return the byte data the service renders.
Imports WebSupergoo.ABCpdf8

Public Class CreatePDF
Implements ICreatePDF

Public Function CreatePDF(ByVal givenURL As String) As Byte Implements ICreatePDF.CreatePDF
Dim theDoc As New Doc
Dim theID = theDoc.AddImageUrl(givenURL, True, 0, True)

Do While True
If Not theDoc.Chainable(theID) Then
Exit Do
End If

theDoc.Page = theDoc.AddPage()
theID = theDoc.AddImageToChain(theID)
theDoc.SaveOptions.Linearize = True

Dim theData As Byte() = theDoc.GetData()

Return theData(0)
End Function

End Class


Posted by: Vuyiswamb on: 11/3/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

it is Simple ,

MyserviceProxy client = new MyserviceProxy();

Byte[] pdf = client.CreatePDF("");

if you need more assistance , you can shout

Thank you for posting at Dotnetfunda

Brmcdani44, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundan64 on: 11/30/2012 [Member] Starter | Points: 25

You already added ServiceRefernce then Imports the service reference in your page
and then write
Dim client as New MyServiceProxy()

Dim pdf As [Byte]() = client.CreatePDF("")

Brmcdani44, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response