Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which URL called my web service component?

Status
Not open for further replies.

rlawrence

Programmer
Sep 14, 2000
182
US
I know this sounds backwards, but I am working on a web application using VFP that will be deployed for multiple web sites on the same server--each with it's own database. I am now working on a web service component for the application, but I need to let the component know which database to connect to.

Each web site will have it's own WSDL file for the service. Clearly that WSDL file specifies the URL that the service is associated with. But once I'm executing the component, I can't see a way to refer to that URL.

I would hate to have to submit the URL as a parameter for each call. The web service definition (SOAP) and IIS both know the URL. Can anyone tell me a way to capture this reference within my component?

Thanks,

Ron
 
O.K. I found a simple asp listener procedure in the SOAP documentation, so I created an ASP page using that code. However, when I ran the WSDL generator in the SOAP Toolkit, and I specified an ASP listener, it generated a much more robust asp page which overwrote my original page. The lesson is that I DIDN'T NEED TO WORRY ABOUT CODING THE LISTENER PAGE.

Now, my web app uses the Global.asa page to set up my database connection. How I do this is not important, but when you look at my sample component method below ("TryMe"), you'll see that I refer to my own session variable, "oSession", which understands (among other things) where the database is located. The session object will be declared public within the context of the component because of the prior execution of global.asa. I'm not completely sure, but I think that using an ASP listener forces the execution of global.asa; whereas the ISAPI listener probably bypasses it.

For what it is worth... :)

Ron

Here's my sample web service code (in Visual Foxpro):

Code:
 PROCEDURE TryMe (cMessage AS String) AS String

 * Return a message indicating that this service was reached...

  * NOTE: This web service is called by an ASP listener.
  * Thus the session object should be available since it is launched
  * in Global.asa.
  IF TYPE("oSession") = "O"
   cOwner = oSession.rmC.GetName(oSession.rsOwner) + ;
     " at " + ;
     oSession.rsOwner.cDataPath
  ELSE
   cOwner = "No Session was available."
  ENDIF

  RETURN "Got your message: " + ;
    cMessage + eol + ;
    "Message processed by: " + cOwner
 ENDPROC
ENDDEFINE

My test program looks like this:

Code:
LOCAL oWS, cURL, cResult

* Identify the specific web service url to be used.
cURL = "[URL unfurl="true"]http://localhost/mywebsite/paweb.wsdl"[/URL]

* Create the SOAP Client.
oWS = CREATEOBJECT("MSSOAP.SoapClient")
oWS.MSSoapInit(cURL, "PAWeb", "WebToolsSoapPort")

* Call the web service.
cResult = oWs.TryMe("This is a test.")
?cResult

It generates the following results:

Got your message: This is a test.
Message processed by: MyCompany, Inc., Doe, John, Mytown, CA at C:\INETPUB\
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top