Solved

Retrieving file path value from web service.

Posted on 2011-09-23
8
379 Views
Last Modified: 2012-05-12
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.docx).

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("MSSOAP.SoapClient30")
    objSoapClient.ClientProperty("ServerHTTPRequest") = True

    Call objSoapClient.mssoapinit("http://localhost/FileStreamDemo/test/FileSteamGatewayFacade.asmx?WSDL")
 
    Dim fileName, filePath, contentType, objStream
   
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set a=objSoapClient.GetName("RP")
    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

0
Comment
Question by:SasDev
  • 5
  • 3
8 Comments
 
LVL 11

Expert Comment

by:G_H
ID: 36587948
{Bit of a stab in the dark}

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("RP")

Send yourself an email which shows you the value of "a". My guess is that will help you find the problem...

GH
0
 
LVL 1

Author Comment

by:SasDev
ID: 36588776

If I remove the line set a=objSoapClient.GetName("RP"), and ran the code, it is sending email to my emailId correctly.

If I keep the line set a=objSoapClient.GetName("RP"), and ran the code, it is not sending the email.

I also tried Response.Write(a) as an alternative to email. It also has the same issue.

Thanks,

RP
0
 
LVL 1

Author Comment

by:SasDev
ID: 36588802

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
0
 
LVL 11

Accepted Solution

by:
G_H earned 500 total points
ID: 36591895
OK, just to try and confirm the place at which this is failing, can you please make changes like this:

VarA = "RP"
Call SendEmail (VarA)
set a=objSoapClient.GetName(VarA)
Call SendEmail (a)
set f=fs.GetFile(a)

I'm just trying to confirm that you are sending something valid, then getting something valid back...

GH
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:SasDev
ID: 36817192
Sorry for the delay. Thanks for your suggestion.

I tried like you mentioned. If I include that line, set a=objSoapClient.GetName(VarA), 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
0
 
LVL 1

Assisted Solution

by:SasDev
SasDev earned 0 total points
ID: 36817758
Nevermind. I figured out. The problem neither lies with the classic asp page nor with the webservice. It is with another aspx page that the webservice is calling.

I will go ahead and mar this issue as resolved.
0
 
LVL 1

Author Closing Comment

by:SasDev
ID: 36908479
Resolved
0
 
LVL 11

Expert Comment

by:G_H
ID: 36817770
OK, glad to have helped in some way, good luck.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
syntax error on ASP ? 6 43
SQL Filter Question 8 78
JSON error 4 51
PDF Embed pdfobject.js local path problem regular ASP 2 117
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now