473,473 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Create Web Services with Word

Hi I want to create a Web Services where I receive a Template DOT word

a file XML and with these I create a Document that a I'll Send as Dime
Attachment.

<WebMethod()> _
Public Function CreateDimeWord(ByVal DotName As String, ByVal
sXML As String) As String
Dim respContext As SoapContext =
ResponseSoapContext.Current
Try
Dim wrdAPP As Object
Dim oWordDoc As Object
Dim strdocPath As String
Dim sr As System.IO.Stream
Dim i As Integer
Dim DocumentName As String
Dim sFileName As String
If respContext.Attachments.Count = 1 Then
sr = respContext.Attachments(0).Stream
DocumentName =
respContext.Attachments(0).Id.ToString.Split(":"). GetValue(1).ToString
strdocPath = Application("UploadPath") +
DocumentName
Dim objfilestream = New
System.IO.FileStream(strdocPath, System.IO.FileMode.Create)
Dim buf(sr.Length) As Byte
While ((i =
respContext.Attachments(0).Stream.Read(buf, 0, buf.Length)) > 0)
objfilestream.Write(buf, 0, i)
End While
sFileName = "c:\temp\" & DotName & ".doc"
wrdAPP = CreateObject("Word.Application")
oWordDoc = wrdAPP.Documents.Open(strdocPath, ,
True)
oWordDoc.SaveAs(sFileName)
wrdAPP.Run("WordHelper.Run", sXML)
oWordDoc.Save()
oWordDoc.Close()
oWordDoc = Nothing
Dim dimeAttach As New
DimeAttachment("application/msword", TypeFormat.MediaType, sFileName)
respContext.Attachments.Add(dimeAttach)
Return "1"
Else
Return "0"
End If
Catch ex As FieldAccessException
Return ex.ToString
End Try
End Function
this is the client...in VB6
Private Sub Command1_Click()
On Error GoTo errcode
Dim SOAPReader As MSSOAPLib30.SoapReader30
Dim SOAPSerializer As MSSOAPLib30.SoapSerializer30
Dim SOAPConnector As MSSOAPLib30.SoapConnector30
Dim SOAPParser As DimeParser30
Dim SOAPRcvdAttachments As MSSOAPLib30.IReceivedAttachment
Dim SOAPComposer As DimeComposer30
Dim DownLoadFile As String
Dim SOAPFileAttachment As FileAttachment30
Dim sNomeAllegato As String
Dim allegato As String
Set SOAPConnector = New MSSOAPLib30.HttpConnector30
SOAPConnector.Property("EndPointURL") =
"http://ibcl14/GestioneModelliWS/GestModelli.asmx"
SOAPConnector.Connect
' Set Method Call
SOAPConnector.Property("SoapAction") =
"http://tempuri.org/GestioneModelliWS/GestModelli/CreateDimeWord"
allegato = "E:\COM.dot"
Set SOAPFileAttachment = CreateObject("MSSOAP.FileAttachment30")
SOAPFileAttachment.FileName = allegato
SOAPFileAttachment.DeleteAfterSending = False
'For j = 3 To Len(allegato)
' strTestChar = Mid(allegato, Len(allegato) - j, 1)
' If strTestChar = "\" Then
' sNomeAllegato = Right(allegato, j)
' Exit For
' End If
'Next
SOAPConnector.BeginMessage
' Create DIME composer and serializer objects, then initialize the
' serializer with the composer.
Set SOAPComposer = CreateObject("MSSOAP.DimeComposer30")
Set SOAPSerializer = CreateObject("MSSOAP.SoapSerializer30")
SOAPSerializer.InitWithComposer SOAPConnector.InputStream,
SOAPComposer
' Serializer.Init Connector.InputStream
' Write out the SOAP Envelope and Body start tags.
SOAPSerializer.StartEnvelope
SOAPSerializer.StartBody
' Start the method element.
SOAPSerializer.StartElement "CreateDimeWord",
"http://tempuri.org/"
SOAPSerializer.StartElement "DotName"
SOAPSerializer.WriteString "Prova"
SOAPSerializer.EndElement
SOAPSerializer.StartElement "sXML"
SOAPSerializer.WriteString
"LIBRANET><COMUNICAZIONI><RECORDS><RECORD><id_Comu nicazione>62</id_Comunica*zione><id_Installazione>111111</id_Installazione><c_TipoDelibera>DG

