473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Create Web Services

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
1 2295
please do not crosspost in multiple groups. It's considered rude

Mar 14 '06 #2

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

Similar topics

4
by: Benny Dein | last post by:
Hi I want to create a servlet or something similar by which im able to create virtual webservices. Lets say i would like to create a webservice with a method called 'getDate' which returnes...
2
by: Peter | last post by:
Firstly let me be very clear about this, I do not want to create a web service proxy nor do I want to do anything with web services. Basically, I have a shrink wrapped desktop application which...
3
by: Mark B | last post by:
I want to create a top navigation bar: Home Products Services About Contact I have been trying to use web.sitemap as the source for a menu control as show in the...
5
by: krasman | last post by:
hi everyone, i hope you might help me on this one. i need to create a contact in a exchange public folder using dotnet (vb or c#) and exchange 2003, without using outlook object model. i'm...
5
by: krasman | last post by:
hi everyone, i hope you might help me on this one. i need to create a contact in a exchange public folder using dotnet (vb or c#) and exchange 2003, without using outlook object model. i'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.