Consuming WCF Web Service - Beginner Level

Posted by Brmcdani44 under WCF on 11/3/2011 | Points: 10 | Views : 1599 | 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.

VB:
Imports System.ServiceModel
Imports WebSupergoo.ABCpdf8

<ServiceContract()>
Public Interface ICreatePDF

<OperationContract()>
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.
svc.vb:
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
theDoc.FrameRect()
If Not theDoc.Chainable(theID) Then
Exit Do
End If

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

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

Return theData(0)
End Function

End Class





Responses

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

Up
0
Down
it is Simple ,

MyserviceProxy client = new MyserviceProxy();


Byte[] pdf = client.CreatePDF("http://www.dotnetfuda.com");


if you need more assistance , you can shout

Thank you for posting at Dotnetfunda
[Administrator]

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

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

Up
0
Down
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("http://www.dotnetfuda.com")


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

Login to post response