SasDev
asked on
Retrieving file path value from web service.
I have a classic ASP page that calls a web service.
The webservice in turn calls another class and, creates a file. It then returns the file path as a string (path to the file created - for example c:\fdemo\test\testfile.doc x).
The classic asp, for some reason, not recognizing the file path value returned by the webservice. Instead of the value returned from the webservice, if I hard code the same file path in quotes, it works okay. The following is my code in classic asp.
Dim objSoapClient, fs, f, a
SET objSoapClient = Server.CreateObject("MSSOA P.SoapClie nt30")
objSoapClient.ClientProper ty("Server HTTPReques t") = True
Call objSoapClient.mssoapinit(" http://localhost/FileStreamDemo/test/FileSteamGatewayFacade.asmx?WSDL")
Dim fileName, filePath, contentType, objStream
set fs=Server.CreateObject("Sc ripting.Fi leSystemOb ject")
set a=objSoapClient.GetName("R P")
set f=fs.GetFile(a)
'Response.Write (f.DateLastModified)
set filePath = f
contentType = "application/msword"
Response.Buffer = true
Response.Clear
Response.ContentType = contentType
Response.Addheader "ContentType", contentType
Response.Addheader "Content-Disposition", "inline; filename=" & fileName
Set objStream = Server.CreateObject("ADODB .Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile filePath
response.BinaryWrite objStream.Read
objStream.Close
Response.Flush
Response.End
set f=nothing
set fs=nothing
The following is the webservice funtion.
<WebMethod()> Public Function GetName(ByVal sName As String) As String
Dim a As New _Default()
Dim b As String = a.LoadScreenFromFileStream (1)
Return b
End Function
Thanks,
RP
The webservice in turn calls another class and, creates a file. It then returns the file path as a string (path to the file created - for example c:\fdemo\test\testfile.doc
The classic asp, for some reason, not recognizing the file path value returned by the webservice. Instead of the value returned from the webservice, if I hard code the same file path in quotes, it works okay. The following is my code in classic asp.
Dim objSoapClient, fs, f, a
SET objSoapClient = Server.CreateObject("MSSOA
objSoapClient.ClientProper
Call objSoapClient.mssoapinit("
Dim fileName, filePath, contentType, objStream
set fs=Server.CreateObject("Sc
set a=objSoapClient.GetName("R
set f=fs.GetFile(a)
'Response.Write (f.DateLastModified)
set filePath = f
contentType = "application/msword"
Response.Buffer = true
Response.Clear
Response.ContentType = contentType
Response.Addheader "ContentType", contentType
Response.Addheader "Content-Disposition", "inline; filename=" & fileName
Set objStream = Server.CreateObject("ADODB
objStream.Open
objStream.Type = 1
objStream.LoadFromFile filePath
response.BinaryWrite objStream.Read
objStream.Close
Response.Flush
Response.End
set f=nothing
set fs=nothing
The following is the webservice funtion.
<WebMethod()> Public Function GetName(ByVal sName As String) As String
Dim a As New _Default()
Dim b As String = a.LoadScreenFromFileStream
Return b
End Function
Thanks,
RP
ASKER
If I remove the line set a=objSoapClient.GetName("R
If I keep the line set a=objSoapClient.GetName("R
I also tried Response.Write(a) as an alternative to email. It also has the same issue.
Thanks,
RP
ASKER
I tested the webservice function separately by running the code in debugging mode. During that time, the function was returning the file path as a string correctly.
The weird thing is that, if I hardcode the same file path (as the value I received from the webservice), it is working perfectly fine.
That one line is all about.
Thanks,
RP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay. Thanks for your suggestion.
I tried like you mentioned. If I include that line, set a=objSoapClient.GetName(Va rA), it is not sending the email. The problem is with that one line.
I run the webservice in debug mode and test. The webservice function returns a file path - for example - c:\xx\xx\xx\abc.docx.
If I replace the call to the web service with a harcode value of what the webservice returns (c:\xx\xx\xx\abc.docx).
it sends the email and displays on the screen correctly.
Also, if I change the webservice function to return just a string value for example - "abc" it works great and send the email. The problem happens only when the webservice returns the file path of a specific filel.
Thanks,
RP
I tried like you mentioned. If I include that line, set a=objSoapClient.GetName(Va
I run the webservice in debug mode and test. The webservice function returns a file path - for example - c:\xx\xx\xx\abc.docx.
If I replace the call to the web service with a harcode value of what the webservice returns (c:\xx\xx\xx\abc.docx).
it sends the email and displays on the screen correctly.
Also, if I change the webservice function to return just a string value for example - "abc" it works great and send the email. The problem happens only when the webservice returns the file path of a specific filel.
Thanks,
RP
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Resolved
OK, glad to have helped in some way, good luck.
As always when you cannot monitor what is happening it can be difficult to see where the process is falling over. I had a similar case, recently, and was able to debug by sending myself an email. So:
Right after:
set a=objSoapClient.GetName("R
Send yourself an email which shows you the value of "a". My guess is that will help you find the problem...
GH