</c_TipoDelibera></RECORD></RECORDS></COMUNICAZIONI></LIBRANET>"
SOAPSerializer.EndElement
SOAPSerializer.AddAttachment SOAPFileAttachment
SOAPSerializer.EndElement
' Write out the SOAP Envelope and Body end tags.
SOAPSerializer.EndBody
SOAPSerializer.EndEnvelope
' Tell the serializer that we are finished providing all message
' content (both the SOAP envelope and all attachments).
SOAPSerializer.Finished
SOAPConnector.EndMessage
''''SOAPConnector.BeginMessage
''''
''''Set SOAPComposer = CreateObject("MSSOAP.DimeComposer30")
''''Set SOAPSerializer = New MSSOAPLib30.SoapSerializer30
''''SOAPSerializer.InitWithComposer SOAPConnector.InputStream,
SOAPComposer
''''
''''' Create/Send SOAP Message with Parameter "Number"
''''
''''SOAPSerializer.StartEnvelope
'''' SOAPSerializer.StartBody
'''' SOAPSerializer.StartElement "DownloadFile",
"http://tempuri.org/"
'''' SOAPSerializer.StartElement "DocumentName"
'''' SOAPSerializer.WriteString sNomeAllegato
'''' SOAPSerializer.EndElement
''''' SOAPSerializer.StartElement "sXML"
''''' SOAPSerializer.WriteString "XX"
''''' SOAPSerializer.EndElement
'''' SOAPSerializer.AddAttachment SOAPFileAttachment
'''' SOAPSerializer.EndElement
'''' SOAPSerializer.EndBody
''''SOAPSerializer.EndEnvelope
''''
''''SOAPConnector.EndMessage
Set SOAPReader = New SoapReader30
SOAPReader.Load SOAPConnector.OutputStream
If Not SOAPReader.Fault Is Nothing Then
DownLoadFile = "0"
Else
DownLoadFile = "1"
End If
'Set SOAPReader = New SoapReader30
'Set SOAPParser = New DimeParser30
'If SOAPReader.LoadWithParser(SOAPConnector.OutputStre am, SOAPParser)
Then
' Set SOAPRcvdAttachments = SOAPReader.Attachments.Item(0)
' SOAPRcvdAttachments.SaveToFile "C:\downloaded.doc"
' DownLoadFile = "OK"
'Else
' DownLoadFile = "no attachment"
'End If
'MsgBox DownLoadFile
Exit Sub
errcode:
MsgBox Err.Description
Unload Me
End Sub
The Web Services don't work
Why? Thanks a Lot

Mar 14 '06 #1
0 753

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thomas Jespersen | last post by:
Hello I want to create a MSI file programmatically. Do you know of any third party .NET component which can help me with that? I'm going to use it like a self extracting zip. So it is not...
3
by: James Proctor | last post by:
Hi there, im brand new to ASP. Ive done loads of VB coding and one of my clients is intrested in a web based application, so im trying to play on and learn it a tad. However im comming across lots...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
1
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
0
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
0
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: dataentryoffshore | last post by:
Get a Discount up to 60% on data entry, data capture, dataentry services, large volume data processing and data conversion services through offshore facilities in India. Offshore data entry also...
0
by: dbsog7777 | last post by:
I was trying to use the sample code below, but I encountered two errors: Application.DoEvents() and AutoText(entry). I am not sure how to correct the errors. I trying to use the sample code to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.