Writing web Service with VFP (II.)

Source: Internet
Author: User
Tags web services wsdl

Publish Web Service

To establish a virtual directory in IIS

This step is simple, create a virtual directory. The property pages that are set up later are:


Figure I

Here I only set two attributes, others remain in the default state. Set the name: First_web_service, set the local path is the path of the DLL, here is: D:\VFP7_Web_Service.

Publishing Web Service in Visual FoxPro

Tools-〉 Wizard-〉web Services

Figure II

The following interface pops up:

Figure Three

Here, in COM server, we select the DLL that we just compiled.

For more information, press the "Advanced ..." button to eject the following dialog box:

Figure Four

The WSDL file here must be set up to describe the service that the Web service can provide, as well as the external interface. We have it stored in the virtual directory, the filename is foxwebservice.wsdl.

Another useful option here is "Intellsense Scripts", the relationship between the Web service and the Visual FoxPro development environment: Registering the interface of the Web service into Intellsense, so that the visual It would be convenient to call this Web service in FoxPro, and of course, there is no way to register the Web service in Intellsense, but in Visual FoxPro, see: Visual FoxPro 7 New debut of--web Service Client.

There is also an option "Automatically generate Web service file during project build", which means that when the project builds COM, a new Web service file is created This option is actually a Visual FoxPro project Hook that can also be set up in the Visual FoxPro development environment.

After filling out the relevant data, press "OK" and return to figure three. Press the "Generate" button, and if the registration succeeds, it will jump out of the dialog box:

Here, the announcement became.

Test Web Service

Simple test Code

How to use a WEB service, if you have seen the article "Visual FoxPro 7 new debut--web Service Client", there should be no problem, here is only the code:

* Please ensure that the C-packing directory does not exist FoxWebService.txt files, if there is deleted it (our goal is to prove that the web Service is "stateless")
Local Oweb as Vfpwebservice_ws
Local lows
Lows = NewObject ("WSClient", Home () + "FFC\_WEBSERVICES.VCX")
Lows.cwsname = "Vfpwebservice_ws"
Oweb = Lows.setupclient ("http://BOEWORKS/first_web_service/FoxWebService.wsdl", "Foxwebservice", " Foxwebservicesoapport ")
Xmltocursor (Oweb. Getinvoice (0), "test")
? oweb. Getsumsales ({^1997-01-01},{^1997-3-30})

If the test succeeds, please check the FoxWebService.txt file in the C packing directory, the contents of my file are (depending on the test time, the results will be different):

Opening time 23:50:47 Closing time 23:50:48 Opening time 23:50:50 Closing Time 23:50:50

Non-stateful web Service

Here we found that the Web Service object was created and destroyed two times during the execution of the code, while almost the same code, based on COM, was created and destroyed once. This shows that the Web service is "stateless" and that the client program is automatically created every time it is invoked, and the call is automatically destroyed. This is called two times, respectively, by calling the Getinvoice () method and the Getsumsales () method. The invocation of these two methods has nothing to do with it, that is, the WEB service does not save the state that was generated after the previous call, and is used for later invocation, which is quite different from the traditional COM invocation.

The most intriguing part of this is this code:

Oweb = Lows.setupclient ("http://BOEWORKS/first_web_service/FoxWebService.wsdl", "Foxwebservice", " Foxwebservicesoapport ")

It looks like the CreateObject () used to invoke COM, and I haven't looked at the soap documentation yet, but I think it's just an interface to request a Web service and initialize something locally on the client, which has no effect on the Web service.

The pros and cons of no State

The biggest benefit of stateless is high efficiency, the WEB service is not serviced for several customers, it is impossible to remember the request status of each client, if so, the system efficiency will be very low. However, if the Web service does not know the state of the client's program, nor does it interact well with the client, it cannot interact well, and cannot make large, good projects. This is Russian. I think of ASP, as a Web application, it is also stateless, but in order to realize the server and client interaction (state memory), put forward the so-called stored in the client's cookies and server-side Session object ... In order to balance efficiency and function.

What exactly is the publication of Web service

Postscript

Web Service is a very new and popular thing, and it is gratifying that--visual FoxPro 7 can support its development well. Although I encountered a lot of hardships in the learning process, this can not say that this technology is not good, can only think that my level too, really should study well ...

It's one o'clock in the morning again, I am very worried about the value of this article-how many netizens can smooth the experiment down, after all, this article involves a lot of Visual FoxPro developers unfamiliar things ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.