Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SOAP Attachment
Message
From
18/03/2004 09:16:41
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Internet applications
Title:
SOAP Attachment
Miscellaneous
Thread ID:
00887472
Message ID:
00887472
Views:
224
Hi All,

I'm testing Soap connectings with attachment in the moment.

This means I've tried to translate the VB example from the SOAPToolkit helpfile to VFP and try to run it.

This is I use the followingcode as Server:
* note the parameter order - the ReceivedAttachments30 parameter must
* appear before the SentAttachments30 parameter
* and the collection parameters must be the last set of parameters.
DEFINE CLASS Attachment AS SESSION OLEPUBLIC

 PROCEDURE ProcessCollection (;
   toReceivedCollection AS MSSOAP.ReceivedAttachments30 @,;
   toCollectionReturned AS MSSOAP.SentAttachments30 @) AS BOOLEAN

  LOCAL;
   lnLoop AS INTEGER,;
   lcFileName AS STRING,;
   loSentAttachmentsTemp AS MSSOAP.SentAttachments30,;
   loReceivedAttach AS MSSOAP.IReceivedAttachment,;
   loAttachTemp AS MSSOAP.FileAttachment30


  loSentAttachmentsTemp = CREATEOBJECT('MSSOAP.SentAttachments30')

*  ' save attachment(s) received'
  lnLoop = 1
  FOR EACH loReceivedAttach IN toReceivedCollection
   lcFileName = "C:\Inetpub\webpub\AttachSample\AttachmentSample2\Server\RcvdFromClient"+TRANSFORM(lnLoop,'@RL 9999')+".txt"
*  FileName = "RcvdFromClient" & CStr(i) & ".txt"
*  FileName = fso.BuildPath(APP.PATH, FileName)
   loReceivedAttach.SaveToFile(lcFileName,.T.)
   lnLoop = lnLoop + 1
  NEXT

* ' now return attachment(s), as unreferenced collection to the client'
* ' 2 attachments are returned in this example'
* ' Adding attachment 1 to the collection'
  loAttachTemp = CREATEOBJECT("MSSOAP.FileAttachment30")
  lcFileName = "C:\Inetpub\webpub\AttachSample\AttachmentSample2\Client\Attachment1FromSvr.txt"
  loAttachTemp.FileName = lcFileName
  loSentAttachmentsTemp.ADD(loAttachTemp)

* ' Adding attachment 2 to the collection'
  loAttachTemp = CREATEOBJECT("MSSOAP.FileAttachment30")
  lcFileName = "C:\Inetpub\webpub\AttachSample\AttachmentSample2\Client\Attachment2FromSvr.txt"
  loAttachTemp.FileName = lcFileName
  loSentAttachmentsTemp.ADD(loAttachTemp)

* ' now return the collection'
  toCollectionReturned = loSentAttachmentsTemp
 ENDPROC

ENDDEFINE &&Attachment
and as client
* SOAP Toolkit 3.0 - Advanced Topics

LOCAL;
 lcwsdl     AS CHARACTER,;
 lcwsml     AS CHARACTER,;
 lcFileName AS CHARACTER,;
 lnLoop     AS INTEGER,;
 llres      AS BOOLEAN

LOCAL;
 loSoapClient         AS MSSOAP.SoapClient30,;
 loFileAttach         AS MSSOAP.FileAttachment30,;
 loSentCollection     AS MSSOAP.SentAttachments30,;
 loStringAttach       AS MSSOAP.StringAttachment30,;
 loReceivedCollection AS MSSOAP.ReceivedAttachments30,;
 loReceivedAttach     AS MSSOAP.IReceivedAttachment

lcwsdl = "AttachmentSample2.WSDL"
lcwsml = "AttachmentSample2Client.WSML"

loSentCollection = CREATEOBJECT("MSSOAP.SentAttachments30")

loSoapClient = CREATEOBJECT("MSSOAP.SoapClient30")
loSoapClient.MSSoapInit('http://MyServer/WebPub/Soap3DocSamples/AttachmentSample2/Server/AttachmentSample2.WSDL', "AttachmentSample2", "AttachmentSoapPort", "")

*' client sending two attachment in the collection
*' Adding attachment 1 (a file attachment)to the collection
loFileAttach = CREATEOBJECT("MSSOAP.FileAttachment30")
lcFileName = "e:\se\foxpro\web\Attachment1FromClient.txt"
*lcFileName = fso.BuildPath(APP.PATH, FileName)
loFileAttach.FileName = lcFileName
loSentCollection.ADD(loFileAttach)
*' Adding attachment 2 (a string attachment) to the collection'
loStringAttach = CREATEOBJECT("MSSOAP.StringAttachment30")
loStringAttach.STRING = "<Attachment2FromClient>Test</Attachment2FromClient>"
*' let us set some properties'
loStringAttach.Property("DimeTNF") = "media-type"
loStringAttach.Property("DimeType") = "text/xml, charset=utf-8"
loSentCollection.ADD(loStringAttach)

loReceivedCollection = CREATEOBJECT("MSSOAP.ReceivedAttachments30")

*'now call the operation and passed in the collection as
*' SentCollection parameter. All attachments are send unreferenced
llres = loSoapClient.ProcessCollection(loSentCollection,loReceivedCollection)

*' now save the attachment received from the server to files
FOR lnLoop = 0 TO loReceivedCollection.COUNT - 1
 lcFileName = "e:\se\foxpro\web\RcvdFromSvr"+TRANSFORM(lnLoop,'@RL 9999')+".txt"
 loFileAttach.FileName = loFileName
 loReceivedAttachment = loReceivedCollection.ITEM(lnLoop)
 loReceivedAttachment.SaveToFile(lcFileName, True)
NEXT
My Problem is that clients
loReceivedCollection = CREATEOBJECT("MSSOAP.ReceivedAttachments30")
comes up with OLE Error 0x80040111 "Class factory can't find class" (or the like, it's german text).
This is a nice one, because Intellisense can resolve the declaration beyond in the LOCAL section.

If I ignore the error the soap connection starts, the server recieces the attachments and returns.
But (logicaly) the return fails with "OLE IDispatch Wrong data type", what means there is no return in loReceivedCollection. This error is on the client side, the server runs fine until end.

What do I miss?

TIA
Agnes
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Reply
Map
View

Click here to load this message in the networking platform